mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
add a warning for subcommand conflict
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user