From 51b4b25094d866b658aae69fd7b8c60bc8ef7cba Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Tue, 3 Jul 2018 01:27:35 +0200 Subject: [PATCH] Remove set/remove class commands. Similar to a88556771f0d64955656c770c783f884277e485b. This specific change may stir the pot a bit, since some people may rely on the set command. However, class chests solve a lot of the problems that the initial command set out to tackle, and we can probably do better in a rewrite of the command if it's missed anyway. The removed commands render a few methods in ArenaMaster obsolete. --- .../MobArena/commands/CommandHandler.java | 4 -- .../commands/setup/RemoveClassCommand.java | 36 ----------- .../commands/setup/SetClassCommand.java | 60 ------------------- 3 files changed, 100 deletions(-) delete mode 100644 src/main/java/com/garbagemule/MobArena/commands/setup/RemoveClassCommand.java delete mode 100644 src/main/java/com/garbagemule/MobArena/commands/setup/SetClassCommand.java diff --git a/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java b/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java index 33224a6..8d50ad5 100644 --- a/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java +++ b/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java @@ -17,11 +17,9 @@ import com.garbagemule.MobArena.commands.setup.ConfigCommand; import com.garbagemule.MobArena.commands.setup.EditArenaCommand; import com.garbagemule.MobArena.commands.setup.ListClassesCommand; import com.garbagemule.MobArena.commands.setup.RemoveArenaCommand; -import com.garbagemule.MobArena.commands.setup.RemoveClassCommand; import com.garbagemule.MobArena.commands.setup.RemoveContainerCommand; import com.garbagemule.MobArena.commands.setup.RemoveLeaderboardCommand; import com.garbagemule.MobArena.commands.setup.RemoveSpawnpointCommand; -import com.garbagemule.MobArena.commands.setup.SetClassCommand; import com.garbagemule.MobArena.commands.setup.SettingCommand; import com.garbagemule.MobArena.commands.setup.SetupCommand; import com.garbagemule.MobArena.commands.user.ArenaListCommand; @@ -238,8 +236,6 @@ public class CommandHandler implements CommandExecutor register(RemoveContainerCommand.class); register(ListClassesCommand.class); - register(SetClassCommand.class); - register(RemoveClassCommand.class); register(ClassChestCommand.class); register(RemoveLeaderboardCommand.class); diff --git a/src/main/java/com/garbagemule/MobArena/commands/setup/RemoveClassCommand.java b/src/main/java/com/garbagemule/MobArena/commands/setup/RemoveClassCommand.java deleted file mode 100644 index f998ba2..0000000 --- a/src/main/java/com/garbagemule/MobArena/commands/setup/RemoveClassCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.garbagemule.MobArena.commands.setup; - -import com.garbagemule.MobArena.ArenaClass; -import com.garbagemule.MobArena.commands.Command; -import com.garbagemule.MobArena.commands.CommandInfo; -import com.garbagemule.MobArena.framework.ArenaMaster; -import com.garbagemule.MobArena.util.TextUtils; -import org.bukkit.command.CommandSender; - -@CommandInfo( - name = "removeclass", - pattern = "(del(.)*|r(e)?m(ove)?)class", - usage = "/ma removeclass ", - desc = "remove the given class", - permission = "mobarena.setup.classes" -) -public class RemoveClassCommand implements Command -{ - @Override - public boolean execute(ArenaMaster am, CommandSender sender, String... args) { - // Require a class name - if (args.length != 1) return false; - - // Find the class - ArenaClass arenaClass = am.getClasses().get(args[0]); - String className = TextUtils.camelCase(args[0]); - if (arenaClass == null) { - am.getGlobalMessenger().tell(sender, "The class '" + className + "' does not exist."); - return true; - } - - am.removeClassNode(className); - am.getGlobalMessenger().tell(sender, "Removed class '" + className + "'."); - return true; - } -} diff --git a/src/main/java/com/garbagemule/MobArena/commands/setup/SetClassCommand.java b/src/main/java/com/garbagemule/MobArena/commands/setup/SetClassCommand.java deleted file mode 100644 index 7216b01..0000000 --- a/src/main/java/com/garbagemule/MobArena/commands/setup/SetClassCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.garbagemule.MobArena.commands.setup; - -import com.garbagemule.MobArena.ArenaClass; -import com.garbagemule.MobArena.Msg; -import com.garbagemule.MobArena.commands.Command; -import com.garbagemule.MobArena.commands.CommandInfo; -import com.garbagemule.MobArena.commands.Commands; -import com.garbagemule.MobArena.framework.ArenaMaster; -import com.garbagemule.MobArena.util.TextUtils; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandInfo( - name = "setclass", - pattern = "setclass|saveclass", - usage = "/ma setclass (safe) ", - desc = "save your inventory as a class", - permission = "mobarena.setup.classes" -) -public class SetClassCommand implements Command -{ - @Override - public boolean execute(ArenaMaster am, CommandSender sender, String... args) { - if (!Commands.isPlayer(sender)) { - am.getGlobalMessenger().tell(sender, Msg.MISC_NOT_FROM_CONSOLE); - return true; - } - - // Require at least a class name - if (args.length < 1) return false; - - // Grab the argument, if any. - String arg1 = (args.length > 0 ? args[0] : ""); - String arg2 = (args.length > 1 ? args[1] : ""); - - // Unwrap the sender. - Player p = Commands.unwrap(sender); - - // Check if we're overwriting. - boolean safe = arg1.equals("safe"); - if (safe && arg2.equals("")) return false; - - // If so, use arg2, otherwise, use arg1 - String className = TextUtils.camelCase(safe ? arg2 : arg1); - - // Create the class. - ArenaClass arenaClass = am.createClassNode(className, p.getInventory(), safe); - - // If the class is null, it was not created. - if (arenaClass == null) { - am.getGlobalMessenger().tell(p, "That class already exists!"); - am.getGlobalMessenger().tell(p, "To overwrite, omit the 'safe' parameter."); - return true; - } - - // Otherwise, yay! - am.getGlobalMessenger().tell(p, "Class '" + className + "' set with your current inventory."); - return true; - } -}