From 15ff88fe6fdd0bf82a4e677e8cbb2f7ddec122bb Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 24 Aug 2021 17:10:01 +0200 Subject: [PATCH] Fix CustomCommandListener Signed-off-by: yoyosource --- .../bausystem/features/script/CustomCommandListener.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomCommandListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomCommandListener.java index c484d4da..31601335 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomCommandListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomCommandListener.java @@ -267,6 +267,15 @@ public class CustomCommandListener implements Listener { return; } MenuCommand menuCommand = new MenuCommand(bookMeta.getPages(), s.substring(6).split(" ")); + for (CustomCommand customCommand : playerMap.computeIfAbsent(p, player -> new ArrayList<>())) { + if (!(customCommand instanceof MenuCommand)) { + continue; + } + if (Arrays.equals(((MenuCommand) customCommand).args, menuCommand.args)) { + p.sendMessage("§cCommand '" + (String.join(" ", menuCommand.args)) + "' bereits definiert"); + return; + } + } playerMap.computeIfAbsent(p, player -> new ArrayList<>()).add(menuCommand); if (!save(p)) { playerMap.get(p).removeIf(customCommand -> customCommand == menuCommand);