Skip to content

Commit

Permalink
Make commands case insensitive.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
garbagemule committed Dec 31, 2018
1 parent 74a7388 commit 7bc6cf2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/garbagemule/MobArena/ArenaListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -1264,15 +1264,15 @@ 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)) {
return;
}

// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 7bc6cf2

Please sign in to comment.