From 7cd8d40e1198caacc3c8d092ba7a7806763740df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 18 Sep 2023 16:36:33 +0200 Subject: [PATCH] Add /loader speed and /loader wait Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 5 +++++ BauSystem_Main/src/BauSystem_de.properties | 5 +++++ .../bausystem/features/loader/Loader.java | 19 +++++++++++++++++++ .../features/loader/LoaderCommand.java | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index a1e09c4e..453c01f7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -567,12 +567,17 @@ LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded ac LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback +LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots +LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader. LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader LOADER_ACTIVE=§7The Loader is now active. LOADER_STOP=§7The Loader has been stopped. LOADER_PAUSED=§7The Loader is now paused. +LOADER_SMALL_TIME=§cThe wait time is too small +LOADER_NEW_TIME=§7The wait time is now: {0} +LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0} LOADER_PERMS=§cYou are not allowed to use the Loader here LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet! diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index bfa45f06..547e1083 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -535,12 +535,17 @@ LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Akt LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen LOADER_HELP_GUI=§8/§7loader settings §8- §7Zeigt die Einstellungen an LOADER_HELP_STOP=§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen +LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen +LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen LOADER_NO_LOADER=§cDu hast noch keinen Loader. Erstelle dir einen mit /loader setup LOADER_NEW=§7Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren. LOADER_HOW_TO_START=§7Führe dann /§eloader start§7 um den Loader zu starten LOADER_ACTIVE=§7Der Loader ist nun aktiviert. LOADER_STOP=§7Der Loader ist nun gestoppt. LOADER_PAUSED=§7Der Loader ist nun pausiert. +LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein +LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0} +LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0} LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen! diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index b50d3c08..22e0df02 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -124,6 +124,25 @@ public class Loader implements Listener { LOADER_MAP.remove(p); } + public boolean setTicksBetweenShots(int delay) { + if (elements.size() == 0) return false; + LoaderElement loaderElement = elements.get(elements.size() - 1); + if (loaderElement instanceof LoaderWait) { + ((LoaderWait) loaderElement).setDelay(delay); + return true; + } + return false; + } + + public void setTicksBetweenBlocks(int delay) { + for (int i = 0; i < elements.size() - 1; i++) { + LoaderElement loaderElement = elements.get(i); + if (loaderElement instanceof LoaderWait) { + ((LoaderWait) loaderElement).setDelay(delay); + } + } + } + public void gui(SettingsSorting settingsSorting) { List> list = new ArrayList<>(); AtomicBoolean allWait = new AtomicBoolean(true); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index 7ced38b8..b065c3d2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -83,6 +83,25 @@ public class LoaderCommand extends SWCommand { loader.gui(Loader.SettingsSorting.ALL); } + @Register(value = "wait", description = "LOADER_HELP_WAIT") + public void shotDelayLoader(@Validator Player p, @Min(intValue = 1) @ErrorMessage("LOADER_SMALL_TIME") int delay) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) return; + if (loader.setTicksBetweenShots(delay)) { + BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay); + } else { + BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); + } + } + + @Register(value = "speed", description = "LOADER_HELP_SPEED") + public void speedLoader(@Validator Player p, @Min(intValue = 0) @ErrorMessage("LOADER_SMALL_TIME") int delay) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) return; + BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay); + loader.setTicksBetweenBlocks(delay); + } + @ClassValidator(value = Player.class, local = true) public TypeValidator loaderValidator() { return (commandSender, player, messageSender) -> {