From 792f16fadf0a4329250f6df6660e0eb36c0d5cec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 17:13:15 +0200 Subject: [PATCH] Update Loader Signed-off-by: yoyosource --- .../bausystem/features/loadern/Loader.java | 41 ++++++++++++++++--- .../features/loadern/LoaderCommand.java | 2 +- .../elements/LoaderInteractionElement.java | 1 - .../features/script/variables/Constants.java | 2 +- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java index d1eef52d..40c3f750 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -21,11 +21,15 @@ package de.steamwar.bausystem.features.loadern; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.bausystem.features.loadern.elements.impl.LoaderTNT; +import de.steamwar.bausystem.features.loadern.elements.impl.LoaderWait; import de.steamwar.bausystem.shared.EnumDisplay; +import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -109,14 +113,36 @@ public class Loader implements Listener { LOADER_MAP.remove(p); } - public void settings() { + public void settings(SettingsSorting settingsSorting) { List> list = new ArrayList<>(); for (LoaderElement element : elements) { + if (settingsSorting != null) { + if (settingsSorting == SettingsSorting.WAIT && !(element instanceof LoaderWait)) { + continue; + } + if (settingsSorting == SettingsSorting.INTERACTIONS && (element instanceof LoaderWait || element instanceof LoaderTNT)) { + continue; + } + } list.add(new SWListInv.SWListEntry<>(element.menu(p), element)); } - new SWListInv<>(p, "Loader Settings", false, list, (clickType, entry) -> { - entry.click(p, this::settings); - }).open(); + SWListInv swListInv = new SWListInv<>(p, "Loader Settings", false, list, (clickType, entry) -> { + entry.click(p, () -> settings(settingsSorting)); + }); + + SWItem onlyWaitElements = new SWItem(Material.CLOCK, "§eNur Warten", clickType -> { + settings(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); + }); + if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true); + swListInv.setItem(48, onlyWaitElements); + + SWItem onlyInteractionsElements = new SWItem(Material.TNT, "§eNur Interaktionen", clickType -> { + settings(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); + }); + if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); + swListInv.setItem(50, onlyInteractionsElements); + + swListInv.open(); } @EventHandler @@ -125,6 +151,11 @@ public class Loader implements Listener { stop(); } + public enum SettingsSorting { + WAIT, + INTERACTIONS, + } + @AllArgsConstructor public enum Stage implements EnumDisplay { SETUP("LOADER_SETUP"), @@ -133,6 +164,6 @@ public class Loader implements Listener { END("LOADER_END"); @Getter - private String chatValue; + private final String chatValue; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java index 6539d16a..b2d7a2b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java @@ -80,7 +80,7 @@ public class LoaderCommand extends SWCommand { public void settingsLoader(@Validator Player player) { Loader loader = Loader.getLoader(player); if (loaderNullCheck(loader, player)) return; - loader.settings(); + loader.settings(null); } @ClassValidator(value = Player.class, local = true) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java index 7785f07b..8397779a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.features.loadern.elements; -import de.steamwar.bausystem.features.loader.LoaderButton; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java index e0ec0872..10d4a75d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java @@ -1,7 +1,7 @@ package de.steamwar.bausystem.features.script.variables; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loader.Loader; +import de.steamwar.bausystem.features.loadern.Loader; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tracer.record.ActiveTracer;