From e6be37d9e39145183e47490b9d92e783ad14fb17 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Fri, 21 Feb 2014 21:44:54 -0500 Subject: [Bleeding] Add direct addresses for command aliases. --- src/main/java/org/bukkit/command/SimpleCommandMap.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java index 8681987f..d75380c8 100644 --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -102,12 +102,11 @@ public class SimpleCommandMap implements CommandMap { public boolean register(String label, String fallbackPrefix, Command command) { label = label.toLowerCase().trim(); fallbackPrefix = fallbackPrefix.toLowerCase().trim(); - boolean registered = register(label, command, false); - knownCommands.put(fallbackPrefix + ":" + label, command); + boolean registered = register(label, command, false, fallbackPrefix); Iterator iterator = command.getAliases().iterator(); while (iterator.hasNext()) { - if (!register(iterator.next(), command, true)) { + if (!register(iterator.next(), command, true, fallbackPrefix)) { iterator.remove(); } } @@ -124,13 +123,18 @@ public class SimpleCommandMap implements CommandMap { } /** - * Registers a command with the given name is possible. + * Registers a command with the given name is possible. Also uses + * fallbackPrefix to create a unique name. * * @param label the name of the command, without the '/'-prefix. * @param command the command to register + * @param isAlias whether the command is an alias + * @param fallbackPrefix a prefix which is prepended to the command for a + * unique address * @return true if command was registered, false otherwise. */ - private synchronized boolean register(String label, Command command, boolean isAlias) { + private synchronized boolean register(String label, Command command, boolean isAlias, String fallbackPrefix) { + knownCommands.put(fallbackPrefix + ":" + label, command); if ((command instanceof VanillaCommand || isAlias) && knownCommands.containsKey(label)) { // Request is for an alias/fallback command and it conflicts with // a existing command or previous alias ignore it -- cgit v1.2.3