From 91c64fa26be251b3fcaab5bd5d862359f3e46f96 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 2 Feb 2022 15:43:16 +0100 Subject: [PATCH] Update ScriptCommand Signed-off-by: yoyosource --- .../features/script/ScriptCommand.java | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java index b2fff250..73be66fb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java @@ -49,20 +49,14 @@ public class ScriptCommand extends SWCommand { @Register(description = "SCRIPT_COMMAND_HELP") public void menuCommand(Player p) { if (swItems.isEmpty()) { - for (int i = 0; i < 3; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } + addEmptyItems(3); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_COMMANDS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_", 1, 13), false, clickType -> { }), null)); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_EVENTS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_", 1, 20, loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_", 1, 2)), false, clickType -> { }), null)); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_OTHER", p), loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_", 1, 9), false, clickType -> { }), null)); - for (int i = 0; i < 3; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } + addEmptyItems(3); List specialCommands = new ArrayList<>(SPECIAL_COMMANDS); specialCommands.sort(Comparator.comparing(specialCommand -> specialCommand.getClass().getTypeName())); specialCommands.forEach(specialCommand -> { @@ -95,16 +89,10 @@ public class ScriptCommand extends SWCommand { }); swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand)); }); - for (int i = 0; i < 3 + 45; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } + addEmptyItems(3 + 45); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_VARIABLES", p), new ArrayList<>(), false, clickType -> { }), null)); - for (int i = 0; i < 4; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } + addEmptyItems(4); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TRACE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TRACE_LORE", p)), false, clickType -> { }), null)); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE", p)), false, clickType -> { @@ -145,10 +133,7 @@ public class ScriptCommand extends SWCommand { }), null)); swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.MAP, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE", p)), false, clickType -> { }), null)); - for (int i = 0; i < 2 * 9 - 2; i++) { - swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { - }), null)); - } + addEmptyItems(2 * 9 - 2); } SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> { @@ -167,6 +152,13 @@ public class ScriptCommand extends SWCommand { swListInv.open(); } + private void addEmptyItems(int count) { + for (int i = 0; i < count; i++) { + swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { + }), null)); + } + } + @Register(value = "menu", description = "SCRIPT_COMMAND_HELP_MENU") public void menuGUICommand(Player p) { customScriptManager.openCommandsMenu(p);