From 3809f47a5453959b52153ebdf2f34f91f512e868 Mon Sep 17 00:00:00 2001 From: benwoo1110 <30431861+benwoo1110@users.noreply.github.com> Date: Fri, 18 Dec 2020 18:53:56 +0800 Subject: [PATCH] Merge the 2 gamerule command class. --- .../commands_acf/GameRuleCommand.java | 43 +++++++++++++-- .../commands_acf/GamerulesCommand.java | 53 ------------------- .../commands_helper/MVCommandManager.java | 4 -- 3 files changed, 38 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/com/onarandombox/MultiverseCore/commands_acf/GamerulesCommand.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GameRuleCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GameRuleCommand.java index 1d9333fe..9d0a7fa4 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GameRuleCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GameRuleCommand.java @@ -4,9 +4,12 @@ import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Flags; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.api.MultiverseWorld; +import org.bukkit.ChatColor; import org.bukkit.GameRule; import org.bukkit.World; import org.bukkit.command.CommandSender; @@ -19,21 +22,51 @@ public class GameRuleCommand extends MultiverseCommand { super(plugin); } + //TODO: Should it be `gamerule list` instead? + @Subcommand("gamerules") + @CommandPermission("multiverse.core.gamerule.list") + @Syntax("[world]") + @CommandCompletion("@MVWorlds") + @Description("See the list gamerules values for a given world.") + public void onGameRulesCommand(@NotNull CommandSender sender, + @NotNull @Flags("other,defaultself") MultiverseWorld world) { + + World CBWorld = world.getCBWorld(); + StringBuilder gameRules = new StringBuilder(); + + for (String gameRule : CBWorld.getGameRules()) { + if (gameRules.length() != 0) { + gameRules.append(ChatColor.WHITE).append(", "); + } + gameRules.append(ChatColor.AQUA) + .append(gameRule) + .append(ChatColor.WHITE) + .append(": ") + .append(ChatColor.GREEN) + .append(CBWorld.getGameRuleValue(GameRule.getByName(gameRule))); + } + + sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ==="); + sender.sendMessage(gameRules.toString()); + } + + //TODO: Should it be `gamerule set` instead? @Subcommand("gamerule") @CommandPermission("multiverse.core.gamerule.set") @Syntax(" [world]") @CommandCompletion("@gameRules") @Description("Allows a player to set a gamerule for a given world.") - public void onGameRuleCommand(@NotNull CommandSender sender, - @NotNull GameRule gameRule, - //TODO: Need to validate value. - @NotNull String value, - @NotNull World world) { + public void onGameRuleChangeCommand(@NotNull CommandSender sender, + @NotNull GameRule gameRule, + //TODO: Need to validate value. + @NotNull String value, + @NotNull World world) { //TODO: Set actual gameRule. sender.sendMessage(gameRule.getName()); sender.sendMessage(gameRule.getType().getName()); sender.sendMessage(value); sender.sendMessage(world.getName()); + sender.sendMessage("Gamerule setting isnt done yet."); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GamerulesCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GamerulesCommand.java deleted file mode 100644 index 2485af6d..00000000 --- a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GamerulesCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.onarandombox.MultiverseCore.commands_acf; - -import co.aikar.commands.annotation.CommandAlias; -import co.aikar.commands.annotation.CommandCompletion; -import co.aikar.commands.annotation.CommandPermission; -import co.aikar.commands.annotation.Description; -import co.aikar.commands.annotation.Flags; -import co.aikar.commands.annotation.Subcommand; -import co.aikar.commands.annotation.Syntax; -import com.onarandombox.MultiverseCore.MultiverseCore; -import com.onarandombox.MultiverseCore.api.MultiverseWorld; -import org.bukkit.ChatColor; -import org.bukkit.GameRule; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.jetbrains.annotations.NotNull; - -@CommandAlias("mv") -public class GamerulesCommand extends MultiverseCommand { - - public GamerulesCommand(MultiverseCore plugin) { - super(plugin); - } - - //TODO: should it be `gamerule list` instead? - @Subcommand("gamerules") - @CommandPermission("multiverse.core.gamerule.list") - @Syntax("[world]") - @CommandCompletion("@MVWorlds") - @Description("See the list gamerules values for a given world.") - public void onGameRulesCommand(@NotNull CommandSender sender, - @NotNull @Flags("other,defaultself") MultiverseWorld world) { - - - World CBWorld = world.getCBWorld(); - StringBuilder gameRules = new StringBuilder(); - - for (String gameRule : CBWorld.getGameRules()) { - if (gameRules.length() != 0) { - gameRules.append(ChatColor.WHITE).append(", "); - } - gameRules.append(ChatColor.AQUA) - .append(gameRule) - .append(ChatColor.WHITE) - .append(": ") - .append(ChatColor.GREEN) - .append(CBWorld.getGameRuleValue(GameRule.getByName(gameRule))); - } - - sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ==="); - sender.sendMessage(gameRules.toString()); - } -} diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands_helper/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commands_helper/MVCommandManager.java index ba4de08a..734692fc 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands_helper/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands_helper/MVCommandManager.java @@ -19,7 +19,6 @@ import com.onarandombox.MultiverseCore.commands_acf.CreateCommand; import com.onarandombox.MultiverseCore.commands_acf.DebugCommand; import com.onarandombox.MultiverseCore.commands_acf.DeleteCommand; import com.onarandombox.MultiverseCore.commands_acf.GameRuleCommand; -import com.onarandombox.MultiverseCore.commands_acf.GamerulesCommand; import com.onarandombox.MultiverseCore.commands_acf.GeneratorCommand; import com.onarandombox.MultiverseCore.commands_acf.ImportCommand; import com.onarandombox.MultiverseCore.commands_acf.InfoCommand; @@ -82,9 +81,6 @@ public class MVCommandManager extends PaperCommandManager { registerCommand(new CloneCommand(plugin)); registerCommand(new ImportCommand(plugin)); registerCommand(new CheckCommand(plugin)); - - //TODO: Can combine both gamerules class into one. - registerCommand(new GamerulesCommand(plugin)); registerCommand(new GameRuleCommand(plugin)); }