From 7bc6cf2800b209325b538e92ff6163818dab3b35 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Mon, 31 Dec 2018 14:47:05 +0100 Subject: [PATCH] Make commands case insensitive. Note that this doesn't make the arguments for commands case insensitive. Each command is still responsible for lowercasing their arguments if it makes sense for them to do so. This closes #446. --- changelog.md | 1 + src/main/java/com/garbagemule/MobArena/ArenaListener.java | 4 ++-- .../com/garbagemule/MobArena/commands/CommandHandler.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 3168f6dd..29825135 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ These changes will (most likely) be included in the next version. - Spectators can no longer take damage when the arena isn't running. - Pets can now teleport back to their owners if they get too far away. - Enchantment names are now case insensitive (i.e. `FIRE_PROTECTION` is the same as `fire_protection`). +- All commands are now case insensitive. This means that typing `/ma join` is the same as typing `/MA JOIN`. This should help reduce the confusion with commands like `/ma l` where the L can be confused with a 1 (one). ## [0.103] - 2018-08-28 - It is now possible to add a fixed delay (in seconds) between waves with the new per-arena setting `next-wave-delay`. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index 2909e284..e31af885 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -1264,7 +1264,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { } // This is safe, because commands will always have at least one element. - String base = event.getMessage().split(" ")[0]; + String base = event.getMessage().split(" ")[0].toLowerCase(); // Check if the entire base command is allowed. if (plugin.getArenaMaster().isAllowed(base)) { @@ -1272,7 +1272,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { } // If not, check if the specific command is allowed. - String noslash = event.getMessage().substring(1); + String noslash = event.getMessage().substring(1).toLowerCase(); if (plugin.getArenaMaster().isAllowed(noslash)) { return; } diff --git a/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java b/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java index e51c54c2..589e2a75 100644 --- a/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java +++ b/src/main/java/com/garbagemule/MobArena/commands/CommandHandler.java @@ -60,8 +60,8 @@ public CommandHandler(MobArena plugin) { @Override public boolean onCommand(CommandSender sender, org.bukkit.command.Command bcmd, String label, String[] args) { // Grab the base and arguments. - String base = (args.length > 0 ? args[0] : ""); - String last = (args.length > 0 ? args[args.length - 1] : ""); + String base = (args.length > 0 ? args[0] : "").toLowerCase(); + String last = (args.length > 0 ? args[args.length - 1] : "").toLowerCase(); // If the player is in a convo (Setup Mode), bail if (sender instanceof Conversable && ((Conversable) sender).isConversing()) {