From 091049c43deaecde2c3ca5bee6e4a0bf6cdfe86a Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 4 May 2017 23:52:09 -0400 Subject: [PATCH] add a warning for subcommand conflict --- src/main/java/co/aikar/commands/RootCommand.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/co/aikar/commands/RootCommand.java b/src/main/java/co/aikar/commands/RootCommand.java index 7cb3aac4..4e91aac2 100644 --- a/src/main/java/co/aikar/commands/RootCommand.java +++ b/src/main/java/co/aikar/commands/RootCommand.java @@ -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); } }