diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-28 00:52:43 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-28 00:52:43 +0000 |
commit | a27b2703dd3d55178c3a258b062575de5f5c695e (patch) | |
tree | d145d19b36c9a3ef207ef68059816bbc76aa83b1 /src/main/java | |
parent | 2d7d0d9bdd3ab6643833b0aa4f3ea1caeea7efed (diff) | |
download | bukkit-a27b2703dd3d55178c3a258b062575de5f5c695e.tar bukkit-a27b2703dd3d55178c3a258b062575de5f5c695e.tar.gz bukkit-a27b2703dd3d55178c3a258b062575de5f5c695e.tar.lz bukkit-a27b2703dd3d55178c3a258b062575de5f5c695e.tar.xz bukkit-a27b2703dd3d55178c3a258b062575de5f5c695e.zip |
Case-insensitive commands
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/command/SimpleCommandMap.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index a24bc061..b21c55c5 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -53,11 +53,13 @@ public final class SimpleCommandMap implements CommandMap { * {@inheritDoc} */ public boolean register(String name, String fallbackPrefix, Command command) { - boolean nameInUse = (knownCommands.get(name) != null); - if (nameInUse) + boolean nameInUse = (getCommand(name) != null); + + if (nameInUse) { name = fallbackPrefix + ":" + name; + } - knownCommands.put(name, command); + knownCommands.put(name.toLowerCase(), command); return !nameInUse; } @@ -70,7 +72,7 @@ public final class SimpleCommandMap implements CommandMap { args = Arrays.copyOfRange(args, 1, args.length); - Command target = knownCommands.get(sentCommandLabel); + Command target = getCommand(sentCommandLabel); boolean isRegisteredCommand = (target != null); if (isRegisteredCommand) { try { @@ -92,7 +94,7 @@ public final class SimpleCommandMap implements CommandMap { } public Command getCommand(String name) { - return knownCommands.get(name); + return knownCommands.get(name.toLowerCase()); } private static class VersionCommand extends Command { |