Compare commits
No commits in common. "fb8a41fb81ddbfcd49db0b8ee7c2090db724a348" and "5507b1eabf19c4527cc25105d0e3a9fd00696095" have entirely different histories.
fb8a41fb81
...
5507b1eabf
161 changed files with 789 additions and 3381 deletions
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
trigger: manual
|
||||
---
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
.idea/dictionaries/project.xml
generated
1
.idea/dictionaries/project.xml
generated
|
|
@ -2,7 +2,6 @@
|
|||
<dictionary name="project">
|
||||
<words>
|
||||
<w>grimms</w>
|
||||
<w>soulbound</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
20
build.gradle
20
build.gradle
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = 'org.gsdistance'
|
||||
version = '1.5.7'
|
||||
version = '1.5.5'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
@ -50,7 +50,7 @@ processResources {
|
|||
}
|
||||
|
||||
// Custom task to clean only jar files before build
|
||||
tasks.register('cleanJars', Delete) {
|
||||
task cleanJars(type: Delete) {
|
||||
delete fileTree('build/libs') {
|
||||
include '*.jar'
|
||||
exclude "${project.name}-${version}.jar"
|
||||
|
|
@ -58,19 +58,5 @@ tasks.register('cleanJars', Delete) {
|
|||
}
|
||||
|
||||
// Run cleanJars before every build
|
||||
build.dependsOn 'cleanJars'
|
||||
|
||||
// Custom task to increment build.v on every build
|
||||
tasks.register('incrementBuildVersion') {
|
||||
doLast {
|
||||
def buildFile = file('src/main/resources/build.v')
|
||||
def currentVersion = buildFile.text.trim().toInteger()
|
||||
def newVersion = currentVersion + 1
|
||||
buildFile.text = newVersion.toString()
|
||||
println "Build version incremented to: ${newVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
// Run incrementBuildVersion before every build
|
||||
build.dependsOn 'incrementBuildVersion'
|
||||
build.dependsOn cleanJars
|
||||
|
||||
|
|
|
|||
BIN
build/libs/GrimmsServer-1.5.4.jar
Normal file
BIN
build/libs/GrimmsServer-1.5.4.jar
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -650,7 +650,7 @@ code + .copy-button {
|
|||
<script type="text/javascript">
|
||||
function configurationCacheProblems() { return (
|
||||
// begin-report-data
|
||||
{"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.5/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('filteringCharset = <value>') instead."}]]},{"locations":[{"path":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java"},{"taskPath":":compileJava"}],"problem":[{"text":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java uses unchecked or unsafe operations."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java uses unchecked or unsafe operations."}],"contextualLabel":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java uses unchecked or unsafe operations.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.filename","displayName":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java uses unchecked or unsafe operations."}]},{"locations":[{"path":"/home/tyuxx/IdeaProjects/GrimmsServer/src/main/java/org/gsdistance/grimmsServer/Constructable/Entity/EntityMetadata.java"},{"taskPath":":compileJava"}],"problem":[{"text":"Recompile with -Xlint:unchecked for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:unchecked for details."}],"contextualLabel":"Recompile with -Xlint:unchecked for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.recompile","displayName":"Recompile with -Xlint:unchecked for details."}]}],"problemsReport":{"totalProblemCount":3,"buildName":"GrimmsServer","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.5/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
{"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.5/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('filteringCharset = <value>') instead."}]]}],"problemsReport":{"totalProblemCount":1,"buildName":"GrimmsServer","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.5/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
// end-report-data
|
||||
);}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,32 +1,36 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
package org.gsdistance.grimmsServer.Commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AddTitle {
|
||||
public class AddTitle implements CommandExecutor {
|
||||
public AddTitle() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||
if (args.length < 3) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
} else if (!PlayerTitles.titles.containsKey(args[2])) {
|
||||
} else if (!PlayerTitles.titles.containsKey(args[1])) {
|
||||
sender.sendMessage("Title not found.");
|
||||
return false;
|
||||
} else {
|
||||
Player player = GrimmsServer.instance.getServer().getPlayer(args[1]);
|
||||
Player player = GrimmsServer.instance.getServer().getPlayer(args[0]);
|
||||
if (player == null) {
|
||||
sender.sendMessage("Player not found.");
|
||||
return false;
|
||||
} else {
|
||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||
if (playerTitles.hasTitle(args[2])) {
|
||||
if (playerTitles.hasTitle(args[1])) {
|
||||
sender.sendMessage("Player already has this title.");
|
||||
return false;
|
||||
} else {
|
||||
playerTitles.addTitle(args[2]);
|
||||
sender.sendMessage("Title " + args[2] + " added to " + player.getDisplayName() + ".");
|
||||
playerTitles.addTitle(args[1]);
|
||||
sender.sendMessage("Title " + args[1] + " added to " + player.getDisplayName() + ".");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,6 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class DepositMoney implements CommandExecutor {
|
||||
public DepositMoney() {
|
||||
}
|
||||
|
|
@ -42,15 +40,13 @@ public class DepositMoney implements CommandExecutor {
|
|||
}
|
||||
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats((Player) sender);
|
||||
BigDecimal banknoteValueBD = BigDecimal.valueOf(banknoteValue);
|
||||
BigDecimal totalValue = banknoteValueBD.multiply(BigDecimal.valueOf(itemStack.getAmount()));
|
||||
double totalValue = banknoteValue * itemStack.getAmount();
|
||||
double currentBalance = playerStats.getStat("money", Double.class);
|
||||
BigDecimal newBalance = BigDecimal.valueOf(currentBalance).add(totalValue);
|
||||
|
||||
playerStats.setStat("money", newBalance.doubleValue());
|
||||
playerStats.setStat("money", currentBalance + totalValue);
|
||||
((Player) sender).getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Deposited " + ChatColor.GOLD + Shared.formatNumber(totalValue.doubleValue()) + ChatColor.GREEN + ". New balance: " + ChatColor.GOLD + Shared.formatNumber(newBalance.doubleValue()));
|
||||
sender.sendMessage(ChatColor.GREEN + "Deposited " + ChatColor.GOLD + Shared.formatNumber(totalValue) + ChatColor.GREEN + ". New balance: " + ChatColor.GOLD + Shared.formatNumber(currentBalance + totalValue));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GAuthBaseCommand implements CommandExecutor {
|
||||
public GAuthBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import java.util.List;
|
|||
public class GAuthTabCompleter implements TabCompleter {
|
||||
public static final List<String> subCommands = List.of("register", "unregister", "login", "autologin");
|
||||
|
||||
public GAuthTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Login {
|
||||
public Login() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String pass) {
|
||||
if (GAuthBaseCommand.isLoggedIn(player)) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Register {
|
||||
public Register() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String pass) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Unregister {
|
||||
public Unregister() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String pass) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Config.ActiveConfig;
|
|||
import org.gsdistance.grimmsServer.Config.ConfigKey;
|
||||
|
||||
public class Dump {
|
||||
public Dump() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.GOLD + "=== Config Dump ===");
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GConfigBaseCommand implements CommandExecutor {
|
||||
public GConfigBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import java.util.List;
|
|||
public class GConfigTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("dump", "reload");
|
||||
|
||||
public GConfigTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import java.util.logging.Level;
|
||||
|
||||
public class Reload {
|
||||
public Reload() {
|
||||
}
|
||||
|
||||
public static boolean subCommand() {
|
||||
Shared.Broadcast("Reloading config...", null);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GDecoBaseCommand implements CommandExecutor {
|
||||
public GDecoBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import java.util.List;
|
|||
public class GDecoTabCompleter implements TabCompleter {
|
||||
public static final List<String> subCommands = List.of("selectTitle", "clearTitle", "togglePrestigeDeco");
|
||||
|
||||
public GDecoTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
|
||||
public class SelectTitle {
|
||||
public SelectTitle() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String title) {
|
||||
PlayerTitles playerTitles = PlayerTitles.getPlayerTitles(player);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Indexers.DynamicDimensionGen;
|
|||
import java.util.Arrays;
|
||||
|
||||
public class Create {
|
||||
public Create() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender player, String[] args) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
public class Delete {
|
||||
public Delete() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GDimBaseCommand implements CommandExecutor {
|
||||
public GDimBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
public class GDimTabCompleter implements TabCompleter {
|
||||
public GDimTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public java.util.List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
public class Info {
|
||||
public Info() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.gsdistance.grimmsServer.Constructable.World.WorldConstructor;
|
||||
|
||||
public class List {
|
||||
public List() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender player) {
|
||||
player.sendMessage("Constructed Worlds:");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
public class Tp {
|
||||
public Tp() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Constructable.Faction;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class Chat {
|
||||
public Chat() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.gsdistance.grimmsServer.Constructable.Faction;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class Claim {
|
||||
public Claim() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GFactionBaseCommand implements CommandExecutor {
|
||||
public GFactionBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import java.util.stream.Collectors;
|
|||
public class GFactionTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("invite", "join", "leave", "kick", "info", "new", "claim", "unclaim", "setrank", "unclaimall", "sethome", "home", "chat", "showclaims");
|
||||
|
||||
public GFactionTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Constructable.Faction;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class Home {
|
||||
public Home() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import org.gsdistance.grimmsServer.Data.FactionRank;
|
|||
import java.util.UUID;
|
||||
|
||||
public class Info {
|
||||
public Info() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import org.gsdistance.grimmsServer.Data.FactionRank;
|
|||
import java.util.UUID;
|
||||
|
||||
public class Invite {
|
||||
public Invite() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import org.gsdistance.grimmsServer.GrimmsServer;
|
|||
import java.util.UUID;
|
||||
|
||||
public class Join {
|
||||
public Join() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Constructable.Faction;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class Kick {
|
||||
public Kick() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.gsdistance.grimmsServer.Data.FactionRank;
|
||||
|
||||
public class Leave {
|
||||
public Leave() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class New {
|
||||
public New() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
@ -26,31 +28,16 @@ public class New {
|
|||
} else if (args.length < 3) {
|
||||
return false;
|
||||
} else {
|
||||
String factionId = args[1];
|
||||
String factionName = args[2];
|
||||
|
||||
// Validate faction ID length
|
||||
if (factionId.length() < 3 || factionId.length() > 16) {
|
||||
player.sendMessage(ChatColor.RED + "Faction id must be between 3 and 16 characters.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate faction name length
|
||||
if (factionName.length() < 2 || factionName.length() > 32) {
|
||||
player.sendMessage(ChatColor.RED + "Faction name must be between 2 and 32 characters.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Faction[] factions = GrimmsServer.pds.retrieveAllData(Faction.class, "factions");
|
||||
if (factions != null && Arrays.stream(factions).anyMatch((factionx) -> factionx.id.equalsIgnoreCase(factionId))) {
|
||||
if (factions != null && Arrays.stream(factions).anyMatch((factionx) -> factionx.id.equalsIgnoreCase(args[1]))) {
|
||||
player.sendMessage(ChatColor.RED + "Faction already exists with this id.");
|
||||
return false;
|
||||
} else if (!factionId.matches("[a-zA-Z0-9_]+")) {
|
||||
} else if (!args[1].matches("[a-zA-Z0-9_]+")) {
|
||||
player.sendMessage(ChatColor.RED + "Faction id can only contain letters, numbers and underscores.");
|
||||
return false;
|
||||
} else {
|
||||
Faction faction = new Faction(factionId, new ArrayList(List.of(new Data(player.getUniqueId(), FactionRank.LEADER))));
|
||||
faction.name = factionName;
|
||||
Faction faction = new Faction(args[1], new ArrayList(List.of(new Data(player.getUniqueId(), FactionRank.LEADER))));
|
||||
faction.name = args[2];
|
||||
faction.saveToFile();
|
||||
playerMetadata.factionUUID = faction.uuid;
|
||||
playerMetadata.saveToPDS();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.gsdistance.grimmsServer.Data.FactionRank;
|
||||
|
||||
public class SetHome {
|
||||
public SetHome() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class SetRank {
|
||||
|
||||
public SetRank() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
// Guard: Ensure minimum argument length
|
||||
if (args.length < 3) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ public class ShowClaims {
|
|||
private static final int VISUAL_RADIUS = 3; // Show 3 chunks in each direction
|
||||
private static final int CHUNK_SIZE = 16;
|
||||
|
||||
public ShowClaims() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
if (playerMetadata.factionUUID == null) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.gsdistance.grimmsServer.Constructable.Faction;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class UnClaim {
|
||||
public UnClaim() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.gsdistance.grimmsServer.Data.FactionRank;
|
||||
|
||||
public class UnClaimAll {
|
||||
public UnClaimAll() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerMetadata playerMetadata = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class GHelp implements CommandExecutor {
|
||||
public GHelp() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class GHelpTabCompleter implements TabCompleter {
|
||||
public GHelpTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.gsdistance.grimmsServer.Commands.GLevelCommand;
|
|||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerLevelHandler;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
|
@ -30,10 +29,6 @@ public class Prestige {
|
|||
playerStats.setStat("xp", 0.0);
|
||||
playerStats.setStat("xp_required", levelHandler.getXpToLevel());
|
||||
|
||||
Market market = Market.getMarket();
|
||||
market.serverPrestiges += 1;
|
||||
market.saveMarket();
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + "You have prestiged to prestige " + newPrestige + "!");
|
||||
player.sendMessage(ChatColor.GOLD + "You received " + newPrestige + " prestige points. Total: " + (currentPrestigePoints + newPrestige));
|
||||
Shared.Broadcast(ChatColor.DARK_PURPLE + "[" + player.getName() + "] has prestiged to " + newPrestige + "!", null);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Constructable.World.ChunkMetadata;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GLogBaseCommand implements CommandExecutor {
|
||||
public GLogBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GLogCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Shared.getOnlinePlayers;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GStatsBaseCommand implements CommandExecutor {
|
||||
public GStatsBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GStatsCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
@ -10,6 +12,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.gsdistance.grimmsServer.Shared.getOnlinePlayers;
|
||||
|
||||
|
|
@ -18,6 +21,9 @@ public class GStatsTabCompleter implements TabCompleter {
|
|||
private static final List<String> TIME_RANGES = Arrays.asList("hour", "day", "week", "month", "all");
|
||||
private static final List<String> GRAPH_OPTIONS = List.of("largegraph");
|
||||
|
||||
public GStatsTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
public class OthersHistory {
|
||||
public OthersHistory() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (!player.hasPermission("grimmsserver.stats.other")) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class SelfHistory {
|
||||
public SelfHistory() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (!player.hasPermission("grimmsserver.stats.self")) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetPlayerStat implements CommandExecutor {
|
||||
public SetPlayerStat() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class Broadcast {
|
||||
public Broadcast() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class Capability {
|
||||
public Capability() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (!player.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -1,167 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.CustomEnchantmentHandler;
|
||||
import org.gsdistance.grimmsServer.Data.CustomEnchantment;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Enchant {
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
// Guard: Permission Check
|
||||
if (!player.hasPermission("grimmsserver.util.admin")) {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Guard: Minimum arguments requirement
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String action = args[1].toLowerCase();
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
|
||||
if (item == null || item.getType().isAir()) {
|
||||
player.sendMessage(ChatColor.RED + "You must hold an item in your main hand.");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case "add" -> {
|
||||
if (args.length < 4) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gutil enchant add <enchantment> [level]");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[2].toUpperCase());
|
||||
int level = args.length >= 4 ? Integer.parseInt(args[3]) : 1;
|
||||
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
if (handler.addEnchantment(enchantment, level)) {
|
||||
player.sendMessage(ChatColor.GREEN + "Added " + ChatColor.GOLD + enchantment.enchantmentName +
|
||||
ChatColor.GREEN + " level " + ChatColor.YELLOW + level + ChatColor.GREEN + " to " + item.getType());
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Failed to add enchantment. Check if level exceeds maximum or enchantment already exists.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid level: " + args[3]);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid enchantment: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
case "remove" -> {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gutil enchant remove <enchantment>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[2].toUpperCase());
|
||||
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
if (handler.removeEnchantment(enchantment)) {
|
||||
player.sendMessage(ChatColor.GREEN + "Removed " + ChatColor.GOLD + enchantment.enchantmentName + ChatColor.GREEN + " from " + item.getType());
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Item does not have that enchantment.");
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid enchantment: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
case "set" -> {
|
||||
if (args.length < 4) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gutil enchant set <enchantment> <level>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[2].toUpperCase());
|
||||
int level = Integer.parseInt(args[3]);
|
||||
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
if (handler.setEnchantmentLevel(enchantment, level)) {
|
||||
player.sendMessage(ChatColor.GREEN + "Set " + ChatColor.GOLD + enchantment.enchantmentName +
|
||||
ChatColor.GREEN + " to level " + ChatColor.YELLOW + level + ChatColor.GREEN + " on " + item.getType());
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Failed to set enchantment level. Check if level is valid.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid level: " + args[3]);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid enchantment: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
case "list" -> {
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
Map<CustomEnchantment, Integer> enchantments = handler.getAllEnchantments();
|
||||
|
||||
if (enchantments.isEmpty()) {
|
||||
player.sendMessage(ChatColor.GRAY + "Item has no custom enchantments.");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "Custom Enchantments on " + item.getType() + ":");
|
||||
for (Map.Entry<CustomEnchantment, Integer> entry : enchantments.entrySet()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "- " + entry.getKey().enchantmentName +
|
||||
ChatColor.GRAY + " (Level " + entry.getValue() + "/" + entry.getKey().maxLevel + ")");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case "clear" -> {
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
handler.clearAllEnchantments();
|
||||
player.sendMessage(ChatColor.GREEN + "Cleared all custom enchantments from " + item.getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
case "has" -> {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gutil enchant has <enchantment>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[2].toUpperCase());
|
||||
CustomEnchantmentHandler handler = CustomEnchantmentHandler.getHandler(item);
|
||||
|
||||
if (handler.hasEnchantment(enchantment)) {
|
||||
int level = handler.getEnchantmentLevel(enchantment);
|
||||
player.sendMessage(ChatColor.GREEN + "Item has " + ChatColor.GOLD + enchantment.enchantmentName +
|
||||
ChatColor.GREEN + " at level " + ChatColor.YELLOW + level);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Item does not have " + enchantment.enchantmentName);
|
||||
}
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid enchantment: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
default -> {
|
||||
player.sendMessage(ChatColor.RED + "Unknown enchant command: " + action);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class Enderchest {
|
||||
public Enderchest() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Fly {
|
||||
public Fly() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
@ -13,55 +14,27 @@ public class Fly {
|
|||
return false;
|
||||
}
|
||||
|
||||
Player targetPlayer;
|
||||
int stateIndex;
|
||||
|
||||
if (args.length >= 2) {
|
||||
Player potentialTarget = Bukkit.getPlayer(args[1]);
|
||||
if (potentialTarget != null) {
|
||||
targetPlayer = potentialTarget;
|
||||
stateIndex = 2;
|
||||
} else {
|
||||
if (sender instanceof Player player) {
|
||||
targetPlayer = player;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command on yourself.");
|
||||
return false;
|
||||
}
|
||||
stateIndex = 1;
|
||||
}
|
||||
} else {
|
||||
if (sender instanceof Player player) {
|
||||
targetPlayer = player;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
stateIndex = 1;
|
||||
}
|
||||
|
||||
boolean enable;
|
||||
if (args.length > stateIndex) {
|
||||
switch (args[stateIndex].toLowerCase()) {
|
||||
case "on", "true" -> enable = true;
|
||||
case "off", "false" -> enable = false;
|
||||
default -> {
|
||||
enable = !targetPlayer.getAllowFlight();
|
||||
} else {
|
||||
boolean enable;
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "on", "true" -> enable = true;
|
||||
case "off", "false" -> enable = false;
|
||||
default -> {
|
||||
enable = !player.getAllowFlight();
|
||||
}
|
||||
}
|
||||
|
||||
player.setAllowFlight(enable);
|
||||
player.setFlying(enable);
|
||||
player.sendMessage(ChatColor.GREEN + "Fly mode " + (enable ? "enabled" : "disabled") + ".");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
enable = !targetPlayer.getAllowFlight();
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
targetPlayer.setAllowFlight(enable);
|
||||
targetPlayer.setFlying(enable);
|
||||
|
||||
if (targetPlayer == sender) {
|
||||
targetPlayer.sendMessage(ChatColor.GREEN + "Fly mode " + (enable ? "enabled" : "disabled") + ".");
|
||||
} else {
|
||||
targetPlayer.sendMessage(ChatColor.GREEN + "Fly mode " + (enable ? "enabled" : "disabled") + " by " + sender.getName() + ".");
|
||||
sender.sendMessage(ChatColor.GREEN + "Fly mode " + (enable ? "enabled" : "disabled") + " for " + targetPlayer.getName() + ".");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GUtilBaseCommand implements CommandExecutor {
|
||||
public GUtilBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length < 1) {
|
||||
|
|
@ -22,18 +24,6 @@ public class GUtilBaseCommand implements CommandExecutor {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
case "enchant" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return Enchant.subCommand(player, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "givecustomitem" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return GiveCustomItem.subCommand(player, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "capability" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return Capability.subCommand(player, args);
|
||||
|
|
@ -97,33 +87,6 @@ public class GUtilBaseCommand implements CommandExecutor {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
case "addtitle" -> {
|
||||
return AddTitle.subCommand(sender, args);
|
||||
}
|
||||
case "removetitle" -> {
|
||||
return RemoveTitle.subCommand(sender, args);
|
||||
}
|
||||
case "unlevelentity" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return UnlevelEntity.subCommand(player, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "levelentity" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return LevelEntity.subCommand(player, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "spawnchampion" -> {
|
||||
if (sender instanceof Player player) {
|
||||
return SpawnChampion.subCommand(player, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "sudo" -> {
|
||||
return Sudo.subCommand(sender, args);
|
||||
}
|
||||
default -> {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,15 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.CustomItemRegistry;
|
||||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
import org.gsdistance.grimmsServer.Data.CustomEnchantment;
|
||||
import org.gsdistance.grimmsServer.Data.Player.PlayerInventoryData;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerTitles;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -23,44 +17,9 @@ import java.util.stream.Stream;
|
|||
|
||||
public class GUtilTabCompleter implements TabCompleter {
|
||||
public static final List<String> defSubCommands = List.of("version", "setting", "spawn");
|
||||
public static final List<String> adminSubCommands = List.of("relic", "enchant", "givecustomitem", "capability", "broadcast", "inventoryrestore", "fly", "god", "heal", "speed", "enderchest", "invsee", "addtitle", "removetitle", "unlevelentity", "sudo", "levelentity", "spawnchampion");
|
||||
public static final List<String> adminSubCommands = List.of("relic", "capability", "broadcast", "inventoryrestore", "fly", "god", "heal", "speed", "enderchest", "invsee");
|
||||
|
||||
private CommandMap cachedCommandMap;
|
||||
|
||||
private CommandMap getCommandMap() {
|
||||
if (cachedCommandMap != null) {
|
||||
return cachedCommandMap;
|
||||
}
|
||||
try {
|
||||
Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
cachedCommandMap = (CommandMap) commandMapField.get(Bukkit.getServer());
|
||||
return cachedCommandMap;
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException("Failed to get command map", e);
|
||||
}
|
||||
}
|
||||
|
||||
private TabCompleter getTabCompleter(Command command) {
|
||||
try {
|
||||
Field tabCompleterField = command.getClass().getDeclaredField("tabCompleter");
|
||||
tabCompleterField.setAccessible(true);
|
||||
return (TabCompleter) tabCompleterField.get(command);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private java.util.Map<String, Command> getKnownCommands(CommandMap commandMap) {
|
||||
try {
|
||||
Field knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
|
||||
knownCommandsField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
java.util.Map<String, Command> knownCommands = (java.util.Map<String, Command>) knownCommandsField.get(commandMap);
|
||||
return knownCommands;
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
return new java.util.HashMap<>();
|
||||
}
|
||||
public GUtilTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
@ -79,93 +38,34 @@ public class GUtilTabCompleter implements TabCompleter {
|
|||
case "relic" -> {
|
||||
return List.of("make", "set", "recalc", "reroll");
|
||||
}
|
||||
case "enchant" -> {
|
||||
return List.of("add", "remove", "set", "list", "clear", "has");
|
||||
}
|
||||
case "givecustomitem" -> {
|
||||
return CustomItemRegistry.getRegisteredItemIds().stream()
|
||||
.filter(id -> id.startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "version" -> {
|
||||
return List.of("check", "update");
|
||||
}
|
||||
case "setting" -> {
|
||||
return PlayerMetadata.getPlayerMetadata(player).settings.stream().toList();
|
||||
}
|
||||
case "inventoryrestore", "heal", "spawn", "enderchest", "invsee", "addtitle", "removetitle", "sudo",
|
||||
"fly", "god" -> {
|
||||
case "inventoryrestore", "heal", "spawn", "enderchest", "invsee" -> {
|
||||
return Bukkit.getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "fly", "god" -> {
|
||||
return Stream.of("on", "off", "true", "false")
|
||||
.filter(option -> option.startsWith(args[1].toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
case "speed" -> {
|
||||
return Stream.of("walk", "fly")
|
||||
.filter(type -> type.startsWith(args[1].toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
case "levelentity", "unlevelentity" -> {
|
||||
return player.getWorld().getEntities().stream()
|
||||
.map(entity -> entity.getUniqueId().toString())
|
||||
.filter(uuid -> uuid.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "spawnchampion" -> {
|
||||
return java.util.Arrays.stream(org.bukkit.entity.EntityType.values())
|
||||
.filter(type -> type.isSpawnable() && type.isAlive())
|
||||
.map(type -> type.name().toLowerCase())
|
||||
.filter(name -> name.startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
} else if (args.length > 3 && args[0].equalsIgnoreCase("sudo")) {
|
||||
// Handle nested tab completion for sudo command
|
||||
String commandName = args[2];
|
||||
org.bukkit.command.Command targetCommand = getCommandMap().getCommand(commandName);
|
||||
if (targetCommand != null) {
|
||||
TabCompleter tabCompleter = getTabCompleter(targetCommand);
|
||||
if (tabCompleter != null) {
|
||||
// Build the args array for the target command
|
||||
String[] targetArgs = new String[args.length - 3];
|
||||
System.arraycopy(args, 3, targetArgs, 0, targetArgs.length);
|
||||
return tabCompleter.onTabComplete(sender, targetCommand, commandName, targetArgs);
|
||||
}
|
||||
}
|
||||
return List.of();
|
||||
} else if (args.length == 3) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "enchant" -> {
|
||||
if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove") ||
|
||||
args[1].equalsIgnoreCase("set") || args[1].equalsIgnoreCase("has")) {
|
||||
return java.util.Arrays.stream(CustomEnchantment.values())
|
||||
.map(enchant -> enchant.name().toLowerCase())
|
||||
.filter(name -> name.startsWith(args[2].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
case "givecustomitem" -> {
|
||||
return java.util.Arrays.stream(Material.values())
|
||||
.map(material -> material.name().toLowerCase())
|
||||
.filter(name -> name.startsWith(args[2].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "relic" -> {
|
||||
if (args[1].equalsIgnoreCase("set")) {
|
||||
List<String> tiers = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
tiers.add(String.valueOf(i));
|
||||
}
|
||||
return tiers.stream()
|
||||
.filter(tier -> tier.startsWith(args[2]))
|
||||
.toList();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
case "speed" -> {
|
||||
List<String> speeds = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
|
|
@ -189,112 +89,6 @@ public class GUtilTabCompleter implements TabCompleter {
|
|||
}
|
||||
return List.of();
|
||||
}
|
||||
case "addtitle" -> {
|
||||
// Ensure dynamic titles are populated
|
||||
PlayerTitles.populateDynamicTitles();
|
||||
return PlayerTitles.titles.keySet().stream()
|
||||
.filter(title -> title.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "removetitle" -> {
|
||||
Player targetPlayer = Bukkit.getPlayer(args[1]);
|
||||
if (targetPlayer != null) {
|
||||
return PlayerTitles.getPlayerTitles(targetPlayer).getTitles().stream()
|
||||
.filter(title -> title.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
case "sudo" -> {
|
||||
return getKnownCommands(getCommandMap()).keySet().stream()
|
||||
.filter(cmd -> cmd.startsWith(args[2].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case "fly", "god" -> {
|
||||
return Stream.of("on", "off", "true", "false")
|
||||
.filter(option -> option.startsWith(args[2].toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
case "spawnchampion" -> {
|
||||
List<String> tiers = new ArrayList<>();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
tiers.add(String.valueOf(i));
|
||||
}
|
||||
return tiers.stream()
|
||||
.filter(tier -> tier.startsWith(args[2]))
|
||||
.toList();
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
} else if (args.length == 4) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "enchant" -> {
|
||||
if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("set")) {
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[2].toUpperCase());
|
||||
List<String> levels = new ArrayList<>();
|
||||
for (int i = 1; i <= enchantment.maxLevel; i++) {
|
||||
levels.add(String.valueOf(i));
|
||||
}
|
||||
return levels.stream()
|
||||
.filter(level -> level.startsWith(args[3]))
|
||||
.collect(Collectors.toList());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
case "relic" -> {
|
||||
if (args[1].equalsIgnoreCase("set")) {
|
||||
List<String> grades = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
grades.add(String.valueOf(i));
|
||||
}
|
||||
return grades.stream()
|
||||
.filter(grade -> grade.startsWith(args[3]))
|
||||
.toList();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
case "spawnchampion" -> {
|
||||
List<String> levels = new ArrayList<>();
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
levels.add(String.valueOf(i));
|
||||
}
|
||||
return levels.stream()
|
||||
.filter(level -> level.startsWith(args[3]))
|
||||
.toList();
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
} else if (args.length == 5) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "spawnchampion" -> {
|
||||
List<String> prestiges = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
prestiges.add(String.valueOf(i));
|
||||
}
|
||||
return prestiges.stream()
|
||||
.filter(prestige -> prestige.startsWith(args[4]))
|
||||
.toList();
|
||||
}
|
||||
case "relic" -> {
|
||||
if (args[1].equalsIgnoreCase("set")) {
|
||||
List<String> resistances = new ArrayList<>();
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
resistances.add(String.valueOf(i));
|
||||
}
|
||||
return resistances.stream()
|
||||
.filter(res -> res.startsWith(args[4]))
|
||||
.toList();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
default -> {
|
||||
return List.of();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.CustomItemHandler;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.CustomItemRegistry;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.ItemStats;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class GiveCustomItem {
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (!player.hasPermission("grimmsserver.util.admin")) {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /gutil givecustomitem <item_id> [material]");
|
||||
return false;
|
||||
}
|
||||
|
||||
String itemId = args[1].toLowerCase();
|
||||
|
||||
// Check if the custom item is registered
|
||||
if (!CustomItemRegistry.isCustomItemRegistered(itemId)) {
|
||||
player.sendMessage(ChatColor.RED + "Custom item '" + itemId + "' is not registered.");
|
||||
player.sendMessage(ChatColor.GRAY + "Available custom items:");
|
||||
Set<String> registeredItems = CustomItemRegistry.getRegisteredItemIds();
|
||||
for (String registeredItem : registeredItems) {
|
||||
player.sendMessage(ChatColor.YELLOW + "- " + registeredItem);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine material (default to iron_hoe for guns, or stone for other items)
|
||||
Material material = Material.IRON_HOE; // Default for guns
|
||||
if (args.length >= 3) {
|
||||
try {
|
||||
material = Material.valueOf(args[2].toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid material: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the custom item
|
||||
ItemStack itemStack = new ItemStack(material);
|
||||
try {
|
||||
// Ensure the ItemStack has ItemMeta (required for NBT operations)
|
||||
if (itemStack.getItemMeta() == null) {
|
||||
itemStack.setItemMeta(org.bukkit.Bukkit.getItemFactory().getItemMeta(material));
|
||||
}
|
||||
|
||||
// Initialize the item with CustomItemHandler first
|
||||
CustomItemHandler.createHandler(itemStack);
|
||||
|
||||
CustomItemRegistry.createCustomItem(itemId, itemStack);
|
||||
|
||||
// Update item stats to show proper display name and description
|
||||
ItemStats.getItemStats(itemStack).UpdateItemStats();
|
||||
|
||||
// Give item to player
|
||||
player.getInventory().addItem(itemStack);
|
||||
player.sendMessage(ChatColor.GREEN + "Given custom item: " + ChatColor.GOLD + itemId);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(ChatColor.RED + "Failed to create custom item: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class God {
|
||||
public God() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
@ -13,54 +14,26 @@ public class God {
|
|||
return false;
|
||||
}
|
||||
|
||||
Player targetPlayer;
|
||||
int stateIndex;
|
||||
|
||||
if (args.length >= 2) {
|
||||
Player potentialTarget = Bukkit.getPlayer(args[1]);
|
||||
if (potentialTarget != null) {
|
||||
targetPlayer = potentialTarget;
|
||||
stateIndex = 2;
|
||||
} else {
|
||||
if (sender instanceof Player player) {
|
||||
targetPlayer = player;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command on yourself.");
|
||||
return false;
|
||||
}
|
||||
stateIndex = 1;
|
||||
}
|
||||
} else {
|
||||
if (sender instanceof Player player) {
|
||||
targetPlayer = player;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
stateIndex = 1;
|
||||
}
|
||||
|
||||
boolean enable;
|
||||
if (args.length > stateIndex) {
|
||||
switch (args[stateIndex].toLowerCase()) {
|
||||
case "on", "true" -> enable = true;
|
||||
case "off", "false" -> enable = false;
|
||||
default -> {
|
||||
enable = !targetPlayer.isInvulnerable();
|
||||
} else {
|
||||
boolean enable;
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "on", "true" -> enable = true;
|
||||
case "off", "false" -> enable = false;
|
||||
default -> {
|
||||
enable = player.isInvulnerable();
|
||||
}
|
||||
}
|
||||
|
||||
player.setInvulnerable(enable);
|
||||
player.sendMessage(ChatColor.GREEN + "God mode " + (enable ? "enabled" : "disabled") + ".");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
enable = !targetPlayer.isInvulnerable();
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
targetPlayer.setInvulnerable(enable);
|
||||
|
||||
if (targetPlayer == sender) {
|
||||
targetPlayer.sendMessage(ChatColor.GREEN + "God mode " + (enable ? "enabled" : "disabled") + ".");
|
||||
} else {
|
||||
targetPlayer.sendMessage(ChatColor.GREEN + "God mode " + (enable ? "enabled" : "disabled") + " by " + sender.getName() + ".");
|
||||
sender.sendMessage(ChatColor.GREEN + "God mode " + (enable ? "enabled" : "disabled") + " for " + targetPlayer.getName() + ".");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Heal {
|
||||
public Heal() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import java.util.Map;
|
|||
|
||||
public class InventoryRestore {
|
||||
|
||||
public InventoryRestore() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (!player.hasPermission("grimmsserver.util.admin")) {
|
||||
player.sendMessage("You do not have permission to use this command.");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class Invsee {
|
||||
public Invsee() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityMetadata;
|
||||
import org.gsdistance.grimmsServer.Manage.CustomEntityManager;
|
||||
|
||||
public class LevelEntity {
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof Player player) {
|
||||
// Parse optional level and prestige parameters
|
||||
Integer specifiedLevel = null;
|
||||
Integer specifiedPrestige = null;
|
||||
|
||||
if (args.length >= 3) {
|
||||
try {
|
||||
specifiedLevel = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid level: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (args.length >= 4) {
|
||||
try {
|
||||
specifiedPrestige = Integer.parseInt(args[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid prestige: " + args[3]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
// Force leveling on entity player is looking at
|
||||
RayTraceResult rayTrace = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), 5);
|
||||
Entity targetEntity = rayTrace != null ? rayTrace.getHitEntity() : null;
|
||||
if (targetEntity == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No entity found in range (5 blocks). Specify an entity UUID or look at an entity.");
|
||||
return false;
|
||||
}
|
||||
return applyLeveling(sender, targetEntity, specifiedLevel, specifiedPrestige);
|
||||
} else {
|
||||
// Force leveling by UUID
|
||||
try {
|
||||
java.util.UUID uuid = java.util.UUID.fromString(args[1]);
|
||||
Entity targetEntity = null;
|
||||
for (Entity entity : player.getWorld().getEntities()) {
|
||||
if (entity.getUniqueId().equals(uuid)) {
|
||||
targetEntity = entity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetEntity == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Entity with UUID " + args[1] + " not found in current world.");
|
||||
return false;
|
||||
}
|
||||
return applyLeveling(sender, targetEntity, specifiedLevel, specifiedPrestige);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid UUID format: " + args[1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applyLeveling(CommandSender sender, Entity entity, Integer specifiedLevel, Integer specifiedPrestige) {
|
||||
// Register entity in the registry
|
||||
CustomEntityManager.registerEntity(entity);
|
||||
|
||||
// Get or create metadata and apply leveling
|
||||
EntityMetadata metadata = EntityMetadata.getEntityMetadata(entity);
|
||||
|
||||
// Override level/prestige if specified
|
||||
if (specifiedLevel != null) {
|
||||
metadata.level = specifiedLevel;
|
||||
}
|
||||
if (specifiedPrestige != null) {
|
||||
metadata.prestige = specifiedPrestige;
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
// Force re-apply leveling even if already leveled
|
||||
try {
|
||||
java.lang.reflect.Method applyLevelling = EntityMetadata.class.getDeclaredMethod("applyLevelling", LivingEntity.class, EntityMetadata.class);
|
||||
applyLevelling.setAccessible(true);
|
||||
applyLevelling.invoke(null, livingEntity, metadata);
|
||||
// Save attribute values after applying
|
||||
java.lang.reflect.Method saveAttributeValues = EntityMetadata.class.getDeclaredMethod("saveAttributeValues", LivingEntity.class, EntityMetadata.class);
|
||||
saveAttributeValues.setAccessible(true);
|
||||
saveAttributeValues.invoke(null, livingEntity, metadata);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Warning: Could not re-apply leveling via reflection.");
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Forced leveling on entity: " + entity.getType().name() + " (Level: " + metadata.level + ", Prestige: " + metadata.prestige + ")");
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Entity registered but not a LivingEntity (no leveling applied).");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,9 @@ import org.gsdistance.grimmsServer.Constructable.Item.RelicHandler;
|
|||
|
||||
public class Relic {
|
||||
|
||||
public Relic() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
// Guard: Permission Check
|
||||
if (!player.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class Setting {
|
||||
public Setting() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Spawn {
|
||||
public Spawn() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -1,167 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.gsdistance.grimmsServer.Constructable.Data;
|
||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityAbility;
|
||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityAffix;
|
||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityMetadata;
|
||||
import org.gsdistance.grimmsServer.Manage.CustomEntityManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnChampion {
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /gutil spawnchampion <entity_type> [tier] [level] [prestige]");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Example: /gutil spawnchampion ZOMBIE 3 50 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse entity type
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(args[1].toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid entity type: " + args[1]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!entityType.isSpawnable() || !entityType.isAlive()) {
|
||||
sender.sendMessage(ChatColor.RED + "Entity type must be a living spawnable entity.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse optional parameters
|
||||
int tier = 1;
|
||||
int level = 1;
|
||||
int prestige = 1;
|
||||
|
||||
if (args.length >= 3) {
|
||||
try {
|
||||
tier = Integer.parseInt(args[2]);
|
||||
if (tier < 1 || tier > 5) {
|
||||
sender.sendMessage(ChatColor.RED + "Tier must be between 1 and 5.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid tier: " + args[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length >= 4) {
|
||||
try {
|
||||
level = Integer.parseInt(args[3]);
|
||||
if (level < 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Level must be at least 1.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid level: " + args[3]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length >= 5) {
|
||||
try {
|
||||
prestige = Integer.parseInt(args[4]);
|
||||
if (prestige < 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Prestige must be at least 1.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid prestige: " + args[4]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn the entity
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), entityType);
|
||||
|
||||
// Set a temporary tag to prevent EntitySpawnEvent from processing this entity
|
||||
entity.setMetadata("champion_spawn", new org.bukkit.metadata.FixedMetadataValue(org.gsdistance.grimmsServer.GrimmsServer.instance, true));
|
||||
|
||||
// Register entity
|
||||
CustomEntityManager.registerEntity(entity);
|
||||
|
||||
// Create metadata manually to bypass automatic leveling
|
||||
EntityMetadata metadata = new EntityMetadata(entity);
|
||||
|
||||
// Clear any affixes/abilities that the constructor might have set
|
||||
metadata.affixes.clear();
|
||||
metadata.abilities.clear();
|
||||
|
||||
// Override champion tier, level, and prestige
|
||||
metadata.championTier = tier;
|
||||
metadata.level = level;
|
||||
metadata.prestige = prestige;
|
||||
|
||||
// Store in session data to prevent recreation
|
||||
org.gsdistance.grimmsServer.Data.PerSessionDataStorage.dataStore.put("entityMetadata-" + entity.getUniqueId(), Data.of(metadata, EntityMetadata.class));
|
||||
|
||||
// Select affixes based on tier
|
||||
int numAffixes = Math.min(tier, org.gsdistance.grimmsServer.Constructable.Entity.EntityAffixes.affixes.size());
|
||||
List<EntityAffix> availableAffixes = new ArrayList<>(org.gsdistance.grimmsServer.Constructable.Entity.EntityAffixes.affixes.keySet());
|
||||
Collections.shuffle(availableAffixes);
|
||||
|
||||
for (int i = 0; i < numAffixes; i++) {
|
||||
metadata.affixes.add(availableAffixes.get(i));
|
||||
}
|
||||
|
||||
// Select abilities based on tier
|
||||
metadata.abilities.clear();
|
||||
int numAbilities = Math.max(0, tier - 1);
|
||||
if (numAbilities > 0) {
|
||||
List<EntityAbility> availableAbilities = new ArrayList<>(org.gsdistance.grimmsServer.Constructable.Entity.EntityAbilities.abilities.keySet());
|
||||
Collections.shuffle(availableAbilities);
|
||||
|
||||
for (int i = 0; i < Math.min(numAbilities, availableAbilities.size()); i++) {
|
||||
metadata.abilities.add(availableAbilities.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// Apply leveling and champion effects
|
||||
try {
|
||||
// Use applyAttributeModifiers directly to avoid recalculation of level/prestige
|
||||
java.lang.reflect.Method applyAttributeModifiers = EntityMetadata.class.getDeclaredMethod("applyAttributeModifiers", LivingEntity.class, EntityMetadata.class);
|
||||
applyAttributeModifiers.setAccessible(true);
|
||||
applyAttributeModifiers.invoke(null, entity, metadata);
|
||||
|
||||
java.lang.reflect.Method saveAttributeValues = EntityMetadata.class.getDeclaredMethod("saveAttributeValues", LivingEntity.class, EntityMetadata.class);
|
||||
saveAttributeValues.setAccessible(true);
|
||||
saveAttributeValues.invoke(null, entity, metadata);
|
||||
|
||||
java.lang.reflect.Method applyChampionAffixes = EntityMetadata.class.getDeclaredMethod("applyChampionAffixes", LivingEntity.class, EntityMetadata.class);
|
||||
applyChampionAffixes.setAccessible(true);
|
||||
applyChampionAffixes.invoke(null, entity, metadata);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Warning: Could not apply effects via reflection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Save metadata
|
||||
metadata.saveToFile();
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Spawned champion " + entityType.name() + " (Tier: " + tier + ", Level: " + level + ", Prestige: " + prestige + ")");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Affixes: " + metadata.affixes.size() + ", Abilities: " + metadata.abilities.size());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Speed {
|
||||
public Speed() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Sudo {
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /gutil sudo <player> <command>");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player '" + args[1] + "' not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
StringBuilder commandBuilder = new StringBuilder();
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
commandBuilder.append(args[i]);
|
||||
if (i < args.length - 1) {
|
||||
commandBuilder.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
String command = commandBuilder.toString();
|
||||
|
||||
try {
|
||||
boolean success = target.performCommand(command);
|
||||
if (success) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Made " + target.getName() + " execute: /" + command);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to make " + target.getName() + " execute: /" + command);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error executing command: " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.gsdistance.grimmsServer.Constructable.Entity.EntityMetadata;
|
||||
import org.gsdistance.grimmsServer.Manage.CustomEntityManager;
|
||||
|
||||
public class UnlevelEntity {
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("grimmsserver.util.admin")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length < 2) {
|
||||
// Remove leveling from entity player is looking at
|
||||
RayTraceResult rayTrace = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), 5);
|
||||
Entity targetEntity = rayTrace != null ? rayTrace.getHitEntity() : null;
|
||||
if (targetEntity == null) {
|
||||
sender.sendMessage(ChatColor.RED + "No entity found in range (5 blocks). Specify an entity UUID or look at an entity.");
|
||||
return false;
|
||||
}
|
||||
return removeLeveling(sender, targetEntity);
|
||||
} else {
|
||||
// Remove leveling by UUID
|
||||
try {
|
||||
java.util.UUID uuid = java.util.UUID.fromString(args[1]);
|
||||
Entity targetEntity = null;
|
||||
for (Entity entity : player.getWorld().getEntities()) {
|
||||
if (entity.getUniqueId().equals(uuid)) {
|
||||
targetEntity = entity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetEntity == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Entity with UUID " + args[1] + " not found in current world.");
|
||||
return false;
|
||||
}
|
||||
return removeLeveling(sender, targetEntity);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid UUID format: " + args[1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean removeLeveling(CommandSender sender, Entity entity) {
|
||||
// Remove from registry
|
||||
CustomEntityManager.unregisterEntity(entity);
|
||||
|
||||
// Remove metadata file
|
||||
try {
|
||||
java.io.File metadataFile = new java.io.File(
|
||||
org.gsdistance.grimmsServer.GrimmsServer.instance.getDataFolder(),
|
||||
"entityMetadata/" + entity.getUniqueId() + ".json"
|
||||
);
|
||||
if (metadataFile.exists()) {
|
||||
metadataFile.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Warning: Could not delete metadata file.");
|
||||
}
|
||||
|
||||
// Remove from session storage
|
||||
org.gsdistance.grimmsServer.Data.PerSessionDataStorage.dataStore.remove("entityMetadata-" + entity.getUniqueId());
|
||||
|
||||
// Reset entity stats if it's a living entity
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
// Reset attributes to default values
|
||||
if (livingEntity.getAttribute(Attribute.MAX_HEALTH) != null) {
|
||||
livingEntity.getAttribute(Attribute.MAX_HEALTH).setBaseValue(livingEntity.getAttribute(Attribute.MAX_HEALTH).getDefaultValue());
|
||||
livingEntity.setHealth(livingEntity.getAttribute(Attribute.MAX_HEALTH).getValue());
|
||||
}
|
||||
if (livingEntity.getAttribute(Attribute.ARMOR) != null) {
|
||||
livingEntity.getAttribute(Attribute.ARMOR).setBaseValue(livingEntity.getAttribute(Attribute.ARMOR).getDefaultValue());
|
||||
}
|
||||
if (livingEntity.getAttribute(Attribute.ARMOR_TOUGHNESS) != null) {
|
||||
livingEntity.getAttribute(Attribute.ARMOR_TOUGHNESS).setBaseValue(livingEntity.getAttribute(Attribute.ARMOR_TOUGHNESS).getDefaultValue());
|
||||
}
|
||||
if (livingEntity.getAttribute(Attribute.ATTACK_DAMAGE) != null) {
|
||||
livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(livingEntity.getAttribute(Attribute.ATTACK_DAMAGE).getDefaultValue());
|
||||
}
|
||||
|
||||
// Reset custom name
|
||||
EntityMetadata metadata = EntityMetadata.getEntityMetadata(entity);
|
||||
if (metadata != null && metadata.originalName != null) {
|
||||
livingEntity.setCustomName(metadata.originalName);
|
||||
} else {
|
||||
livingEntity.setCustomName(null);
|
||||
}
|
||||
livingEntity.setCustomNameVisible(false);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Removed leveling from entity: " + entity.getType().name() + " (" + entity.getUniqueId() + ")");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,30 +3,13 @@ package org.gsdistance.grimmsServer.Commands.GUtilCommand;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.gsdistance.grimmsServer.GrimmsServer;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class Version {
|
||||
|
||||
private static String cachedBuildVersion = null;
|
||||
|
||||
private static String getBuildVersion() {
|
||||
if (cachedBuildVersion == null) {
|
||||
try (InputStream is = GrimmsServer.instance.getResource("build.v")) {
|
||||
if (is != null) {
|
||||
cachedBuildVersion = new String(is.readAllBytes()).trim();
|
||||
} else {
|
||||
cachedBuildVersion = "unknown";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cachedBuildVersion = "error";
|
||||
}
|
||||
}
|
||||
return cachedBuildVersion;
|
||||
public Version() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(CommandSender sender, String[] args) {
|
||||
String name = GrimmsServer.instance.getDescription().getPrefix();
|
||||
sender.sendMessage(name + " v" + GrimmsServer.instance.getDescription().getVersion() + " (build " + getBuildVersion() + ")");
|
||||
String var10001 = GrimmsServer.instance.getDescription().getPrefix();
|
||||
sender.sendMessage(var10001 + " GMSv" + GrimmsServer.instance.getDescription().getVersion());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DelHome {
|
||||
public DelHome() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(Player player, @NotNull String[] args) {
|
||||
String homeName = "home";
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HomeBaseCommand implements CommandExecutor {
|
||||
public HomeBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import java.util.List;
|
|||
public class HomeTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("sethome", "tp", "homes", "delhome");
|
||||
|
||||
public HomeTabCompleter() {
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> result = new ArrayList();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import org.bukkit.entity.Player;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class Homes {
|
||||
public Homes() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(Player player, String[] args) {
|
||||
PlayerMetadata meta = PlayerMetadata.getPlayerMetadata(player);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class Sethome {
|
||||
public Sethome() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(Player player, String[] args) {
|
||||
String homeName = "home";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.gsdistance.grimmsServer.Constructable.Location;
|
|||
import org.gsdistance.grimmsServer.Constructable.Player.PlayerMetadata;
|
||||
|
||||
public class TpHome {
|
||||
public TpHome() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(Player player, String[] args) {
|
||||
String homeName = "home";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class BuyEdu {
|
||||
public BuyEdu() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
|
|
|||
|
|
@ -7,18 +7,23 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JobBaseCommand implements CommandExecutor {
|
||||
public JobBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "log" -> Log.subCommand(player, args);
|
||||
case "take" -> Take.subCommand(player, args);
|
||||
case "buyedu" -> BuyEdu.subCommand(player);
|
||||
default -> false;
|
||||
};
|
||||
boolean var10000;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "log" -> var10000 = Log.subCommand(player, args);
|
||||
case "take" -> var10000 = Take.subCommand(player, args);
|
||||
case "buyedu" -> var10000 = BuyEdu.subCommand(player);
|
||||
default -> var10000 = false;
|
||||
}
|
||||
|
||||
return var10000;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("Only players can use this command.");
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import java.util.List;
|
|||
public class JobTabCompleter implements TabCompleter {
|
||||
private static final List<String> SUBCOMMANDS = Arrays.asList("log", "take", "buyedu");
|
||||
|
||||
public JobTabCompleter() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
|||
|
||||
public class Log {
|
||||
|
||||
public Log() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Data.JobTitlesBaseValues;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class Take {
|
||||
public Take() {
|
||||
}
|
||||
|
||||
public static boolean subCommand(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import org.gsdistance.grimmsServer.Constructable.Market;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class Buy {
|
||||
public Buy() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
package org.gsdistance.grimmsServer.Commands.MarketComand;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.CustomEnchantmentHandler;
|
||||
import org.gsdistance.grimmsServer.Constructable.Item.ItemLevelHandler;
|
||||
import org.gsdistance.grimmsServer.Data.CustomEnchantment;
|
||||
import org.gsdistance.grimmsServer.Data.Market.EnchantBaseValues;
|
||||
import org.gsdistance.grimmsServer.Shared;
|
||||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class BuyCustomEnchantment {
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /market customenchant <enchantment>");
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
CustomEnchantment enchantment = CustomEnchantment.valueOf(args[1].toUpperCase());
|
||||
if (EnchantBaseValues.customEnchantBaseValues.containsKey(enchantment)) {
|
||||
ItemStack itemToApply = player.getInventory().getItemInMainHand();
|
||||
if (itemToApply.getAmount() > 1) {
|
||||
sender.sendMessage(ChatColor.RED + "You can only enchant one item at a time. Please unstack the item first.");
|
||||
return false;
|
||||
}
|
||||
|
||||
CustomEnchantmentHandler enchantHandler = CustomEnchantmentHandler.getHandler(itemToApply);
|
||||
int currentLevel = enchantHandler.getEnchantmentLevel(enchantment);
|
||||
|
||||
ItemLevelHandler itemLevelHandler = ItemLevelHandler.getLevelHandler(itemToApply, player.getPlayer());
|
||||
double itemLevel = itemLevelHandler.getLevel();
|
||||
|
||||
// Respect the hard max level from CustomEnchantment
|
||||
if (currentLevel >= enchantment.maxLevel || Math.sqrt(itemLevel) / 2 < currentLevel + 1) {
|
||||
sender.sendMessage(ChatColor.RED + "Enchantment already at maximum level (" + enchantment.maxLevel + ").");
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerStats playerStats = PlayerStats.getPlayerStats(player);
|
||||
|
||||
// Simple cost calculation based on current level
|
||||
double cost = EnchantBaseValues.customEnchantBaseValues.get(enchantment) * (currentLevel + 1);
|
||||
|
||||
if (playerStats.getStat("money", Double.class) < cost) {
|
||||
sender.sendMessage(ChatColor.RED + "Not enough money. Cost: " + ChatColor.GOLD + Shared.formatNumber(cost));
|
||||
return false;
|
||||
} else {
|
||||
int oldLevel = currentLevel;
|
||||
int newLevel = oldLevel + 1;
|
||||
|
||||
if (enchantHandler.setEnchantmentLevel(enchantment, newLevel)) {
|
||||
playerStats.setStat("money", playerStats.getStat("money", Double.class) - cost);
|
||||
sender.sendMessage(ChatColor.GREEN + "Upgraded the custom enchantment " + ChatColor.GOLD + enchantment.enchantmentName +
|
||||
ChatColor.GREEN + " from level " + ChatColor.YELLOW + oldLevel +
|
||||
ChatColor.GREEN + " to level " + ChatColor.YELLOW + newLevel +
|
||||
ChatColor.GREEN + " for " + ChatColor.GOLD + Shared.formatNumber(cost) + ChatColor.GREEN + " money.");
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to upgrade enchantment.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Custom enchantment not listed or nonexistent.");
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid custom enchantment: " + args[1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,8 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class BuyEnchantment {
|
||||
public BuyEnchantment() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class BuyPotionEffect {
|
||||
public BuyPotionEffect() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.gsdistance.grimmsServer.Data.Market.EnchantBaseValues;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class GetEnchantCosts {
|
||||
public GetEnchantCosts() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
sender.sendMessage("__Enchant costs:");
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Constructable.Market;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class GetMarket {
|
||||
public GetMarket() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
Market market = Market.getMarket();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ import org.gsdistance.grimmsServer.Constructable.Market;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class Info {
|
||||
|
||||
public Info() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean subCommand(Player player) {
|
||||
Market market = Market.getMarket();
|
||||
|
||||
|
|
@ -17,7 +22,9 @@ public class Info {
|
|||
|
||||
player.sendMessage("Total item count: " + Shared.formatNumber(totalItemCount));
|
||||
|
||||
player.sendMessage("Total value: " + Shared.formatNumber(market.totalValue));
|
||||
double totalValue = Math.pow(market.NegMarketSaturation, 4);
|
||||
|
||||
player.sendMessage("Total value: " + Shared.formatNumber(totalValue));
|
||||
player.sendMessage("Unique item count: " + market.items.size());
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MarketBaseCommand implements CommandExecutor {
|
||||
public MarketBaseCommand() {
|
||||
}
|
||||
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (args.length == 0) {
|
||||
|
|
@ -17,7 +19,6 @@ public class MarketBaseCommand implements CommandExecutor {
|
|||
case "stock" -> Stock.SubCommand(sender, args);
|
||||
case "ripoff" -> Ripoff.SubCommand(sender, args);
|
||||
case "enchant" -> BuyEnchantment.SubCommand(sender, args);
|
||||
case "customenchant" -> BuyCustomEnchantment.SubCommand(sender, args);
|
||||
case "potioneffect" -> BuyPotionEffect.SubCommand(sender, args);
|
||||
case "tp" -> Tp.SubCommand(sender, args);
|
||||
case "sell" -> Sell.SubCommand(sender, args);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.bukkit.command.TabCompleter;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.gsdistance.grimmsServer.Constructable.Market;
|
||||
import org.gsdistance.grimmsServer.Data.CustomEnchantment;
|
||||
import org.gsdistance.grimmsServer.Data.Market.EnchantBaseValues;
|
||||
import org.gsdistance.grimmsServer.Data.Market.MarketBaseValues;
|
||||
import org.gsdistance.grimmsServer.Data.Market.PotionEffectBaseValues;
|
||||
|
|
@ -19,6 +18,8 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class MarketTabCompleter implements TabCompleter {
|
||||
public MarketTabCompleter() {
|
||||
}
|
||||
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
|
@ -27,7 +28,6 @@ public class MarketTabCompleter implements TabCompleter {
|
|||
subs.add("stock");
|
||||
subs.add("ripoff");
|
||||
subs.add("enchant");
|
||||
subs.add("customenchant");
|
||||
subs.add("potioneffect");
|
||||
subs.add("tp");
|
||||
subs.add("buy");
|
||||
|
|
@ -47,8 +47,6 @@ public class MarketTabCompleter implements TabCompleter {
|
|||
yield MarketBaseValues.marketBaseValues.keySet().stream().map(Material::name).filter((name) -> name.toLowerCase().startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
case "enchant":
|
||||
yield EnchantBaseValues.enchantBaseValues.keySet().stream().map((enchantment) -> enchantment.getKey().getKey()).map(Object::toString).filter((name) -> name.toLowerCase().startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
case "customenchant":
|
||||
yield EnchantBaseValues.customEnchantBaseValues.keySet().stream().map(CustomEnchantment::name).map(String::toLowerCase).filter((name) -> name.startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
case "potioneffect":
|
||||
yield PotionEffectBaseValues.potionEffectBaseValues.keySet().stream().map(PotionEffectType::getName).filter((name) -> name.toLowerCase().startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
case "tp":
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class OpenGUI {
|
||||
public OpenGUI() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import org.gsdistance.grimmsServer.Shared;
|
|||
import org.gsdistance.grimmsServer.Stats.PlayerStats;
|
||||
|
||||
public class Ripoff {
|
||||
public Ripoff() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import org.gsdistance.grimmsServer.Constructable.Market;
|
|||
import org.gsdistance.grimmsServer.Shared;
|
||||
|
||||
public class Sell {
|
||||
public Sell() {
|
||||
}
|
||||
|
||||
public static boolean SubCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue