summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authort00thpick1 <t00thpick1dirko@gmail.com>2014-02-21 21:44:54 -0500
committerEvilSeph <evilseph@gmail.com>2014-03-22 16:45:34 -0400
commite6be37d9e39145183e47490b9d92e783ad14fb17 (patch)
tree2e6ffe1d266342547f15026b5bfd680d8fbf2307 /src
parent71a5f8b83508e8d74323001285f9ab799423f8c8 (diff)
downloadbukkit-e6be37d9e39145183e47490b9d92e783ad14fb17.tar
bukkit-e6be37d9e39145183e47490b9d92e783ad14fb17.tar.gz
bukkit-e6be37d9e39145183e47490b9d92e783ad14fb17.tar.lz
bukkit-e6be37d9e39145183e47490b9d92e783ad14fb17.tar.xz
bukkit-e6be37d9e39145183e47490b9d92e783ad14fb17.zip
[Bleeding] Add direct addresses for command aliases.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/command/SimpleCommandMap.java14
1 files changed, 9 insertions, 5 deletions
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<String> 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