From 4108ddc917255d0be3976b6f7c37c8c56237e5fb Mon Sep 17 00:00:00 2001 From: filoghost Date: Sat, 1 Nov 2014 11:40:21 +0100 Subject: [PATCH] Warning about multiple menus using the same command. --- .../com/gmail/filoghost/chestcommands/ChestCommands.java | 3 +++ .../filoghost/chestcommands/internal/ExtendedIconMenu.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/ChestCommands/src/com/gmail/filoghost/chestcommands/ChestCommands.java b/ChestCommands/src/com/gmail/filoghost/chestcommands/ChestCommands.java index 008067c..9895232 100644 --- a/ChestCommands/src/com/gmail/filoghost/chestcommands/ChestCommands.java +++ b/ChestCommands/src/com/gmail/filoghost/chestcommands/ChestCommands.java @@ -201,6 +201,9 @@ public class ChestCommands extends JavaPlugin { if (data.hasCommands()) { for (String command : data.getCommands()) { if (!command.isEmpty()) { + if (commandsToMenuMap.containsKey(command)) { + errorLogger.addError("The menus \"" + commandsToMenuMap.get(command).getFileName() + "\" and \"" + menuConfig.getFileName() + "\" have the same command \"" + command + "\". Only one will be opened."); + } commandsToMenuMap.put(command, iconMenu); } } diff --git a/ChestCommands/src/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java b/ChestCommands/src/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java index b8cf114..7f91a36 100644 --- a/ChestCommands/src/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java +++ b/ChestCommands/src/com/gmail/filoghost/chestcommands/internal/ExtendedIconMenu.java @@ -11,11 +11,13 @@ import com.gmail.filoghost.chestcommands.internal.icon.IconCommand; public class ExtendedIconMenu extends IconMenu { + private String fileName; private String permission; private List openActions; public ExtendedIconMenu(String title, int rows, String fileName) { super(title, rows); + this.fileName = fileName; this.permission = Permissions.OPEN_MENU_BASE + fileName; } @@ -31,6 +33,10 @@ public class ExtendedIconMenu extends IconMenu { return permission; } + public String getFileName() { + return fileName; + } + @Override public void open(Player player) { if (openActions != null) {