add a warning for subcommand conflict

This commit is contained in:
Aikar
2017-05-04 23:52:09 -04:00
parent 3cf6d8f239
commit 091049c43d
@@ -24,6 +24,7 @@
package co.aikar.commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -76,7 +77,15 @@ public class RootCommand extends Command {
if (this.defCommand == null || command.subCommands.get("__default") != null) {
this.defCommand = command;
}
command.subCommands.keySet().forEach(key -> this.subCommands.put(key, command));
command.subCommands.keySet().forEach(key -> {
BaseCommand regged = this.subCommands.get(key);
if (regged != null) {
ACFLog.severe("ACF Error: " + command.getLabel() + " registered subcommand " + key + " - but it is already defined in " + regged.getLabel());
ACFLog.severe("2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this.");
return;
}
this.subCommands.put(key, command);
});
this.children.add(command);
}
}