[Bleeding] Fixed a StackOverflowError with command alias handling for Help. Addresses BUKKIT-1253

Dieser Commit ist enthalten in:
zml2008 2012-03-20 19:12:14 -07:00 committet von EvilSeph
Ursprung 8aee4c3f56
Commit 31b1bc02ca
2 geänderte Dateien mit 13 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.help; package org.bukkit.craftbukkit.help;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.help.HelpMap; import org.bukkit.help.HelpMap;
@ -14,6 +15,7 @@ public class CommandAliasHelpTopic extends HelpTopic {
this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor; this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor;
this.helpMap = helpMap; this.helpMap = helpMap;
this.name = alias.startsWith("/") ? alias : "/" + alias; this.name = alias.startsWith("/") ? alias : "/" + alias;
Validate.isTrue(!this.name.equals(this.aliasFor), "Command " + this.name + " cannot be alias for itself");
this.shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor; this.shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor;
} }

Datei anzeigen

@ -119,7 +119,9 @@ public class SimpleHelpMap implements HelpMap {
continue; continue;
} }
for (String alias : command.getAliases()) { for (String alias : command.getAliases()) {
addTopic(new CommandAliasHelpTopic(alias, command.getLabel(), this)); if (!helpTopics.containsKey("/" + alias)) {
addTopic(new CommandAliasHelpTopic("/" + alias, "/" + command.getLabel(), this));
}
} }
} }