From b4d63e1fe976dee36fafa66826a47e2e3fac07b3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 00:04:14 +0200 Subject: [PATCH 01/17] Add reworked Loader Signed-off-by: yoyosource --- .../features/loader/LoaderCommand.java | 2 +- .../bausystem/features/loadern/Loader.java | 130 ++++++++++++ .../features/loadern/LoaderCommand.java | 92 +++++++++ .../features/loadern/LoaderRecorder.java | 187 +++++++++++++++++ .../loadern/elements/ElementSettings.java | 31 +++ .../loadern/elements/LoaderElement.java | 29 +++ .../elements/LoaderInteractionElement.java | 116 +++++++++++ .../elements/impl/LoaderComparator.java | 135 +++++++++++++ .../elements/impl/LoaderDaylightDetector.java | 159 +++++++++++++++ .../loadern/elements/impl/LoaderLectern.java | 155 ++++++++++++++ .../loadern/elements/impl/LoaderLever.java | 132 ++++++++++++ .../elements/impl/LoaderNoteBlock.java | 115 +++++++++++ .../loadern/elements/impl/LoaderOpenable.java | 138 +++++++++++++ .../loadern/elements/impl/LoaderRepeater.java | 149 ++++++++++++++ .../loadern/elements/impl/LoaderTNT.java | 63 ++++++ .../loadern/elements/impl/LoaderTicks.java | 191 ++++++++++++++++++ .../loadern/elements/impl/LoaderWait.java | 88 ++++++++ 17 files changed, 1911 insertions(+), 1 deletion(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java 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 ffea7e4f..95fa92b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -26,7 +26,7 @@ import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked +// @Linked public class LoaderCommand extends SWCommand { public LoaderCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java new file mode 100644 index 00000000..01d56d04 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -0,0 +1,130 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.inventory.SWListInv; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Loader implements Listener { + + private static final Map LOADER_MAP = new HashMap<>(); + + public static Loader getLoader(Player player) { + return LOADER_MAP.get(player); + } + + public static void newLoader(Player player) { + LOADER_MAP.put(player, new Loader(player)); + } + + private final Player p; + + private Stage stage = Stage.SETUP; + private LoaderRecorder recorder; + + private List elements = new ArrayList<>(); + private int currentElement = 0; + + public Loader(Player p) { + this.p = p; + this.recorder = new LoaderRecorder(p, elements); + Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); + } + + private void next() { + currentElement++; + if (currentElement >= elements.size()) { + currentElement = 0; + } + if (stage == Stage.RUNNING) { + elements.get(currentElement).execute(this::next); + } + } + + public void start() { + if (stage == Stage.END) return; + if (stage == Stage.RUNNING) return; + stage = Stage.RUNNING; + if (recorder != null) { + recorder.stop(); + recorder = null; + } + if (elements.isEmpty()) { + p.sendMessage("§cEs wurden keine Elemente aufgenommen!"); + stop(); + return; + } + elements.get(currentElement).execute(this::next); + } + + public void pause() { + if (stage == Stage.END) return; + if (stage == Stage.PAUSE) return; + stage = Stage.PAUSE; + if (recorder != null) { + recorder.stop(); + recorder = null; + } + } + + public void stop() { + stage = Stage.END; + if (recorder != null) { + recorder.stop(); + recorder = null; + } + elements.clear(); + LOADER_MAP.remove(p); + } + + public void settings() { + List> list = new ArrayList<>(); + for (LoaderElement element : elements) { + list.add(new SWListInv.SWListEntry<>(element.menu(p), element)); + } + new SWListInv<>(p, "Loader Settings", false, list, (clickType, entry) -> { + entry.click(p, this::settings); + }).open(); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + if (event.getPlayer() != p) return; + stop(); + } + + public enum Stage { + SETUP, + RUNNING, + PAUSE, + END + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java new file mode 100644 index 00000000..6539d16a --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java @@ -0,0 +1,92 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +@Linked +public class LoaderCommand extends SWCommand { + + public LoaderCommand() { + super("loader"); + } + + private boolean loaderNullCheck(Loader loader, Player p) { + if (loader == null) { + BauSystem.MESSAGE.send("LOADER_NO_LOADER", p); + return true; + } + return false; + } + + @Register(value = "setup", description = "LOADER_HELP_SETUP") + public void setupLoader(@Validator Player player) { + if (Loader.getLoader(player) != null) { + player.sendMessage("Please stop the current loader first!"); + return; + } + Loader.newLoader(player); + BauSystem.MESSAGE.send("LOADER_NEW", player); + BauSystem.MESSAGE.send("LOADER_HOW_TO_START", player); + } + + @Register(value = "start", description = "LOADER_HELP_START") + public void startLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; + loader.start(); + BauSystem.MESSAGE.send("LOADER_ACTIVE", player); + } + + @Register(value = "stop", description = "LOADER_HELP_STOP") + public void stopLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; + loader.stop(); + BauSystem.MESSAGE.send("LOADER_STOP", player); + } + + @Register(value = "pause", description = "LOADER_HELP_PAUSE") + public void pauseLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; + loader.pause(); + BauSystem.MESSAGE.send("LOADER_PAUSED", player); + } + + @Register(value = "settings", description = "LOADER_HELP_PAUSE") + public void settingsLoader(@Validator Player player) { + Loader loader = Loader.getLoader(player); + if (loaderNullCheck(loader, player)) return; + loader.settings(); + } + + @ClassValidator(value = Player.class, local = true) + public TypeValidator loaderValidator() { + return (commandSender, player, messageSender) -> { + return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS"); + }; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java new file mode 100644 index 00000000..4bc9f071 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java @@ -0,0 +1,187 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +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.*; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.EquipmentSlot; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class LoaderRecorder implements Listener { + + private Player player; + private List loaderElementList; + private Set blockSet = new HashSet<>(); + private long lastInteraction = TPSUtils.currentTick.get(); + + public LoaderRecorder(Player player, List loaderElementList) { + this.player = player; + this.loaderElementList = loaderElementList; + Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); + } + + public void stop() { + addWaitTime(true); + HandlerList.unregisterAll(this); + player = null; + blockSet.clear(); + } + + private void addWaitTime(boolean last) { + if (loaderElementList.isEmpty()) { + lastInteraction = TPSUtils.currentTick.get(); + return; + } + if (loaderElementList.get(loaderElementList.size() - 1) instanceof LoaderWait) { + return; + } + long diff = TPSUtils.currentTick.get() - lastInteraction; + if (last && diff > 160) diff = 160; + lastInteraction = TPSUtils.currentTick.get(); + loaderElementList.add(new LoaderWait(diff)); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) { + if (event.getPlayer() != player) return; + if (event.getBlock().getType() != Material.TNT) return; + + addWaitTime(false); + loaderElementList.add(new LoaderTNT(event.getBlock().getLocation())); + } + + @EventHandler + public void onPlayerInteractEntity(PlayerInteractEvent event) { + if (event.getPlayer() != player) return; + if (player.isSneaking()) return; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return; + if (event.getClickedBlock().getType() == Material.OBSERVER) return; + if (event.getHand() == EquipmentSlot.OFF_HAND) return; + + addWaitTime(false); + Block block = event.getClickedBlock(); + Material type = block.getType(); + switch (type) { + case COMPARATOR: + loaderElementList.add(new LoaderComparator(block.getLocation())); + break; + case REPEATER: + loaderElementList.add(new LoaderRepeater(block.getLocation())); + break; + case NOTE_BLOCK: + loaderElementList.add(new LoaderNoteBlock(block.getLocation())); + break; + case LEVER: + loaderElementList.add(new LoaderLever(block.getLocation())); + break; + case DAYLIGHT_DETECTOR: + loaderElementList.add(new LoaderDaylightDetector(block.getLocation())); + break; + case LECTERN: + loaderElementList.add(new LoaderLectern(block.getLocation())); + break; + case IRON_TRAPDOOR: + break; + default: + if (type.name().endsWith("_TRAPDOOR")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "Trapdoor", type)); + } else if (type.name().endsWith("_DOOR")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "Door", type)); + } else if (type.name().endsWith("FENCE_GATE")) { + loaderElementList.add(new LoaderOpenable(block.getLocation(), "Fencegate", type)); + } else if (type.name().endsWith("STONE_BUTTON")) { + loaderElementList.add(new LoaderTicks(block.getLocation(), "Stone Button", type, 20)); + } else if (type.name().endsWith("BUTTON")) { + loaderElementList.add(new LoaderTicks(block.getLocation(), "Wooden Button", type, 30)); + } + break; + } + } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent event) { + if (event.getPlayer() != player) return; + + Block fromBlock = event.getTo().getBlock(); + Block toBlock = event.getTo().getBlock(); + if (!blockSet.contains(toBlock.getLocation())) { + blockSet.remove(fromBlock.getLocation()); + blockSet.add(toBlock.getLocation()); + + addWaitTime(false); + Material type = toBlock.getType(); + switch (type) { + case TRIPWIRE: + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Tripwire", Material.STRING, 30)); + break; + case LIGHT_WEIGHTED_PRESSURE_PLATE: + case HEAVY_WEIGHTED_PRESSURE_PLATE: + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Weighted Pressure Plate", type, 20)); + break; + default: + if (type.name().endsWith("PRESSURE_PLATE")) { + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Pressure Plate", type, 30)); + } + break; + } + } + + fromBlock = fromBlock.getRelative(0, 1, 0); + toBlock = toBlock.getRelative(0, 1, 0); + if (!blockSet.contains(toBlock.getLocation())) { + blockSet.remove(fromBlock.getLocation()); + blockSet.add(toBlock.getLocation()); + + addWaitTime(false); + Material type = toBlock.getType(); + switch (type) { + case TRIPWIRE: + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Tripwire", Material.STRING, 30)); + break; + case LIGHT_WEIGHTED_PRESSURE_PLATE: + case HEAVY_WEIGHTED_PRESSURE_PLATE: + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Weighted Pressure Plate", type, 20)); + break; + default: + if (type.name().endsWith("PRESSURE_PLATE")) { + loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Pressure Plate", type, 30)); + } + break; + } + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java new file mode 100644 index 00000000..5142e8cf --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java @@ -0,0 +1,31 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements; + +import de.steamwar.inventory.SWItem; +import org.bukkit.entity.Player; + +public interface ElementSettings { + SWItem menu(Player player); + void execute(Runnable nextAction); + void click(Player player, Runnable backAction, Runnable deleteAction); + + default void playerInteract() {} +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java new file mode 100644 index 00000000..4b1734bd --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java @@ -0,0 +1,29 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements; + +import de.steamwar.inventory.SWItem; +import org.bukkit.entity.Player; + +public interface LoaderElement { + SWItem menu(Player player); + void execute(Runnable nextAction); + void click(Player player, Runnable backAction); +} 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 new file mode 100644 index 00000000..7785f07b --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java @@ -0,0 +1,116 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +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; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.FaceAttachable; +import org.bukkit.block.data.type.Switch; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +public abstract class LoaderInteractionElement implements LoaderElement { + + protected final Location location; + protected int currentShot = 0; + protected List elements = new ArrayList<>(); + + protected LoaderInteractionElement(Location location) { + this.location = location; + + T element = createNewElement(); + element.playerInteract(); + elements.add(element); + } + + @Override + public void execute(Runnable nextAction) { + if (currentShot >= elements.size()) currentShot = 0; + elements.get(currentShot).execute(nextAction); + currentShot++; + if (currentShot >= elements.size()) currentShot = 0; + } + + @Override + public void click(Player player, Runnable backAction) { + List> entries = new ArrayList<>(); + for (T element : elements) { + entries.add(new SWListInv.SWListEntry<>(element.menu(player), element)); + } + + SWListInv listInv = new SWListInv<>(player, "Interaction Settings", false, entries, (clickType, entry) -> { + entry.click(player, () -> { + click(player, backAction); + }, () -> { + if (elements.size() == 1) return; + elements.remove(entry); + click(player, backAction); + }); + }); + listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> { + backAction.run(); + })); + listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another", clickType -> { + T element = createNewElement(); + elements.add(element); + element.click(player, () -> click(player, backAction), () -> { + if (elements.size() == 1) return; + elements.remove(element); + click(player, backAction); + }); + })); + listInv.open(); + } + + protected void update(Block block) { + Material material = block.getType(); + if (block.getBlockData() instanceof Switch) { + Switch sw = (Switch) block.getBlockData(); + FaceAttachable.AttachedFace face = sw.getAttachedFace(); + if (face == FaceAttachable.AttachedFace.FLOOR) { + updateBlock(block.getRelative(BlockFace.DOWN)); + } else if (face == FaceAttachable.AttachedFace.CEILING) { + updateBlock(block.getRelative(BlockFace.UP)); + } else { + updateBlock(block.getRelative(sw.getFacing().getOppositeFace())); + } + } else if (material == Material.TRIPWIRE) { + updateBlock(block); + } else if (material.name().endsWith("_PLATE")) { + updateBlock(block.getRelative(BlockFace.DOWN)); + } + } + + protected void updateBlock(Block block) { + BlockData data = block.getBlockData(); + block.setType(Material.BARRIER, true); + block.setBlockData(data, true); + } + + public abstract T createNewElement(); +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java new file mode 100644 index 00000000..d92ea4ad --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java @@ -0,0 +1,135 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Comparator; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderComparator extends LoaderInteractionElement { + + public LoaderComparator(Location location) { + super(location); + } + + public class ComparatorSettings implements ElementSettings { + + private boolean interact = false; + private Comparator.Mode mode = Comparator.Mode.COMPARE; + + @Override + public SWItem menu(Player player) { + return menu(player, interact, mode); + } + + private SWItem menu(Player player, boolean interact, Comparator.Mode mode) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.STICK, "§7Comparator§8: §eInteract"); + } else if (mode == null) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Comparator§8: §eNOOP"); + } else { + swItem = new SWItem(Material.COMPARATOR, "§7Comparator§8: §e" + mode.name()); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.COMPARATOR) return; + Comparator comparator = (Comparator) location.getBlock().getBlockData(); + if (interact) { + comparator.setMode(comparator.getMode() == Comparator.Mode.COMPARE ? Comparator.Mode.SUBTRACT : Comparator.Mode.COMPARE); + } else if (mode == null) { + return; + } else { + comparator.setMode(mode); + } + location.getBlock().setBlockData(comparator, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, null).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, null).getItemStack(), clickType -> { + interact = false; + mode = null; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, Comparator.Mode.COMPARE).getItemStack(), clickType -> { + interact = false; + mode = Comparator.Mode.COMPARE; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, Comparator.Mode.SUBTRACT).getItemStack(), clickType -> { + interact = false; + mode = Comparator.Mode.SUBTRACT; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact, Comparator.Mode mode) { + SWItem swItem = menu(player, interact, mode); + if (swItem.getItemStack().equals(menu(player, this.interact, this.mode).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + @Override + public void playerInteract() { + interact = true; + mode = null; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.COMPARATOR, "§7Comparator"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public ComparatorSettings createNewElement() { + return new ComparatorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java new file mode 100644 index 00000000..cbdcc7dc --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java @@ -0,0 +1,159 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.DaylightDetector; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderDaylightDetector extends LoaderInteractionElement { + + public LoaderDaylightDetector(Location location) { + super(location); + } + + public class DaylightDetectorSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = false; + private boolean inverted = true; + private int power = 0; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, inverted); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Daylight Detector§8: §eNOOP"); + } else if (interact) { + swItem = new SWItem(Material.STICK, "§7Daylight Detector§8: §eInteract"); + } else { + swItem = new SWItem(Material.DAYLIGHT_DETECTOR, "§7Daylight Detector§8: §e" + (powered ? "Powered" : "Unpowered")); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.DAYLIGHT_DETECTOR) return; + DaylightDetector daylightDetector = (DaylightDetector) location.getBlock().getBlockData(); + if (noop) { + return; + } else if (interact) { + daylightDetector.setInverted(!daylightDetector.isInverted()); + } else { + daylightDetector.setInverted(inverted); + } + daylightDetector.setPower(daylightDetector.isInverted() ? 15 - power : power); + location.getBlock().setBlockData(daylightDetector); + update(location.getBlock().getRelative(0, -1, 0)); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 36, "Settings"); + for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(27, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + inverted = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + inverted = true; + click(player, backAction, deleteAction); + }); + + for (int i = 0; i < 16; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + swInventory.setItem(finalI2 + 9, item(player, finalI).getItemStack(), clickType -> { + power = finalI; + click(player, backAction, deleteAction); + }); + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean inverted) { + SWItem swItem = menu(player, noop, interact, inverted); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.inverted).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + private SWItem item(Player player, int power) { + SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, "§7Power §8:§e " + power); + swItem.getItemStack().setAmount(power == 0 ? 1 : power); + if (!this.noop && this.power == power) swItem.setEnchanted(true); + return swItem; + } + + @Override + public void playerInteract() { + noop = false; + interact = true; + inverted = false; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.DAYLIGHT_DETECTOR, "§7Daylight Detector"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public DaylightDetectorSettings createNewElement() { + return new DaylightDetectorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java new file mode 100644 index 00000000..033d936a --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java @@ -0,0 +1,155 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Lectern; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.BookMeta; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderLectern extends LoaderInteractionElement { + + + public LoaderLectern(Location location) { + super(location); + } + + public class LecternSettings implements ElementSettings { + + private boolean noop = true; + private LecternAction action = LecternAction.PAGE_NEXT; + private int page = 0; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, action, page); + } + + private SWItem menu(Player player, boolean noop, LecternAction action, int page) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Lectern§8: §eNOOP"); + } else if (action == LecternAction.PAGE_PREV) { + swItem = new SWItem(Material.STICK, "§7Lectern§8: §ePage Prev"); + } else if (action == LecternAction.PAGE_NEXT) { + swItem = new SWItem(Material.STICK, "§7Lectern§8: §ePage Next"); + } else { + swItem = new SWItem(Material.LECTERN, "§7Lectern§8: §ePage " + page); + swItem.getItemStack().setAmount(page); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.LECTERN) return; + Lectern lectern = (Lectern) location.getBlock().getState(); + if (!((org.bukkit.block.data.type.Lectern) lectern.getBlockData()).hasBook()) return; + int pages = ((BookMeta) lectern.getInventory().getItem(0).getItemMeta()).getPages().size(); + if (noop) { + return; + } else if (action == LecternAction.PAGE_PREV) { + int page = lectern.getPage(); + if (page > 1) lectern.setPage(page - 1); + } else if (action == LecternAction.PAGE_NEXT) { + int page = lectern.getPage(); + if (page < pages) lectern.setPage(page + 1); + } else if (action == LecternAction.PAGE_SET) { + if (page <= pages) lectern.setPage(page); + } + lectern.update(false, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 36, "Settings"); + for (int i = 27; i < 35; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(27, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(3, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, LecternAction.PAGE_PREV, 0).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_PREV; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, LecternAction.PAGE_NEXT, 0).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_NEXT; + click(player, backAction, deleteAction); + }); + + for (int i = 0; i < 15; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + if (i >= 12) finalI2++; + swInventory.setItem(finalI2 + 9, item(player, false, LecternAction.PAGE_SET, finalI + 1).getItemStack(), clickType -> { + noop = false; + action = LecternAction.PAGE_SET; + page = finalI + 1; + click(player, backAction, deleteAction); + }); + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, LecternAction action, int page) { + SWItem swItem = menu(player, noop, action, page); + if (swItem.getItemStack().equals(menu(player, this.noop, this.action, this.page).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + public enum LecternAction { + PAGE_NEXT, + PAGE_PREV, + PAGE_SET + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.LECTERN, "§7Lectern"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public LecternSettings createNewElement() { + return new LecternSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java new file mode 100644 index 00000000..8bd0d7b0 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java @@ -0,0 +1,132 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Switch; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderLever extends LoaderInteractionElement { + + public LoaderLever(Location location) { + super(location); + } + + public class LeverSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = false; + private boolean power = false; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, power); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean power) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Lever§8: §eNOOP"); + } else if (interact) { + swItem = new SWItem(Material.STICK, "§7Lever§8: §eInteract"); + } else { + swItem = new SWItem(Material.LEVER, "§7Lever§8: §e" + (power ? "Active" : "Inactive")); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.LEVER) return; + if (noop) return; + + Switch lever = (Switch) location.getBlock().getBlockData(); + if (interact) { + lever.setPowered(!lever.isPowered()); + } else { + lever.setPowered(power); + } + location.getBlock().setBlockData(lever); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + power = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + power = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean power) { + SWItem swItem = menu(player, noop, interact, power); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.power).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.LEVER, "§7Lever"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public LeverSettings createNewElement() { + return new LeverSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java new file mode 100644 index 00000000..5f062f87 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java @@ -0,0 +1,115 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Instrument; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.NoteBlock; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderNoteBlock extends LoaderInteractionElement { + + public LoaderNoteBlock(Location location) { + super(location); + } + + public class NoteBlockSettings implements ElementSettings { + + private boolean interact = true; + + @Override + public SWItem menu(Player player) { + return menu(player, interact); + } + + private SWItem menu(Player player, boolean interact) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.NOTE_BLOCK, "§7Note Block§8: §eInteract"); + } else { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Note Block§8: §eNOOP"); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.NOTE_BLOCK) return; + NoteBlock noteBlock = (NoteBlock) location.getBlock().getBlockData(); + if (interact) { + if (noteBlock.getInstrument() == Instrument.BANJO) noteBlock.setInstrument(Instrument.BIT); + else noteBlock.setInstrument(Instrument.BANJO); + } else { + return; + } + location.getBlock().setBlockData(noteBlock); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(3, item(player, false).getItemStack(), clickType -> { + interact = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, true).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact) { + SWItem swItem = menu(player, interact); + if (swItem.getItemStack().equals(menu(player, this.interact).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.NOTE_BLOCK, "§7Note Block"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public NoteBlockSettings createNewElement() { + return new NoteBlockSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java new file mode 100644 index 00000000..1fc45d69 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java @@ -0,0 +1,138 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.Openable; +import org.bukkit.block.data.type.TrapDoor; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderOpenable extends LoaderInteractionElement { + + private String name; + private Material material; + + public LoaderOpenable(Location location, String name, Material material) { + super(location); + this.name = name; + this.material = material; + } + + public class TrapdoorSettings implements ElementSettings { + + private boolean noop = false; + private boolean interact = true; + private boolean open = false; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, interact, open); + } + + private SWItem menu(Player player, boolean noop, boolean interact, boolean powered) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7" + name +"§8: §eNOOP"); + } else if (interact) { + swItem = new SWItem(Material.STICK, "§7" + name + "§8: §eInteract"); + } else { + swItem = new SWItem(material, "§7" + name + "§8: §e" + (powered ? "Open" : "Closed")); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != material) return; + Openable openable = (Openable) location.getBlock().getBlockData(); + if (noop) { + return; + } else if (interact) { + openable.setOpen(!openable.isOpen()); + } else { + openable.setOpen(open); + } + location.getBlock().setBlockData(openable); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(3, item(player, false, true, false).getItemStack(), clickType -> { + noop = false; + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, false, false).getItemStack(), clickType -> { + noop = false; + interact = false; + open = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, false, true).getItemStack(), clickType -> { + noop = false; + interact = false; + open = true; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean interact, boolean open) { + SWItem swItem = menu(player, noop, interact, open); + if (swItem.getItemStack().equals(menu(player, this.noop, this.interact, this.open).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(material, "§7" + name); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public TrapdoorSettings createNewElement() { + return new TrapdoorSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java new file mode 100644 index 00000000..a0e50e48 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java @@ -0,0 +1,149 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.type.Repeater; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderRepeater extends LoaderInteractionElement { + + public LoaderRepeater(Location location) { + super(location); + } + + public class RepeaterSettings implements ElementSettings { + + private boolean interact = false; + private int delay = 1; + + @Override + public SWItem menu(Player player) { + return menu(player, interact, delay); + } + + private SWItem menu(Player player, boolean interact, int delay) { + SWItem swItem; + if (interact) { + swItem = new SWItem(Material.STICK, "§7Repeater§8: §eInteract"); + } else if (delay == 0) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7Repeater§8: §eNOOP"); + } else { + swItem = new SWItem(Material.REPEATER, "§7Repeater§8: §e" + delay); + swItem.getItemStack().setAmount(delay); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + nextAction.run(); + if (location.getBlock().getType() != Material.REPEATER) return; + Repeater repeater = (Repeater) location.getBlock().getBlockData(); + if (interact) { + int delay = repeater.getDelay(); + delay++; + if (delay > 4) delay = 1; + repeater.setDelay(delay); + } else if (delay == 0) { + return; + } else { + repeater.setDelay(delay); + } + location.getBlock().setBlockData(repeater, true); + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(1, item(player, true, -1).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); + swInventory.setItem(2, item(player, false, 0).getItemStack(), clickType -> { + interact = false; + delay = 0; + click(player, backAction, deleteAction); + }); + swInventory.setItem(4, item(player, false, 1).getItemStack(), clickType -> { + interact = false; + delay = 1; + click(player, backAction, deleteAction); + }); + swInventory.setItem(5, item(player, false, 2).getItemStack(), clickType -> { + interact = false; + delay = 2; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, 3).getItemStack(), clickType -> { + interact = false; + delay = 3; + click(player, backAction, deleteAction); + }); + swInventory.setItem(7, item(player, false, 4).getItemStack(), clickType -> { + interact = false; + delay = 4; + click(player, backAction, deleteAction); + }); + + swInventory.open(); + } + + private SWItem item(Player player, boolean interact, int delay) { + SWItem swItem = menu(player, interact, delay); + if (swItem.getItemStack().equals(menu(player, this.interact, this.delay).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + @Override + public void playerInteract() { + interact = true; + delay = 0; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.REPEATER, "§7Repeater"); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public RepeaterSettings createNewElement() { + return new RepeaterSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java new file mode 100644 index 00000000..92c2bd4e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java @@ -0,0 +1,63 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.Arrays; + +public class LoaderTNT implements LoaderElement { + + private Location location; + + public LoaderTNT(Location location) { + this.location = location; + } + + @Override + public SWItem menu(Player player) { + SWItem item = new SWItem(Material.TNT, "§cTNT"); + item.setLore(Arrays.asList("§7X§8: " + location.getBlockX(), "§7Y§8: " + location.getBlockY(), "§7Z§8: " + location.getBlockZ())); + return item; + } + + @Override + public void execute(Runnable nextAction) { + Block block = location.getBlock(); + if (block.getType() != Material.AIR && block.getType() != Material.WATER) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> execute(nextAction), 1); + return; + } + + block.setType(Material.TNT, true); + nextAction.run(); + } + + @Override + public void click(Player player, Runnable backAction) { + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java new file mode 100644 index 00000000..54e63d34 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -0,0 +1,191 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Powerable; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderTicks extends LoaderInteractionElement { + + protected String name; + protected Material material; + protected boolean analogue; + protected int ticks; + + public LoaderTicks(Location location, String name, Material material, int ticks) { + super(location); + this.name = name; + this.material = material; + this.analogue = location.getBlock().getBlockData() instanceof AnaloguePowerable; + this.ticks = ticks; + } + + public class StoneButtonSettings implements ElementSettings { + + private boolean noop = false; + private boolean waitFor = true; + private int power = 0; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, waitFor); + } + + private SWItem menu(Player player, boolean noop, boolean waitFor) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7" + name + "§8: §eNOOP"); + } else if (waitFor) { + swItem = new SWItem(material, "§7" + name + "§8: §eWaitFor"); + } else { + swItem = new SWItem(material, "§7" + name + "§8: §eNoWaitFor"); + swItem.setEnchanted(true); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + if (location.getBlock().getType() != material) { + nextAction.run(); + return; + } + if (noop) { + nextAction.run(); + return; + } + + BlockData blockData = location.getBlock().getBlockData(); + if (blockData instanceof AnaloguePowerable) { + AnaloguePowerable analoguePowerable = (AnaloguePowerable) location.getBlock().getBlockData(); + analoguePowerable.setPower(power); + } else if (blockData instanceof Powerable) { + Powerable powerable = (Powerable) location.getBlock().getBlockData(); + if (ticks < 0) { + powerable.setPowered(power > 0); + } else { + powerable.setPowered(true); + } + } + + location.getBlock().setBlockData(blockData); + update(location.getBlock()); + if (ticks >= 0) { + boolean finalWaitFor = waitFor; + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (blockData instanceof AnaloguePowerable) { + ((AnaloguePowerable) blockData).setPower(0); + } else { + ((Powerable) blockData).setPowered(false); + } + location.getBlock().setBlockData(blockData); + update(location.getBlock()); + if (finalWaitFor) { + nextAction.run(); + } + }, ticks); + if (!finalWaitFor) { + nextAction.run(); + } + } + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, analogue ? 36 : 18, "Settings"); + for (int i = analogue ? 27 : 9; i < (analogue ? 35 : 18); i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(analogue ? 27 : 9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(analogue ? 35 : 17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(3, item(player, true, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + if (ticks >= 0) { + swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> { + noop = false; + waitFor = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> { + noop = false; + waitFor = true; + click(player, backAction, deleteAction); + }); + } + + if (analogue) { + for (int i = 0; i < 16; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + swInventory.setItem(finalI2 + 9, item(player, finalI).getItemStack(), clickType -> { + power = finalI; + click(player, backAction, deleteAction); + }); + } + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean waitFor) { + SWItem swItem = menu(player, noop, waitFor); + if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + private SWItem item(Player player, int power) { + SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, "§7Power §8:§e " + power); + swItem.getItemStack().setAmount(power == 0 ? 1 : power); + if (!this.noop && this.power == power) swItem.setEnchanted(true); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(material, "§7" + name); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public StoneButtonSettings createNewElement() { + return new StoneButtonSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java new file mode 100644 index 00000000..5b263af9 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java @@ -0,0 +1,88 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.util.Arrays; + +public class LoaderWait implements LoaderElement, Listener { + + private long delay; + + public LoaderWait(long delay) { + this.delay = delay; + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(Material.CLOCK, "§7Wartezeit: §e" + delay + " Ticks"); + swItem.getItemStack().setAmount((int) Math.max(Math.min(delay, 64), 1)); + if (delay == 0) swItem.setEnchanted(true); + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + if (delay == 0) { + nextAction.run(); + return; + } + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), nextAction, delay); + } + + @Override + public void click(Player player, Runnable backAction) { + SWInventory swInventory = new SWInventory(player, 9, "Wartezeit"); + swInventory.setItem(0, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + + swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1").getItemStack(), clickType -> { + delay -= clickType.isShiftClick() ? 5 : 1; + if (delay < 0) delay = 0; + swInventory.setItem(4, menu(player)); + }); + swInventory.setItem(4, menu(player).getItemStack(), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(player, "§7Wartezeit", delay + ""); + swAnvilInv.setCallback(s -> { + try { + delay = Long.parseLong(s); + } catch (NumberFormatException ignored) { + } + click(player, backAction); + }); + swAnvilInv.open(); + }); + swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§a+1").getItemStack(), clickType -> { + delay += clickType.isShiftClick() ? 5 : 1; + swInventory.setItem(4, menu(player)); + }); + + swInventory.open(); + } +} -- 2.39.2 From e997243887d38b929a0f0f2d002637f7a3e7bec8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 12:20:24 +0200 Subject: [PATCH 02/17] Update LoaderRecorder Signed-off-by: yoyosource --- .../features/loadern/LoaderRecorder.java | 56 ++--- .../loadern/elements/impl/LoaderMovement.java | 226 ++++++++++++++++++ .../loadern/elements/impl/LoaderTicks.java | 16 +- .../loadern/elements/impl/LoaderWait.java | 1 + 4 files changed, 261 insertions(+), 38 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java index 4bc9f071..329cfd55 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java @@ -37,15 +37,14 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EquipmentSlot; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Map; public class LoaderRecorder implements Listener { private Player player; private List loaderElementList; - private Set blockSet = new HashSet<>(); private long lastInteraction = TPSUtils.currentTick.get(); public LoaderRecorder(Player player, List loaderElementList) { @@ -132,56 +131,53 @@ public class LoaderRecorder implements Listener { } } + private Map blockSet = new HashMap<>(); + private Map movementSet = new HashMap<>(); + @EventHandler public void onPlayerMove(PlayerMoveEvent event) { if (event.getPlayer() != player) return; Block fromBlock = event.getTo().getBlock(); Block toBlock = event.getTo().getBlock(); - if (!blockSet.contains(toBlock.getLocation())) { - blockSet.remove(fromBlock.getLocation()); - blockSet.add(toBlock.getLocation()); - - addWaitTime(false); - Material type = toBlock.getType(); - switch (type) { - case TRIPWIRE: - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Tripwire", Material.STRING, 30)); - break; - case LIGHT_WEIGHTED_PRESSURE_PLATE: - case HEAVY_WEIGHTED_PRESSURE_PLATE: - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Weighted Pressure Plate", type, 20)); - break; - default: - if (type.name().endsWith("PRESSURE_PLATE")) { - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Pressure Plate", type, 30)); - } - break; - } - } + calcMovementBlocks(fromBlock, toBlock); fromBlock = fromBlock.getRelative(0, 1, 0); toBlock = toBlock.getRelative(0, 1, 0); - if (!blockSet.contains(toBlock.getLocation())) { - blockSet.remove(fromBlock.getLocation()); - blockSet.add(toBlock.getLocation()); + calcMovementBlocks(fromBlock, toBlock); + } + + private void calcMovementBlocks(Block fromBlock, Block toBlock) { + if (!blockSet.containsKey(toBlock.getLocation())) { + Long startTime = blockSet.remove(fromBlock.getLocation()); + LoaderMovement loaderMovement = movementSet.remove(fromBlock.getLocation()); + if (loaderMovement != null && startTime != null) { + loaderMovement.setInitialTicks(TPSUtils.currentTick.get() - startTime); + } + + blockSet.put(toBlock.getLocation(), TPSUtils.currentTick.get()); addWaitTime(false); + loaderMovement = null; Material type = toBlock.getType(); switch (type) { case TRIPWIRE: - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Tripwire", Material.STRING, 30)); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "Tripwire", Material.STRING); break; case LIGHT_WEIGHTED_PRESSURE_PLATE: case HEAVY_WEIGHTED_PRESSURE_PLATE: - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Weighted Pressure Plate", type, 20)); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "Weighted Pressure Plate", type); break; default: if (type.name().endsWith("PRESSURE_PLATE")) { - loaderElementList.add(new LoaderTicks(toBlock.getLocation(), "Pressure Plate", type, 30)); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "Pressure Plate", type); } break; } + if (loaderMovement != null) { + movementSet.put(toBlock.getLocation(), loaderMovement); + loaderElementList.add(loaderMovement); + } } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java new file mode 100644 index 00000000..ee1f11ac --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java @@ -0,0 +1,226 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.loadern.elements.impl; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.loadern.elements.ElementSettings; +import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Powerable; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.Collections; + +public class LoaderMovement extends LoaderInteractionElement { + + private String name; + private Material material; + private boolean analogue; + + public LoaderMovement(Location location, String name, Material material) { + super(location); + this.name = name; + this.material = material; + this.analogue = location.getBlock().getBlockData() instanceof AnaloguePowerable; + } + + public void setInitialTicks(long ticks) { + elements.get(currentShot).ticks = ticks; + } + + public class MovementSettings implements ElementSettings { + + private boolean noop = false; + private boolean waitFor = true; + private int power = 0; + private long ticks = 1; + + @Override + public SWItem menu(Player player) { + return menu(player, noop, waitFor); + } + + private SWItem menu(Player player, boolean noop, boolean waitFor) { + SWItem swItem; + if (noop) { + swItem = new SWItem(Material.STRUCTURE_VOID, "§7" + name + "§8: §eNOOP"); + } else if (waitFor) { + swItem = new SWItem(material, "§7" + name + "§8: §eWaitFor"); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + } else { + swItem = new SWItem(material, "§7" + name + "§8: §eNoWaitFor"); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + swItem.setEnchanted(true); + } + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + + @Override + public void execute(Runnable nextAction) { + if (location.getBlock().getType() != material) { + nextAction.run(); + return; + } + if (noop) { + nextAction.run(); + return; + } + + BlockData blockData = location.getBlock().getBlockData(); + if (blockData instanceof AnaloguePowerable) { + AnaloguePowerable analoguePowerable = (AnaloguePowerable) location.getBlock().getBlockData(); + analoguePowerable.setPower(power); + } else if (blockData instanceof Powerable) { + Powerable powerable = (Powerable) location.getBlock().getBlockData(); + if (ticks < 0) { + powerable.setPowered(power > 0); + } else { + powerable.setPowered(true); + } + } + + location.getBlock().setBlockData(blockData); + update(location.getBlock()); + if (ticks >= 0) { + boolean finalWaitFor = waitFor; + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (blockData instanceof AnaloguePowerable) { + ((AnaloguePowerable) blockData).setPower(0); + } else { + ((Powerable) blockData).setPowered(false); + } + location.getBlock().setBlockData(blockData); + update(location.getBlock()); + if (finalWaitFor) { + nextAction.run(); + } + }, ticks); + if (!finalWaitFor) { + nextAction.run(); + } + } + } + + @Override + public void click(Player player, Runnable backAction, Runnable deleteAction) { + SWInventory swInventory = new SWInventory(player, analogue ? 45 : 27, "Settings"); + for (int i = analogue ? 36 : 18; i < (analogue ? 44 : 26); i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(analogue ? 36 : 18, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + + swInventory.setItem(3, item(player, true, false).getItemStack(), clickType -> { + noop = true; + click(player, backAction, deleteAction); + }); + if (ticks >= 0) { + swInventory.setItem(5, item(player, false, false).getItemStack(), clickType -> { + noop = false; + waitFor = false; + click(player, backAction, deleteAction); + }); + swInventory.setItem(6, item(player, false, true).getItemStack(), clickType -> { + noop = false; + waitFor = true; + click(player, backAction, deleteAction); + }); + } + + swInventory.setItem(12, new SWItem(SWItem.getDye(1), "§c-1").getItemStack(), clickType -> { + ticks -= clickType.isShiftClick() ? 5 : 1; + if (ticks < 1) ticks = 1; + swInventory.setItem(13, item(player)); + }); + swInventory.setItem(13, item(player).getItemStack(), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Ticks", ticks + ""); + swAnvilInv.setCallback(s -> { + try { + ticks = Long.parseLong(s); + if (ticks < 1) ticks = 1; + } catch (NumberFormatException ignored) { + } + click(player, backAction, deleteAction); + }); + swAnvilInv.open(); + }); + swInventory.setItem(14, new SWItem(SWItem.getDye(10), "§a+1").getItemStack(), clickType -> { + ticks += clickType.isShiftClick() ? 5 : 1; + swInventory.setItem(13, item(player)); + }); + + if (analogue) { + for (int i = 0; i < 16; i++) { + int finalI = i; + int finalI2 = i; + if (i >= 9) finalI2++; + swInventory.setItem(finalI2 + 18, item(player, finalI).getItemStack(), clickType -> { + power = finalI; + click(player, backAction, deleteAction); + }); + } + } + + swInventory.open(); + } + + private SWItem item(Player player, boolean noop, boolean waitFor) { + SWItem swItem = menu(player, noop, waitFor); + if (swItem.getItemStack().equals(menu(player, this.noop, this.waitFor).getItemStack())) { + swItem.setEnchanted(true); + } + swItem.setLore(Collections.emptyList()); + return swItem; + } + + private SWItem item(Player player, int power) { + SWItem swItem = new SWItem(power == 0 ? Material.GUNPOWDER : Material.REDSTONE, "§7Power §8:§e " + power); + swItem.getItemStack().setAmount(power == 0 ? 1 : power); + if (!this.noop && this.power == power) swItem.setEnchanted(true); + return swItem; + } + + private SWItem item(Player player) { + SWItem swItem = new SWItem(Material.CLOCK, "§7Ticks§8: §e" + ticks); + swItem.getItemStack().setAmount((int) Math.min(ticks, 64)); + swItem.setLore(Arrays.asList("§7Click to edit")); + return swItem; + } + } + + @Override + public SWItem menu(Player player) { + SWItem swItem = new SWItem(material, "§7" + name); + swItem.setLore(Arrays.asList("§7Modes§8: §e" + elements.size(), "§8", "§7Click to edit")); + return swItem; + } + + @Override + public MovementSettings createNewElement() { + return new MovementSettings(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java index 54e63d34..8e203d7d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -35,12 +35,12 @@ import org.bukkit.entity.Player; import java.util.Arrays; import java.util.Collections; -public class LoaderTicks extends LoaderInteractionElement { +public class LoaderTicks extends LoaderInteractionElement { - protected String name; - protected Material material; - protected boolean analogue; - protected int ticks; + private String name; + private Material material; + private boolean analogue; + private int ticks; public LoaderTicks(Location location, String name, Material material, int ticks) { super(location); @@ -50,7 +50,7 @@ public class LoaderTicks extends LoaderInteractionElement { try { delay = Long.parseLong(s); + if (delay < 0) delay = 0; } catch (NumberFormatException ignored) { } click(player, backAction); -- 2.39.2 From 35f882c1239fbbd8d773b91f5046b6ce14441ec7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 16:39:00 +0200 Subject: [PATCH 03/17] Update Loader Signed-off-by: yoyosource --- .../bausystem/features/loadern/LoaderRecorder.java | 2 +- .../loadern/elements/impl/LoaderComparator.java | 10 +++++----- .../features/loadern/elements/impl/LoaderLectern.java | 2 +- .../features/loadern/elements/impl/LoaderMovement.java | 3 ++- .../loadern/elements/impl/LoaderNoteBlock.java | 4 ++-- .../features/loadern/elements/impl/LoaderRepeater.java | 10 +++++----- .../features/loadern/elements/impl/LoaderTicks.java | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java index 329cfd55..04eb1c11 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java @@ -138,7 +138,7 @@ public class LoaderRecorder implements Listener { public void onPlayerMove(PlayerMoveEvent event) { if (event.getPlayer() != player) return; - Block fromBlock = event.getTo().getBlock(); + Block fromBlock = event.getFrom().getBlock(); Block toBlock = event.getTo().getBlock(); calcMovementBlocks(fromBlock, toBlock); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java index d92ea4ad..1205e4bf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java @@ -82,15 +82,15 @@ public class LoaderComparator extends LoaderInteractionElement backAction.run()); swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(2, item(player, true, null).getItemStack(), clickType -> { - interact = true; - click(player, backAction, deleteAction); - }); - swInventory.setItem(3, item(player, false, null).getItemStack(), clickType -> { + swInventory.setItem(2, item(player, false, null).getItemStack(), clickType -> { interact = false; mode = null; click(player, backAction, deleteAction); }); + swInventory.setItem(3, item(player, true, null).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); swInventory.setItem(5, item(player, false, Comparator.Mode.COMPARE).getItemStack(), clickType -> { interact = false; mode = Comparator.Mode.COMPARE; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java index 033d936a..5df1594d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java @@ -94,7 +94,7 @@ public class LoaderLectern extends LoaderInteractionElement backAction.run()); swInventory.setItem(35, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(3, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> { + swInventory.setItem(2, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> { noop = true; click(player, backAction, deleteAction); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java index ee1f11ac..176ffd19 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java @@ -50,6 +50,7 @@ public class LoaderMovement extends LoaderInteractionElement backAction.run()); swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(3, item(player, true, false).getItemStack(), clickType -> { + swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { noop = true; click(player, backAction, deleteAction); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java index 5f062f87..53811035 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java @@ -79,11 +79,11 @@ public class LoaderNoteBlock extends LoaderInteractionElement backAction.run()); swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(3, item(player, false).getItemStack(), clickType -> { + swInventory.setItem(2, item(player, false).getItemStack(), clickType -> { interact = false; click(player, backAction, deleteAction); }); - swInventory.setItem(5, item(player, true).getItemStack(), clickType -> { + swInventory.setItem(3, item(player, true).getItemStack(), clickType -> { interact = true; click(player, backAction, deleteAction); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java index a0e50e48..102ee35c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java @@ -86,15 +86,15 @@ public class LoaderRepeater extends LoaderInteractionElement backAction.run()); swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(1, item(player, true, -1).getItemStack(), clickType -> { - interact = true; - click(player, backAction, deleteAction); - }); - swInventory.setItem(2, item(player, false, 0).getItemStack(), clickType -> { + swInventory.setItem(1, item(player, false, 0).getItemStack(), clickType -> { interact = false; delay = 0; click(player, backAction, deleteAction); }); + swInventory.setItem(2, item(player, true, -1).getItemStack(), clickType -> { + interact = true; + click(player, backAction, deleteAction); + }); swInventory.setItem(4, item(player, false, 1).getItemStack(), clickType -> { interact = false; delay = 1; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java index 8e203d7d..5b615f20 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -128,7 +128,7 @@ public class LoaderTicks extends LoaderInteractionElement backAction.run()); swInventory.setItem(analogue ? 35 : 17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); - swInventory.setItem(3, item(player, true, false).getItemStack(), clickType -> { + swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { noop = true; click(player, backAction, deleteAction); }); -- 2.39.2 From 7e78c2890a0ce1cd91b04d79b74480dfec518a18 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 16:59:06 +0200 Subject: [PATCH 04/17] Update loader and remove old one Signed-off-by: yoyosource --- .../bausystem/features/loader/Loader.java | 244 ------------------ .../features/loader/LoaderBauGuiItem.java | 107 -------- .../features/loader/LoaderButton.java | 71 ----- .../features/loader/LoaderCommand.java | 160 ------------ .../activations/AbstractLoaderActivation.java | 36 --- .../BlockPlaceLoaderActivation.java | 57 ---- .../activations/InteractionActivation.java | 174 ------------- .../bausystem/features/loadern/Loader.java | 18 +- .../LoaderScoreboardElement.java | 2 +- .../loadern/elements/impl/LoaderWait.java | 5 +- 10 files changed, 17 insertions(+), 857 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/AbstractLoaderActivation.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java rename BauSystem_Main/src/de/steamwar/bausystem/features/{loader => loadern}/LoaderScoreboardElement.java (96%) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java deleted file mode 100644 index 6cba6fe9..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.loader.activations.AbstractLoaderActivation; -import de.steamwar.bausystem.features.loader.activations.BlockPlaceLoaderActivation; -import de.steamwar.bausystem.features.loader.activations.InteractionActivation; -import de.steamwar.bausystem.shared.EnumDisplay; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.bukkit.scheduler.BukkitTask; - -import java.util.*; - -@Getter -@Setter -public class Loader implements Listener { - - private static final Map LOADER_MAP = new HashMap<>(); - private final Player p; - private final List actions = new LinkedList<>(); - private int ticksBetweenShots = 80; - private int ticksBetweenBlocks = 1; - private Stage stage; - private int lastActivation = -1; - private int countdown = 0; - - @Getter(AccessLevel.PRIVATE) - private final BukkitTask task; - - @Getter(AccessLevel.PRIVATE) - @Setter(AccessLevel.PRIVATE) - private AbstractLoaderActivation current; - - @Getter(AccessLevel.PRIVATE) - @Setter(AccessLevel.PRIVATE) - private ListIterator iterator; - - private Loader(Player p) { - this.p = p; - stage = Stage.SETUP; - Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1); - } - - public static Loader getLoader(Player p) { - return LOADER_MAP.getOrDefault(p, null); - } - - public static Loader newLoader(Player p) { - return LOADER_MAP.put(p, new Loader(p)); - } - - public void start() { - if (stage != Stage.SETUP) return; - iterator = actions.listIterator(); - countdown = 0; - current = null; - stage = Stage.RUNNING; - } - - public void pause() { - if (stage == Stage.RUNNING) { - stage = Stage.PAUSE; - } - } - - public void resume() { - if (stage == Stage.PAUSE) { - stage = Stage.RUNNING; - } - } - - public void setup() { - stage = Stage.SETUP; - iterator = null; - current = null; - countdown = 0; - } - - public void stop() { - stage = Stage.END; - task.cancel(); - LOADER_MAP.remove(p, this); - } - - public void clear() { - if (stage == Stage.SETUP) { - actions.clear(); - BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR", p); - } else { - BauSystem.MESSAGE.send("LOADER_MESSAGE_CLEAR_HELP", p); - } - } - - public void single() { - if (stage != Stage.PAUSE && stage != Stage.SETUP) return; - if (iterator == null || !iterator.hasNext()) { - iterator = actions.listIterator(); - countdown = 0; - current = null; - } - stage = Stage.SINGLE; - } - - public void run() { - if (stage == Stage.SETUP && lastActivation >= 0) - lastActivation++; - - if (stage != Stage.RUNNING && stage != Stage.SINGLE) { - return; - } - - if (countdown-- > 0) { - return; - } - - while (countdown <= 0) { - if (!iterator.hasNext()) { - countdown = getTicksBetweenShots(); - iterator = actions.listIterator(); - if (stage == Stage.SINGLE) stage = Stage.PAUSE; - return; - } - - current = iterator.next(); - - if (current.execute()) { - countdown = current.delay(this); - } else { - countdown = 1; - iterator.previous(); - } - } - } - - public void undo() { - if (actions.isEmpty() || stage != Stage.SETUP) { - return; - } - actions.remove(actions.size() - 1); - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) { - if (event.getPlayer() != p) { - return; - } - - if (stage != Stage.SETUP) { - return; - } - - if (event.getBlock().getType() != Material.TNT) { - return; - } - - actions.add(new BlockPlaceLoaderActivation(p, event.getBlock().getLocation(), Material.TNT)); - SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_TNT", p, actions.size())); - } - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getPlayer() != p) { - return; - } - - if (stage != Stage.SETUP) { - return; - } - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) - return; - - if (event.getClickedBlock().getType() == Material.OBSERVER) - return; - - if (event.getHand() == EquipmentSlot.OFF_HAND) { - return; - } - - if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.TNT) { - return; - } - - LoaderButton button = LoaderButton.fromBlock(event.getClickedBlock()); - if (button != LoaderButton.INVALID) { - actions.add(InteractionActivation.construct(p, event.getClickedBlock().getLocation(), this)); - lastActivation = 0; - SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", p, BauSystem.MESSAGE.parse(button.getName(), p), actions.size())); - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - if (event.getPlayer() != p) { - return; - } - stop(); - } - - @AllArgsConstructor - public enum Stage implements EnumDisplay { - SETUP("LOADER_SETUP"), - RUNNING("LOADER_RUNNING"), - SINGLE("LOADER_SINGLE_SIDEBAR"), - PAUSE("LOADER_PAUSE"), - END("LOADER_END"); - - @Getter - private String chatValue; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java deleted file mode 100644 index 55370c3f..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.inventory.SWAnvilInv; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import de.steamwar.linkage.Linked; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Arrays; - -@Linked -public class LoaderBauGuiItem extends BauGuiItem { - - public LoaderBauGuiItem() { - super(9); - } - - @Override - public ItemStack getItem(Player player) { - return SWUtils.setCustomModelData(new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)), 1).getItemStack(); - } - - @Override - public boolean click(ClickType click, Player p) { - p.closeInventory(); - openLoaderGui(p); - return false; - } - - private void openLoaderGui(Player p) { - SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", p)); - if (Loader.getLoader(p) == null) { - inv.setItem(4, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("LOADER_GUI_NEW", p), clickType -> { - p.closeInventory(); - p.performCommand("loader setup"); - })); - } else { - Loader loader = Loader.getLoader(p); - if (loader.getStage() != Loader.Stage.RUNNING) { - inv.setItem(0, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_START", p), clickType -> { - p.closeInventory(); - p.performCommand("loader start"); - })); - } else { - inv.setItem(0, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("LOADER_GUI_PAUSE", p), clickType -> { - p.closeInventory(); - p.performCommand("loader pause"); - })); - } - inv.setItem(2, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_UNDO", p), clickType -> { - p.closeInventory(); - p.performCommand("loader undo"); - })); - inv.setItem(4, new SWItem(Material.COMPASS, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_LORE", p, loader.getTicksBetweenShots())), false, clickType -> { - p.closeInventory(); - SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", p)); - anvilInv.setItem(Material.CLOCK); - anvilInv.setCallback(s -> p.performCommand("loader delay " + s)); - anvilInv.open(); - })); - inv.setItem(6, new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED", p), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_LORE", p, loader.getTicksBetweenBlocks())), false, clickType -> { - p.closeInventory(); - SWAnvilInv anvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SPEED_TITLE", p)); - anvilInv.setItem(Material.CLOCK); - anvilInv.setCallback(s -> p.performCommand("loader speed " + s)); - anvilInv.open(); - })); - inv.setItem(8, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_STOP", p), clickType -> { - p.closeInventory(); - p.performCommand("loader stop"); - })); - } - inv.open(); - } - - @Override - public Permission permission() { - return Permission.WORLD; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java deleted file mode 100644 index 4a1d5159..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderButton.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.block.Block; - - -@AllArgsConstructor -@RequiredArgsConstructor -@Getter -public enum LoaderButton { - SWITCH(0, true, "LOADER_BUTTON_SWITCH"), - WOOD_BUTTON(30, "LOADER_BUTTON_WOOD_BUTTON"), - STONE_BUTTON(20, "LOADER_BUTTON_STONE_BUTTON"), - PRESSURE_PLATE(30, "LOADER_BUTTON_PRESSURE_PLATE"), - WEIGHTED_PRESSURE_PLATE(20, "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE"), - TRIPWIRE(30, "LOADER_BUTTON_TRIPWIRE"), - NOTEBLOCK(1, "LOADER_BUTTON_NOTEBLOCK"), - DAYLIGHTSENSOR(0, true, "LOADER_BUTTON_DAYLIGHTSENSOR"), - INVALID(-1, "LOADER_BUTTON_INVALID"); - - private final int time; - private boolean toggle; - private final String name; - - public static LoaderButton fromBlock(Block block) { - switch (block.getType()) { - case LEVER: - return LoaderButton.SWITCH; - case TRIPWIRE: - return LoaderButton.TRIPWIRE; - case NOTE_BLOCK: - return LoaderButton.NOTEBLOCK; - case DAYLIGHT_DETECTOR: - return LoaderButton.DAYLIGHTSENSOR; - case HEAVY_WEIGHTED_PRESSURE_PLATE: - case LIGHT_WEIGHTED_PRESSURE_PLATE: - return LoaderButton.WEIGHTED_PRESSURE_PLATE; - default: - if (block.getType().name().contains("STONE_BUTTON")) { - return LoaderButton.STONE_BUTTON; - } else if (block.getType().name().contains("BUTTON")) { - return LoaderButton.WOOD_BUTTON; - } else if (block.getType().name().contains("PRESSURE_PLATE")) { - return LoaderButton.PRESSURE_PLATE; - } else { - return LoaderButton.INVALID; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java deleted file mode 100644 index 95fa92b6..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; -import de.steamwar.linkage.Linked; -import org.bukkit.entity.Player; - -// @Linked -public class LoaderCommand extends SWCommand { - - public LoaderCommand() { - super("loader", "autoloader", "al"); - addDefaultHelpMessage("LOADER_HELP_OTHER"); - } - - private boolean loaderNullCheck(Loader loader, Player p) { - if (loader == null) { - BauSystem.MESSAGE.send("LOADER_NO_LOADER", p); - return true; - } - return false; - } - - @Register(value = "setup", description = "LOADER_HELP_SETUP") - public void setupLoader(@Validator Player p) { - if (Loader.getLoader(p) != null) { - Loader.getLoader(p).setup(); - BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p); - } else { - Loader.newLoader(p); - BauSystem.MESSAGE.send("LOADER_NEW", p); - BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p); - } - } - - @Register(value = "start", description = "LOADER_HELP_START") - public void startLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.start(); - BauSystem.MESSAGE.send("LOADER_ACTIVE", p); - } - - @Register(value = "stop", description = "LOADER_HELP_STOP") - public void stopLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.stop(); - BauSystem.MESSAGE.send("LOADER_STOP", p); - } - - @Register(value = "pause", description = "LOADER_HELP_PAUSE") - public void pauseLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.pause(); - BauSystem.MESSAGE.send("LOADER_PAUSED", p); - } - - @Register(value = "resume", description = "LOADER_HELP_RESUME") - public void resumeLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.resume(); - BauSystem.MESSAGE.send("LOADER_RESUME", p); - } - - @Register(value = "wait", description = "LOADER_HELP_WAIT") - public void shotDelayLoader(@Validator Player p, int delay) { - if (delay < 1) { - BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); - return; - } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots()); - loader.setTicksBetweenShots(delay); - } - - @Register(value = "speed", description = "LOADER_HELP_SPEED") - public void speedLoader(@Validator Player p, int delay) { - if (delay < 0) { - BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); - return; - } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay, loader.getTicksBetweenBlocks()); - loader.setTicksBetweenBlocks(delay); - } - - @Register(value = "undo", description = "LOADER_HELP_UNDO") - public void undoLast(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - BauSystem.MESSAGE.send("LOADER_UNDO", p); - loader.undo(); - } - - @Register(value = "clear", description = "LOADER_HELP_CLEAR") - public void clearLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.clear(); - } - - @Register(value = "single", description = "LOADER_HELP_SINGLE") - public void singleLoader(@Validator Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - loader.single(); - BauSystem.MESSAGE.send("LOADER_SINGLE", p); - } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator loaderValidator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS"); - }; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/AbstractLoaderActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/AbstractLoaderActivation.java deleted file mode 100644 index 7c4d4768..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/AbstractLoaderActivation.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader.activations; - -import de.steamwar.bausystem.features.loader.Loader; -import org.bukkit.entity.Player; - -public abstract class AbstractLoaderActivation { - - Player p; - - public AbstractLoaderActivation(Player p) { - this.p = p; - } - - public abstract boolean execute(); - - public abstract int delay(Loader loader); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java deleted file mode 100644 index 910f2071..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/BlockPlaceLoaderActivation.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader.activations; - -import de.steamwar.bausystem.features.loader.Loader; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -public class BlockPlaceLoaderActivation extends AbstractLoaderActivation { - - private final Location location; - private final Material material; - - public BlockPlaceLoaderActivation(Player p, Location location, Material material) { - super(p); - this.location = location; - if (!material.isBlock()) { - throw new IllegalStateException("Only Blocks, " + material.name() + " is not a Block"); - } - this.material = material; - } - - @Override - public boolean execute() { - Block currBlock = location.getBlock(); - if (currBlock.getType() != Material.AIR && currBlock.getType() != Material.WATER) { - return false; - } - - currBlock.setType(material, true); - return true; - } - - @Override - public int delay(Loader loader) { - return loader.getTicksBetweenBlocks(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java deleted file mode 100644 index c7f27bd3..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/activations/InteractionActivation.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.loader.activations; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loader.Loader; -import de.steamwar.bausystem.features.loader.LoaderButton; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.*; -import org.bukkit.block.data.type.DaylightDetector; -import org.bukkit.block.data.type.Switch; -import org.bukkit.entity.Player; - -public abstract class InteractionActivation extends AbstractLoaderActivation { - - Location location; - LoaderButton button; - - InteractionActivation(Player p, Location location, LoaderButton button) { - super(p); - this.location = location; - this.button = button; - } - - public static InteractionActivation construct(Player p, Location location, Loader loader) { - LoaderButton button = LoaderButton.fromBlock(location.getBlock()); - if (button.isToggle()) { - return new ToggleActivation(p, location, button, loader.getLastActivation()); - } else { - return new TimedActivation(p, location, button); - } - } - - void updateButton() { - Block block = location.getBlock(); - if (block.getBlockData() instanceof Switch) { - Switch sw = (Switch) block.getBlockData(); - FaceAttachable.AttachedFace face = sw.getAttachedFace(); - if (face == FaceAttachable.AttachedFace.FLOOR) { - update(block.getRelative(BlockFace.DOWN)); - } else if (face == FaceAttachable.AttachedFace.CEILING) { - update(block.getRelative(BlockFace.UP)); - } else { - update(block.getRelative(sw.getFacing().getOppositeFace())); - } - } else if (button == LoaderButton.TRIPWIRE) { - update(block); - } else if (button == LoaderButton.PRESSURE_PLATE || button == LoaderButton.WEIGHTED_PRESSURE_PLATE) { - update(block.getRelative(BlockFace.DOWN)); - } - } - - void update(Block block) { - BlockData data = block.getBlockData(); - block.setType(Material.BARRIER, true); - block.setBlockData(data, true); - } - - boolean getBlockPower() { - Block block = location.getBlock(); - BlockData data = block.getBlockData(); - if (data instanceof Powerable) { - Powerable pow = (Powerable) data; - return pow.isPowered(); - } - if (data instanceof DaylightDetector) { - DaylightDetector detector = (DaylightDetector) data; - return detector.isInverted(); - } - if (data instanceof AnaloguePowerable) { - AnaloguePowerable powerable = (AnaloguePowerable) data; - return powerable.getPower() > 0; - } - return false; - } - - void setBlockPower(boolean state) { - Block block = location.getBlock(); - BlockData data = block.getBlockData(); - if (data instanceof Powerable) { - Powerable pow = (Powerable) data; - pow.setPowered(state); - } - if (data instanceof Openable) { - Openable openable = (Openable) data; - openable.setOpen(state); - } - if (data instanceof DaylightDetector) { - DaylightDetector detector = (DaylightDetector) data; - detector.setInverted(state); - } - if (data instanceof AnaloguePowerable) { - AnaloguePowerable powerable = (AnaloguePowerable) data; - if (block.getType() == Material.REDSTONE_WIRE) { - powerable.setPower(state ? 15 : 0); - } else { - powerable.setPower(state ? 1 : 0); - } - } - block.setBlockData(data); - } - - public static class ToggleActivation extends InteractionActivation { - - private final int delay; - - public ToggleActivation(Player p, Location location, LoaderButton button, int delay) { - super(p, location, button); - this.delay = Math.max(delay, 0); - } - - @Override - public boolean execute() { - if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID) - return false; - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - setBlockPower(!getBlockPower()); - updateButton(); - }, delay); - return true; - } - - @Override - public int delay(Loader loader) { - return delay; - } - } - - public static class TimedActivation extends InteractionActivation { - - public TimedActivation(Player p, Location location, LoaderButton button) { - super(p, location, button); - } - - @Override - public boolean execute() { - if (LoaderButton.fromBlock(location.getBlock()) == LoaderButton.INVALID) - return false; - setBlockPower(true); - updateButton(); - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - setBlockPower(false); - updateButton(); - }, button.getTime()); - return true; - } - - @Override - public int delay(Loader loader) { - return button.getTime(); - } - } -} 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 01d56d04..d1eef52d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -21,7 +21,10 @@ package de.steamwar.bausystem.features.loadern; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.bausystem.shared.EnumDisplay; import de.steamwar.inventory.SWListInv; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -47,6 +50,7 @@ public class Loader implements Listener { private final Player p; + @Getter private Stage stage = Stage.SETUP; private LoaderRecorder recorder; @@ -121,10 +125,14 @@ public class Loader implements Listener { stop(); } - public enum Stage { - SETUP, - RUNNING, - PAUSE, - END + @AllArgsConstructor + public enum Stage implements EnumDisplay { + SETUP("LOADER_SETUP"), + RUNNING("LOADER_RUNNING"), + PAUSE("LOADER_PAUSE"), + END("LOADER_END"); + + @Getter + private String chatValue; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java index 847ed59b..d0b41cc0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loader; +package de.steamwar.bausystem.features.loadern; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java index ad84fa21..67875b2b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java @@ -59,8 +59,9 @@ public class LoaderWait implements LoaderElement, Listener { @Override public void click(Player player, Runnable backAction) { - SWInventory swInventory = new SWInventory(player, 9, "Wartezeit"); - swInventory.setItem(0, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + SWInventory swInventory = new SWInventory(player, 18, "Wartezeit"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1").getItemStack(), clickType -> { delay -= clickType.isShiftClick() ? 5 : 1; -- 2.39.2 From 792f16fadf0a4329250f6df6660e0eb36c0d5cec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 17:13:15 +0200 Subject: [PATCH 05/17] 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; -- 2.39.2 From b1dcd6d57bf7e2ddb7efb7e48addcac2caeb6876 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 1 May 2023 18:00:54 +0200 Subject: [PATCH 06/17] Update Loader and fix many things Signed-off-by: yoyosource --- .../bausystem/features/loadern/Loader.java | 18 ++++- .../loadern/LoaderScoreboardElement.java | 6 +- .../elements/LoaderInteractionElement.java | 17 +++-- .../elements/impl/LoaderDaylightDetector.java | 2 +- .../loadern/elements/impl/LoaderLever.java | 2 +- .../loadern/elements/impl/LoaderMovement.java | 18 +++-- .../loadern/elements/impl/LoaderTicks.java | 74 ++++--------------- .../loadern/elements/impl/LoaderWait.java | 2 + 8 files changed, 62 insertions(+), 77 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 40c3f750..0560f1a6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -60,6 +60,7 @@ public class Loader implements Listener { private List elements = new ArrayList<>(); private int currentElement = 0; + private long totalDelay = 0; public Loader(Player p) { this.p = p; @@ -71,9 +72,18 @@ public class Loader implements Listener { currentElement++; if (currentElement >= elements.size()) { currentElement = 0; + if (totalDelay == 0) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::next, 1); + return; + } + totalDelay = 0; } if (stage == Stage.RUNNING) { - elements.get(currentElement).execute(this::next); + LoaderElement element = elements.get(currentElement); + if (element instanceof LoaderWait) { + totalDelay += ((LoaderWait) element).getDelay(); + } + element.execute(this::next); } } @@ -136,7 +146,7 @@ public class Loader implements Listener { if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true); swListInv.setItem(48, onlyWaitElements); - SWItem onlyInteractionsElements = new SWItem(Material.TNT, "§eNur Interaktionen", clickType -> { + SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, "§eNur Interaktionen", clickType -> { settings(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); }); if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); @@ -151,6 +161,10 @@ public class Loader implements Listener { stop(); } + public String getProgress() { + return "§7" + (currentElement + 1) + "§8/§7" + elements.size(); + } + public enum SettingsSorting { WAIT, INTERACTIONS, diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java index d0b41cc0..dd0a59c5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java @@ -42,6 +42,10 @@ public class LoaderScoreboardElement implements ScoreboardElement { public String get(Region region, Player p) { Loader loader = Loader.getLoader(p); if (loader == null) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p); + if (loader.getStage() == Loader.Stage.RUNNING || loader.getStage() == Loader.Stage.PAUSE) { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p) + " §8(" + loader.getProgress() + "§8)"; + } else { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p); + } } } 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 8397779a..948a3e1d 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 @@ -86,10 +86,12 @@ public abstract class LoaderInteractionElement implem listInv.open(); } - protected void update(Block block) { - Material material = block.getType(); - if (block.getBlockData() instanceof Switch) { - Switch sw = (Switch) block.getBlockData(); + protected void update(BlockData blockData) { + Material material = blockData.getMaterial(); + Block block = location.getBlock(); + if (blockData instanceof Switch) { + Switch sw = (Switch) blockData; + updateBlock(block, sw); FaceAttachable.AttachedFace face = sw.getAttachedFace(); if (face == FaceAttachable.AttachedFace.FLOOR) { updateBlock(block.getRelative(BlockFace.DOWN)); @@ -99,14 +101,17 @@ public abstract class LoaderInteractionElement implem updateBlock(block.getRelative(sw.getFacing().getOppositeFace())); } } else if (material == Material.TRIPWIRE) { - updateBlock(block); + updateBlock(block, blockData); } else if (material.name().endsWith("_PLATE")) { updateBlock(block.getRelative(BlockFace.DOWN)); } } protected void updateBlock(Block block) { - BlockData data = block.getBlockData(); + updateBlock(block, block.getBlockData()); + } + + protected void updateBlock(Block block, BlockData data) { block.setType(Material.BARRIER, true); block.setBlockData(data, true); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java index cbdcc7dc..d78e6319 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java @@ -76,7 +76,7 @@ public class LoaderDaylightDetector extends LoaderInteractionElement= 0) { boolean finalWaitFor = waitFor; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { if (blockData instanceof AnaloguePowerable) { - ((AnaloguePowerable) blockData).setPower(0); + AnaloguePowerable analoguePowerable = (AnaloguePowerable) blockData; + analoguePowerable.setPower(0); + location.getBlock().setBlockData(analoguePowerable, true); } else { - ((Powerable) blockData).setPowered(false); + Powerable powerable = (Powerable) blockData; + powerable.setPowered(false); + location.getBlock().setBlockData(powerable, true); } - location.getBlock().setBlockData(blockData); - update(location.getBlock()); if (finalWaitFor) { nextAction.run(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java index 5b615f20..0bdb5228 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -27,8 +27,6 @@ import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.data.AnaloguePowerable; -import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Powerable; import org.bukkit.entity.Player; @@ -39,22 +37,19 @@ public class LoaderTicks extends LoaderInteractionElement 0); - } else { - powerable.setPowered(true); - } - } + Powerable powerable = (Powerable) location.getBlock().getBlockData(); + powerable.setPowered(true); + location.getBlock().setBlockData(powerable, true); - location.getBlock().setBlockData(blockData); - update(location.getBlock()); - if (ticks >= 0) { - boolean finalWaitFor = waitFor; - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - if (blockData instanceof AnaloguePowerable) { - ((AnaloguePowerable) blockData).setPower(0); - } else { - ((Powerable) blockData).setPowered(false); - } - location.getBlock().setBlockData(blockData); - update(location.getBlock()); - if (finalWaitFor) { - nextAction.run(); - } - }, ticks); - if (!finalWaitFor) { + boolean finalWaitFor = waitFor; + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + powerable.setPowered(false); + location.getBlock().setBlockData(powerable, true); + if (finalWaitFor) { nextAction.run(); } + }, ticks); + if (!finalWaitFor) { + nextAction.run(); } } @Override public void click(Player player, Runnable backAction, Runnable deleteAction) { - SWInventory swInventory = new SWInventory(player, analogue ? 36 : 18, "Settings"); - for (int i = analogue ? 27 : 9; i < (analogue ? 35 : 18); i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); - swInventory.setItem(analogue ? 27 : 9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); - swInventory.setItem(analogue ? 35 : 17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + SWInventory swInventory = new SWInventory(player, 18, "Settings"); + for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); + swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { noop = true; @@ -145,18 +122,6 @@ public class LoaderTicks extends LoaderInteractionElement= 9) finalI2++; - swInventory.setItem(finalI2 + 9, item(player, finalI).getItemStack(), clickType -> { - power = finalI; - click(player, backAction, deleteAction); - }); - } - } - swInventory.open(); } @@ -168,13 +133,6 @@ public class LoaderTicks extends LoaderInteractionElement Date: Mon, 1 May 2023 18:10:32 +0200 Subject: [PATCH 07/17] Fix LoaderMovement Signed-off-by: yoyosource --- .../features/loadern/elements/impl/LoaderMovement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java index e931ea50..0ca03583 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java @@ -84,7 +84,7 @@ public class LoaderMovement extends LoaderInteractionElement Date: Mon, 1 May 2023 20:17:30 +0200 Subject: [PATCH 08/17] Update scoreboard Signed-off-by: yoyosource --- .../src/de/steamwar/bausystem/features/loadern/Loader.java | 7 +++---- .../features/loadern/LoaderScoreboardElement.java | 6 ++++-- 2 files changed, 7 insertions(+), 6 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 0560f1a6..06dffc03 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -136,9 +136,8 @@ public class Loader implements Listener { } list.add(new SWListInv.SWListEntry<>(element.menu(p), element)); } - SWListInv swListInv = new SWListInv<>(p, "Loader Settings", false, list, (clickType, entry) -> { - entry.click(p, () -> settings(settingsSorting)); - }); + SWListInv swListInv = new SWListInv<>(p, "Loader Settings", false, list, (clickType, loaderElement) -> {}); + swListInv.setCallback((clickType, entry) -> entry.click(p, swListInv::open)); SWItem onlyWaitElements = new SWItem(Material.CLOCK, "§eNur Warten", clickType -> { settings(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); @@ -162,7 +161,7 @@ public class Loader implements Listener { } public String getProgress() { - return "§7" + (currentElement + 1) + "§8/§7" + elements.size(); + return (currentElement + 1) + "§8/§7" + elements.size(); } public enum SettingsSorting { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java index dd0a59c5..e9fc9004 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java @@ -42,8 +42,10 @@ public class LoaderScoreboardElement implements ScoreboardElement { public String get(Region region, Player p) { Loader loader = Loader.getLoader(p); if (loader == null) return null; - if (loader.getStage() == Loader.Stage.RUNNING || loader.getStage() == Loader.Stage.PAUSE) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p) + " §8(" + loader.getProgress() + "§8)"; + if (loader.getStage() == Loader.Stage.RUNNING) { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §a" + loader.getProgress(); + } else if (loader.getStage() == Loader.Stage.PAUSE) { + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: §c" + loader.getProgress(); } else { return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader.getStage().getChatValue(), p); } -- 2.39.2 From 6e82b57fbf8f9ef5a719a2faa3a5248370245a88 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 5 May 2023 16:51:14 +0200 Subject: [PATCH 09/17] Fix some stuff and add lores Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 32 ++++++----------- BauSystem_Main/src/BauSystem_de.properties | 32 ++++++----------- .../features/loadern/LoaderCommand.java | 2 +- .../features/loadern/LoaderRecorder.java | 36 ++++++++++++++----- .../loadern/elements/impl/LoaderMovement.java | 8 +++-- .../loadern/elements/impl/LoaderOpenable.java | 1 - .../loadern/elements/impl/LoaderTicks.java | 2 ++ .../loadern/elements/impl/LoaderWait.java | 4 +-- 8 files changed, 61 insertions(+), 56 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index d71c6aaf..7d3618d3 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -788,47 +788,36 @@ TRACE_GUI_POSITION_EXPLODED = §7Exploded§8: §e{0} # Loader LOADER_SETUP = §eSetup LOADER_RUNNING = §aRunning -LOADER_SINGLE_SIDEBAR = §aSingle LOADER_PAUSE = §7Pause LOADER_END = §8Finished -LOADER_MESSAGE_CLEAR = §7Loader cleared -LOADER_MESSAGE_CLEAR_HELP = §cYou have to be in Setup-Mode to clear the Loader -LOADER_MESSAGE_TNT = §eTNT added {0} LOADER_MESSAGE_INTERACT = §e{0} added {1} +LOADER_BUTTON_TNT = TNT LOADER_BUTTON_SWITCH=Lever -LOADER_BUTTON_WOOD_BUTTON=Button -LOADER_BUTTON_STONE_BUTTON=Button +LOADER_BUTTON_WOOD_BUTTON=Wooden Button +LOADER_BUTTON_STONE_BUTTON=Stone Button LOADER_BUTTON_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock LOADER_BUTTON_DAYLIGHTSENSOR=Daylightsensor -LOADER_BUTTON_INVALID=Invalid +LOADER_BUTTON_COMPARATOR=Comparator +LOADER_BUTTON_REPEATER=Repeater +LOADER_BUTTON_LECTERN=Lectern +LOADER_BUTTON_TRAPDOOR=Trapdoor +LOADER_BUTTON_DOOR=Door +LOADER_BUTTON_FENCEGATE=Fencegate LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions -LOADER_HELP_UNDO=§8/§7loader undo §8- §7Removes last recorded action LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action -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_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader -LOADER_HELP_RESUME=§8/§7loader resume §8- §7Resumes Loader +LOADER_HELP_SETTINGS=§8/§7loader settings §8- §7Shows Loader settings LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback -LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Clears recording -LOADER_HELP_SINGLE=§8/§eloader single §8- §7Starts a single shot -LOADER_HELP_OTHER=§7The loader works with §eIngame§8-§eTicks §7(20 ticks per Second) LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup -LOADER_BACK_SETUP=§7DYour Loader is in Setup again 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_RESUME=§7The Loader is resuming. -LOADER_SINGLE=§7The Loader is shooting once. -LOADER_SMALL_TIME=§cThe wait time is too small -LOADER_NEW_TIME=§7The wait time is now: {0}, before {1} -LOADER_NEW_LOAD_TIME=§7The action wait time is now: {0}, before {1} -LOADER_UNDO=§7Undo succesful. LOADER_PERMS=§cYou are not allowed to use the Loader here LOADER_GUI_NAME=§eLoader LOADER_GUI_NEW=§eNew Loader @@ -842,6 +831,7 @@ LOADER_GUI_SPEED=§eSpeed LOADER_GUI_SPEED_LORE=§7Currently: §e{0} LOADER_GUI_SPEED_TITLE=§7Block placing speed LOADER_GUI_STOP=§eStop Loader + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Starts the simple Loadtimer diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 9ac07bd8..ce5c7c17 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -761,47 +761,36 @@ TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0} # Loader LOADER_SETUP = §eEinrichtung LOADER_RUNNING = §aLaufend -LOADER_SINGLE_SIDEBAR = §aEiner LOADER_PAUSE = §7Pausiert LOADER_END = §8Beendet -LOADER_MESSAGE_CLEAR = §7Loader gecleart -LOADER_MESSAGE_CLEAR_HELP = §cDu must im Setup-Modus sein um den Loader zu clearen -LOADER_MESSAGE_TNT = §eTNT hinzugefügt {0} LOADER_MESSAGE_INTERACT = §e{0} hinzugefügt {1} +LOADER_BUTTON_TNT = TNT LOADER_BUTTON_SWITCH=Hebel -LOADER_BUTTON_WOOD_BUTTON=Knopf -LOADER_BUTTON_STONE_BUTTON=Knopf +LOADER_BUTTON_WOOD_BUTTON=Holzknopf +LOADER_BUTTON_STONE_BUTTON=Steinknopf LOADER_BUTTON_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock LOADER_BUTTON_DAYLIGHTSENSOR=Tageslichtsensor -LOADER_BUTTON_INVALID=Invalider +LOADER_BUTTON_COMPARATOR=Comparator +LOADER_BUTTON_REPEATER=Repeater +LOADER_BUTTON_LECTERN=Lectern +LOADER_BUTTON_TRAPDOOR=Trapdoor +LOADER_BUTTON_DOOR=Door +LOADER_BUTTON_FENCEGATE=Fencegate LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen -LOADER_HELP_UNDO=§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab -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_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen -LOADER_HELP_RESUME=§8/§7loader resume §8- §7Spielt den Loader weiter ab +LOADER_HELP_SETTINGS=§8/§7loader settings §8- §7Zeigt die Einstellungen an LOADER_HELP_STOP=§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen -LOADER_HELP_CLEAR=§8/§eloader clear §8- §7Cleart die Aufnahme -LOADER_HELP_SINGLE=§8/§eloader single §8- §7Spielt die Aufnahme einmal ab -LOADER_HELP_OTHER=§7Der Loader arbeitet mit §eIngame§8-§eTicks §7(20 Ticks pro Sekunde) LOADER_NO_LOADER=§cDu hast noch keinen Loader. Erstelle dir einen mit /loader setup -LOADER_BACK_SETUP=§7Dein Loader ist nun wieder im 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_RESUME=§7Der Loader läuft nun weiter. -LOADER_SINGLE=§7Der Loader schießt einmal. -LOADER_SMALL_TIME=§cDie Wartezeit ist zu klein -LOADER_NEW_TIME=§7Die Schusswartezeit ist nun: {0}, zuvor {1} -LOADER_NEW_LOAD_TIME=§7Die Setzwartezeit ist nun: {0}, zuvor {1} -LOADER_UNDO=§7Undo erfolgreich. LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen LOADER_GUI_NAME=§eLoader LOADER_GUI_NEW=§eNeuer Loader @@ -815,6 +804,7 @@ LOADER_GUI_SPEED=§eGeschwindigkeit LOADER_GUI_SPEED_LORE=§7Aktuell: §e{0} LOADER_GUI_SPEED_TITLE=§7Block Platzier Geschwindigkeit LOADER_GUI_STOP=§eLoader Stoppen + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Startet den einfachen Loadtimer 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 b2d7a2b8..77168028 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java @@ -76,7 +76,7 @@ public class LoaderCommand extends SWCommand { BauSystem.MESSAGE.send("LOADER_PAUSED", player); } - @Register(value = "settings", description = "LOADER_HELP_PAUSE") + @Register(value = "settings", description = "LOADER_HELP_SETTINGS") public void settingsLoader(@Validator Player player) { Loader loader = Loader.getLoader(player); if (loaderNullCheck(loader, player)) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java index 04eb1c11..16a41002 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.loadern; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.loadern.elements.LoaderElement; import de.steamwar.bausystem.features.loadern.elements.impl.*; import de.steamwar.bausystem.features.tpslimit.TPSUtils; @@ -81,6 +82,7 @@ public class LoaderRecorder implements Listener { addWaitTime(false); loaderElementList.add(new LoaderTNT(event.getBlock().getLocation())); + message("LOADER_BUTTON_TNT"); } @EventHandler @@ -97,35 +99,46 @@ public class LoaderRecorder implements Listener { switch (type) { case COMPARATOR: loaderElementList.add(new LoaderComparator(block.getLocation())); + message("LOADER_BUTTON_COMPARATOR"); break; case REPEATER: loaderElementList.add(new LoaderRepeater(block.getLocation())); + message("LOADER_BUTTON_REPEATER"); break; case NOTE_BLOCK: loaderElementList.add(new LoaderNoteBlock(block.getLocation())); + message("LOADER_BUTTON_NOTEBLOCK"); break; case LEVER: loaderElementList.add(new LoaderLever(block.getLocation())); + message("LOADER_BUTTON_SWITCH"); break; case DAYLIGHT_DETECTOR: loaderElementList.add(new LoaderDaylightDetector(block.getLocation())); + message("LOADER_BUTTON_DAYLIGHTSENSOR"); break; case LECTERN: loaderElementList.add(new LoaderLectern(block.getLocation())); + message("LOADER_BUTTON_LECTERN"); break; case IRON_TRAPDOOR: break; default: if (type.name().endsWith("_TRAPDOOR")) { - loaderElementList.add(new LoaderOpenable(block.getLocation(), "Trapdoor", type)); + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_TRAPDOOR", type)); + message("LOADER_BUTTON_TRAPDOOR"); } else if (type.name().endsWith("_DOOR")) { - loaderElementList.add(new LoaderOpenable(block.getLocation(), "Door", type)); + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_DOOR", type)); + message("LOADER_BUTTON_DOOR"); } else if (type.name().endsWith("FENCE_GATE")) { - loaderElementList.add(new LoaderOpenable(block.getLocation(), "Fencegate", type)); + loaderElementList.add(new LoaderOpenable(block.getLocation(), "LOADER_BUTTON_FENCEGATE", type)); + message("LOADER_BUTTON_FENCEGATE"); } else if (type.name().endsWith("STONE_BUTTON")) { - loaderElementList.add(new LoaderTicks(block.getLocation(), "Stone Button", type, 20)); + loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_STONE_BUTTON", type, 20)); + message("LOADER_BUTTON_STONE_BUTTON"); } else if (type.name().endsWith("BUTTON")) { - loaderElementList.add(new LoaderTicks(block.getLocation(), "Wooden Button", type, 30)); + loaderElementList.add(new LoaderTicks(block.getLocation(), "LOADER_BUTTON_WOOD_BUTTON", type, 30)); + message("LOADER_BUTTON_WOOD_BUTTON"); } break; } @@ -162,15 +175,18 @@ public class LoaderRecorder implements Listener { Material type = toBlock.getType(); switch (type) { case TRIPWIRE: - loaderMovement = new LoaderMovement(toBlock.getLocation(), "Tripwire", Material.STRING); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_TRIPWIRE", Material.STRING); + message("LOADER_BUTTON_TRIPWIRE"); break; case LIGHT_WEIGHTED_PRESSURE_PLATE: case HEAVY_WEIGHTED_PRESSURE_PLATE: - loaderMovement = new LoaderMovement(toBlock.getLocation(), "Weighted Pressure Plate", type); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE", type); + message("LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE"); break; default: if (type.name().endsWith("PRESSURE_PLATE")) { - loaderMovement = new LoaderMovement(toBlock.getLocation(), "Pressure Plate", type); + loaderMovement = new LoaderMovement(toBlock.getLocation(), "LOADER_BUTTON_PRESSURE_PLATE", type); + message("LOADER_BUTTON_PRESSURE_PLATE"); } break; } @@ -180,4 +196,8 @@ public class LoaderRecorder implements Listener { } } } + + private void message(String type) { + SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("LOADER_MESSAGE_INTERACT", player, BauSystem.MESSAGE.parse(type, player), loaderElementList.size())); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java index 0ca03583..ec9b7f60 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java @@ -98,6 +98,7 @@ public class LoaderMovement extends LoaderInteractionElement= 0) { @@ -115,10 +117,12 @@ public class LoaderMovement extends LoaderInteractionElement { + swInventory.setItem(12, new SWItem(SWItem.getDye(1), "§c-1", Arrays.asList("§7Shift: §c-5"), false, clickType -> {}).getItemStack(), clickType -> { ticks -= clickType.isShiftClick() ? 5 : 1; if (ticks < 1) ticks = 1; swInventory.setItem(13, item(player)); @@ -171,7 +175,7 @@ public class LoaderMovement extends LoaderInteractionElement { + swInventory.setItem(14, new SWItem(SWItem.getDye(10), "§a+1", Arrays.asList("§7Shift: §a+5"), false, clickType -> {}).getItemStack(), clickType -> { ticks += clickType.isShiftClick() ? 5 : 1; swInventory.setItem(13, item(player)); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java index 1fc45d69..876a51d4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java @@ -26,7 +26,6 @@ import de.steamwar.inventory.SWItem; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.data.Openable; -import org.bukkit.block.data.type.TrapDoor; import org.bukkit.entity.Player; import java.util.Arrays; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java index 0bdb5228..53c9e455 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -84,11 +84,13 @@ public class LoaderTicks extends LoaderInteractionElement { powerable.setPowered(false); location.getBlock().setBlockData(powerable, true); + update(powerable); if (finalWaitFor) { nextAction.run(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java index 3ea9dc28..08ba91c6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java @@ -65,7 +65,7 @@ public class LoaderWait implements LoaderElement, Listener { for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); - swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1").getItemStack(), clickType -> { + swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1", Arrays.asList("§7Shift: §c-5"), false, clickType -> {}).getItemStack(), clickType -> { delay -= clickType.isShiftClick() ? 5 : 1; if (delay < 0) delay = 0; swInventory.setItem(4, menu(player)); @@ -82,7 +82,7 @@ public class LoaderWait implements LoaderElement, Listener { }); swAnvilInv.open(); }); - swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§a+1").getItemStack(), clickType -> { + swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§a+1", Arrays.asList("§7Shift: §a+5"), false, clickType -> {}).getItemStack(), clickType -> { delay += clickType.isShiftClick() ? 5 : 1; swInventory.setItem(4, menu(player)); }); -- 2.39.2 From ac2900c080aa59101c368bd0789ec245da043734 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 5 May 2023 17:07:55 +0200 Subject: [PATCH 10/17] Add Loader setWaitBetween TNT and setGlobalWait Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 2 +- BauSystem_Main/src/BauSystem_de.properties | 2 +- .../bausystem/features/loadern/Loader.java | 60 ++++++++++++++++--- .../features/loadern/LoaderCommand.java | 6 +- .../loadern/elements/impl/LoaderWait.java | 2 + 5 files changed, 60 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 7d3618d3..3b9bba5f 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -810,7 +810,7 @@ LOADER_BUTTON_FENCEGATE=Fencegate LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader -LOADER_HELP_SETTINGS=§8/§7loader settings §8- §7Shows Loader settings +LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback 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. diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index ce5c7c17..08371f51 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -783,7 +783,7 @@ LOADER_BUTTON_FENCEGATE=Fencegate LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen -LOADER_HELP_SETTINGS=§8/§7loader settings §8- §7Zeigt die Einstellungen an +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_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. 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 06dffc03..d5b48efa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -24,6 +24,7 @@ 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.SWAnvilInv; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import lombok.AllArgsConstructor; @@ -123,7 +124,7 @@ public class Loader implements Listener { LOADER_MAP.remove(p); } - public void settings(SettingsSorting settingsSorting) { + public void gui(SettingsSorting settingsSorting) { List> list = new ArrayList<>(); for (LoaderElement element : elements) { if (settingsSorting != null) { @@ -139,17 +140,62 @@ public class Loader implements Listener { SWListInv swListInv = new SWListInv<>(p, "Loader Settings", false, list, (clickType, loaderElement) -> {}); swListInv.setCallback((clickType, entry) -> entry.click(p, swListInv::open)); + SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, "§eNur Interaktionen", clickType -> { + gui(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); + }); + if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); + swListInv.setItem(47, onlyInteractionsElements); + SWItem onlyWaitElements = new SWItem(Material.CLOCK, "§eNur Warten", clickType -> { - settings(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); + gui(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); }); if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true); swListInv.setItem(48, onlyWaitElements); - SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, "§eNur Interaktionen", clickType -> { - settings(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); - }); - if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); - swListInv.setItem(50, onlyInteractionsElements); + if (settingsSorting == SettingsSorting.WAIT) { + SWItem waitBetweenTNT = new SWItem(Material.TNT, "§7Wait Time zwischen TNT", clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, "§7Wartezeit", ""); + swAnvilInv.setCallback(s -> { + try { + long delay = Long.parseLong(s); + if (delay < 0) delay = 0; + for (int i = 1; i < elements.size() - 1; i++) { + if (!(elements.get(i - 1) instanceof LoaderTNT)) continue; + if (!(elements.get(i + 1) instanceof LoaderTNT)) continue; + if (!(elements.get(i) instanceof LoaderWait)) continue; + ((LoaderWait) elements.get(i)).setDelay(delay); + } + } catch (NumberFormatException ignored) { + } + gui(settingsSorting); + }); + swAnvilInv.open(); + }); + swListInv.setItem(50, waitBetweenTNT); + + SWItem waitTime = new SWItem(Material.PAPER, "§7Wait Time alle", clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, "§7Wartezeit", ""); + swAnvilInv.setCallback(s -> { + try { + long delay = Long.parseLong(s); + if (delay < 0) delay = 0; + long finalDelay = delay; + elements.stream() + .filter(LoaderWait.class::isInstance) + .map(LoaderWait.class::cast) + .forEach(loaderWait -> loaderWait.setDelay(finalDelay)); + } catch (NumberFormatException ignored) { + } + swListInv.open(); + }); + gui(settingsSorting); + }); + swListInv.setItem(51, waitTime); + } else { + SWItem empty = new SWItem(Material.STRUCTURE_VOID, "§7", clickType -> {}); + swListInv.setItem(50, empty); + swListInv.setItem(51, empty); + } swListInv.open(); } 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 77168028..5799bc6e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java @@ -76,11 +76,11 @@ public class LoaderCommand extends SWCommand { BauSystem.MESSAGE.send("LOADER_PAUSED", player); } - @Register(value = "settings", description = "LOADER_HELP_SETTINGS") - public void settingsLoader(@Validator Player player) { + @Register(value = "gui", description = "LOADER_HELP_GUI") + public void guiLoader(@Validator Player player) { Loader loader = Loader.getLoader(player); if (loaderNullCheck(loader, player)) return; - loader.settings(null); + loader.gui(null); } @ClassValidator(value = Player.class, local = true) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java index 08ba91c6..841969fe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java @@ -25,6 +25,7 @@ import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import lombok.Getter; +import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -35,6 +36,7 @@ import java.util.Arrays; public class LoaderWait implements LoaderElement, Listener { @Getter + @Setter private long delay; public LoaderWait(long delay) { -- 2.39.2 From 55a720eb438e1b0474cc5ff3471c7a64418e11a7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 5 May 2023 17:15:10 +0200 Subject: [PATCH 11/17] Remove unused translations Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 12 ------------ BauSystem_Main/src/BauSystem_de.properties | 12 ------------ .../loadern/elements/LoaderInteractionElement.java | 2 +- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 3b9bba5f..9a9f24af 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -819,18 +819,6 @@ LOADER_ACTIVE=§7The Loader is now active. LOADER_STOP=§7The Loader has been stopped. LOADER_PAUSED=§7The Loader is now paused. LOADER_PERMS=§cYou are not allowed to use the Loader here -LOADER_GUI_NAME=§eLoader -LOADER_GUI_NEW=§eNew Loader -LOADER_GUI_START=§eStart Loader -LOADER_GUI_PAUSE=§7pause Loader -LOADER_GUI_UNDO=§7Undo last action -LOADER_GUI_WAIT=§7Shot delay -LOADER_GUI_WAIT_LORE=§7Currently: §e{0} -LOADER_GUI_WAIT_TITLE=§7Shot delay -LOADER_GUI_SPEED=§eSpeed -LOADER_GUI_SPEED_LORE=§7Currently: §e{0} -LOADER_GUI_SPEED_TITLE=§7Block placing speed -LOADER_GUI_STOP=§eStop Loader # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 08371f51..e0d12fa6 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -792,18 +792,6 @@ LOADER_ACTIVE=§7Der Loader ist nun aktiviert. LOADER_STOP=§7Der Loader ist nun gestoppt. LOADER_PAUSED=§7Der Loader ist nun pausiert. LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen -LOADER_GUI_NAME=§eLoader -LOADER_GUI_NEW=§eNeuer Loader -LOADER_GUI_START=§eLoader starten -LOADER_GUI_PAUSE=§7Loader pausieren -LOADER_GUI_UNDO=§7Letzte Aktion Rückgängig machen -LOADER_GUI_WAIT=§7Schuss Delay -LOADER_GUI_WAIT_LORE=§7Aktuell: §e{0} -LOADER_GUI_WAIT_TITLE=§7Schuss Delay -LOADER_GUI_SPEED=§eGeschwindigkeit -LOADER_GUI_SPEED_LORE=§7Aktuell: §e{0} -LOADER_GUI_SPEED_TITLE=§7Block Platzier Geschwindigkeit -LOADER_GUI_STOP=§eLoader Stoppen # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone 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 948a3e1d..0d38cd7a 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 @@ -74,7 +74,7 @@ public abstract class LoaderInteractionElement implem listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> { backAction.run(); })); - listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another", clickType -> { + listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> { T element = createNewElement(); elements.add(element); element.click(player, () -> click(player, backAction), () -> { -- 2.39.2 From bb654018d602792ac27f77b6a8ea322af8ff54e4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 May 2023 01:43:28 +0200 Subject: [PATCH 12/17] Update some multilingual stuff for Loader and LoaderCommand Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 10 ++++++++++ BauSystem_Main/src/BauSystem_de.properties | 10 ++++++++++ .../bausystem/features/loadern/Loader.java | 20 +++++++++---------- .../features/loadern/LoaderCommand.java | 2 +- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 9a9f24af..7a451354 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -807,7 +807,9 @@ LOADER_BUTTON_LECTERN=Lectern LOADER_BUTTON_TRAPDOOR=Trapdoor LOADER_BUTTON_DOOR=Door LOADER_BUTTON_FENCEGATE=Fencegate + LOADER_HELP_SETUP=§8/§eloader setup §8- §7Starts recording actions +LOADER_SETUP_STOP_FIRST=§cPlease stop the current loader first! LOADER_HELP_START=§8/§eloader start §8- §7Playback of previously recorded action LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pauses Loader LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui @@ -820,6 +822,14 @@ LOADER_STOP=§7The Loader has been stopped. LOADER_PAUSED=§7The Loader is now paused. LOADER_PERMS=§cYou are not allowed to use the Loader here +LOADER_NOTHING_RECORDED=§cYou have not recorded anything yet! +LOADER_GUI_TITLE=Loader GUI +LOADER_GUI_SHOW_INTERACTIONS=§eShow only Interactions +LOADER_GUI_SHOW_WAITS=§eShow only Waits +LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time between TNT +LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time all +LOADER_GUI_SHOW_WAITS_TITLE=§7Wait Time + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Starts the simple Loadtimer diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index e0d12fa6..38a4e4cb 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -780,7 +780,9 @@ LOADER_BUTTON_LECTERN=Lectern LOADER_BUTTON_TRAPDOOR=Trapdoor LOADER_BUTTON_DOOR=Door LOADER_BUTTON_FENCEGATE=Fencegate + LOADER_HELP_SETUP=§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen +LOADER_SETUP_STOP_FIRST=§cBitte stoppe zuerst den Loader LOADER_HELP_START=§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab LOADER_HELP_PAUSE=§8/§7loader pause §8- §7Pausiert das Abspielen LOADER_HELP_GUI=§8/§7loader settings §8- §7Zeigt die Einstellungen an @@ -793,6 +795,14 @@ LOADER_STOP=§7Der Loader ist nun gestoppt. LOADER_PAUSED=§7Der Loader ist nun pausiert. LOADER_PERMS=§cDu darfst hier nicht den Detonator nutzen +LOADER_NOTHING_RECORDED=§cEs wurden keine Elemente aufgenommen! +LOADER_GUI_TITLE=Loader Einstellungen +LOADER_GUI_SHOW_INTERACTIONS=§eZeige Interaktionen +LOADER_GUI_SHOW_WAITS=§eZeige Wartezeiten +LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time zwischen TNT +LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time alle +LOADER_GUI_SHOW_WAITS_TITLE=§7Wartezeit + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Startet den einfachen Loadtimer 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 d5b48efa..a50ad0bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -97,7 +97,7 @@ public class Loader implements Listener { recorder = null; } if (elements.isEmpty()) { - p.sendMessage("§cEs wurden keine Elemente aufgenommen!"); + BauSystem.MESSAGE.send("LOADER_NOTHING_RECORDED", p); stop(); return; } @@ -137,24 +137,24 @@ public class Loader implements Listener { } list.add(new SWListInv.SWListEntry<>(element.menu(p), element)); } - SWListInv swListInv = new SWListInv<>(p, "Loader Settings", false, list, (clickType, loaderElement) -> {}); + SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {}); swListInv.setCallback((clickType, entry) -> entry.click(p, swListInv::open)); - SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, "§eNur Interaktionen", clickType -> { + SWItem onlyInteractionsElements = new SWItem(Material.REPEATER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_INTERACTIONS", p), clickType -> { gui(settingsSorting == SettingsSorting.INTERACTIONS ? null : SettingsSorting.INTERACTIONS); }); if (settingsSorting == SettingsSorting.INTERACTIONS) onlyInteractionsElements.setEnchanted(true); swListInv.setItem(47, onlyInteractionsElements); - SWItem onlyWaitElements = new SWItem(Material.CLOCK, "§eNur Warten", clickType -> { + SWItem onlyWaitElements = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS", p), clickType -> { gui(settingsSorting == SettingsSorting.WAIT ? null : SettingsSorting.WAIT); }); if (settingsSorting == SettingsSorting.WAIT) onlyWaitElements.setEnchanted(true); swListInv.setItem(48, onlyWaitElements); if (settingsSorting == SettingsSorting.WAIT) { - SWItem waitBetweenTNT = new SWItem(Material.TNT, "§7Wait Time zwischen TNT", clickType -> { - SWAnvilInv swAnvilInv = new SWAnvilInv(p, "§7Wartezeit", ""); + SWItem waitBetweenTNT = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT", p), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), ""); swAnvilInv.setCallback(s -> { try { long delay = Long.parseLong(s); @@ -173,8 +173,8 @@ public class Loader implements Listener { }); swListInv.setItem(50, waitBetweenTNT); - SWItem waitTime = new SWItem(Material.PAPER, "§7Wait Time alle", clickType -> { - SWAnvilInv swAnvilInv = new SWAnvilInv(p, "§7Wartezeit", ""); + SWItem waitTime = new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_SET_ALL", p), clickType -> { + SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("LOADER_GUI_SHOW_WAITS_TITLE", p), ""); swAnvilInv.setCallback(s -> { try { long delay = Long.parseLong(s); @@ -186,9 +186,9 @@ public class Loader implements Listener { .forEach(loaderWait -> loaderWait.setDelay(finalDelay)); } catch (NumberFormatException ignored) { } - swListInv.open(); + gui(settingsSorting); }); - gui(settingsSorting); + swAnvilInv.open(); }); swListInv.setItem(51, waitTime); } else { 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 5799bc6e..070b2e95 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java @@ -44,7 +44,7 @@ public class LoaderCommand extends SWCommand { @Register(value = "setup", description = "LOADER_HELP_SETUP") public void setupLoader(@Validator Player player) { if (Loader.getLoader(player) != null) { - player.sendMessage("Please stop the current loader first!"); + BauSystem.MESSAGE.send("LOADER_SETUP_STOP_FIRST", player); return; } Loader.newLoader(player); -- 2.39.2 From be33184cfede23c99bbb538bb536e397e2bf9490 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 May 2023 01:50:56 +0200 Subject: [PATCH 13/17] Update some gui texts Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 5 +++++ BauSystem_Main/src/BauSystem_de.properties | 5 +++++ .../features/loadern/elements/impl/LoaderComparator.java | 7 ++++--- .../loadern/elements/impl/LoaderDaylightDetector.java | 7 ++++--- .../features/loadern/elements/impl/LoaderLectern.java | 7 ++++--- .../features/loadern/elements/impl/LoaderLever.java | 7 ++++--- .../features/loadern/elements/impl/LoaderMovement.java | 6 +++--- .../features/loadern/elements/impl/LoaderNoteBlock.java | 7 ++++--- .../features/loadern/elements/impl/LoaderOpenable.java | 7 ++++--- .../features/loadern/elements/impl/LoaderRepeater.java | 7 ++++--- .../features/loadern/elements/impl/LoaderTicks.java | 6 +++--- .../features/loadern/elements/impl/LoaderWait.java | 4 ++-- 12 files changed, 46 insertions(+), 29 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 7a451354..cd378576 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -829,6 +829,11 @@ LOADER_GUI_SHOW_WAITS=§eShow only Waits LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time between TNT LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time all LOADER_GUI_SHOW_WAITS_TITLE=§7Wait Time +LOADER_GUI_SETTINGS_TITLE=Settings +LOADER_GUI_SETTINGS_BACK=§8Back +LOADER_GUI_SETTINGS_DELETE=§cDelete +LOADER_GUI_WAIT_TITLE=Settings +LOADER_GUI_WAIT_BACK=§8Back # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 38a4e4cb..2515d945 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -802,6 +802,11 @@ LOADER_GUI_SHOW_WAITS=§eZeige Wartezeiten LOADER_GUI_SHOW_WAITS_SET_BETWEEN_TNT=§7Wait Time zwischen TNT LOADER_GUI_SHOW_WAITS_SET_ALL=§7Wait Time alle LOADER_GUI_SHOW_WAITS_TITLE=§7Wartezeit +LOADER_GUI_SETTINGS_TITLE=Einstellungen +LOADER_GUI_SETTINGS_BACK=§8Zurück +LOADER_GUI_SETTINGS_DELETE=§cLöschen +LOADER_GUI_WAIT_TITLE=Wartezeit +LOADER_GUI_WAIT_BACK=§8Zurück # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java index 1205e4bf..52d51fe5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -77,10 +78,10 @@ public class LoaderComparator extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, false, null).getItemStack(), clickType -> { interact = false; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java index d78e6319..cc1927b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -81,10 +82,10 @@ public class LoaderDaylightDetector extends LoaderInteractionElement backAction.run()); - swInventory.setItem(35, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java index 5df1594d..c60e9f30 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -89,10 +90,10 @@ public class LoaderLectern extends LoaderInteractionElement backAction.run()); - swInventory.setItem(35, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(27, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(35, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, LecternAction.PAGE_SET, 0).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java index e83d5539..06105eaf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -78,10 +79,10 @@ public class LoaderLever extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java index ec9b7f60..6147d9c4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java @@ -136,10 +136,10 @@ public class LoaderMovement extends LoaderInteractionElement backAction.run()); - swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(analogue ? 36 : 18, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(analogue ? 44 : 26, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java index 53811035..f36271b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -74,10 +75,10 @@ public class LoaderNoteBlock extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, false).getItemStack(), clickType -> { interact = false; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java index 876a51d4..599582ef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -83,10 +84,10 @@ public class LoaderOpenable extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false, false).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java index 102ee35c..3e0354d0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements.impl; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loadern.elements.ElementSettings; import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; @@ -81,10 +82,10 @@ public class LoaderRepeater extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(1, item(player, false, 0).getItemStack(), clickType -> { interact = false; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java index 53c9e455..1b6da9e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java @@ -102,10 +102,10 @@ public class LoaderTicks extends LoaderInteractionElement backAction.run()); - swInventory.setItem(17, new SWItem(Material.BARRIER, "§cDelete").getItemStack(), clickType -> deleteAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> backAction.run()); + swInventory.setItem(17, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_DELETE", player)).getItemStack(), clickType -> deleteAction.run()); swInventory.setItem(2, item(player, true, false).getItemStack(), clickType -> { noop = true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java index 841969fe..75374abc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java @@ -63,9 +63,9 @@ public class LoaderWait implements LoaderElement, Listener { @Override public void click(Player player, Runnable backAction) { - SWInventory swInventory = new SWInventory(player, 18, "Wartezeit"); + SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player)); for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7")); - swInventory.setItem(9, new SWItem(Material.ARROW, "§8Back").getItemStack(), clickType -> backAction.run()); + swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).getItemStack(), clickType -> backAction.run()); swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1", Arrays.asList("§7Shift: §c-5"), false, clickType -> {}).getItemStack(), clickType -> { delay -= clickType.isShiftClick() ? 5 : 1; -- 2.39.2 From a73372a406b58436f0e94f2598d03688115661db Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 May 2023 22:36:33 +0200 Subject: [PATCH 14/17] Update some more messages Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 2 ++ BauSystem_Main/src/BauSystem_de.properties | 2 ++ .../features/loadern/elements/impl/LoaderComparator.java | 2 +- .../features/loadern/elements/impl/LoaderDaylightDetector.java | 2 +- .../bausystem/features/loadern/elements/impl/LoaderLectern.java | 2 +- .../bausystem/features/loadern/elements/impl/LoaderLever.java | 2 +- .../features/loadern/elements/impl/LoaderMovement.java | 2 +- .../features/loadern/elements/impl/LoaderNoteBlock.java | 2 +- .../features/loadern/elements/impl/LoaderOpenable.java | 2 +- .../features/loadern/elements/impl/LoaderRepeater.java | 2 +- .../bausystem/features/loadern/elements/impl/LoaderTicks.java | 2 +- .../bausystem/features/loadern/elements/impl/LoaderWait.java | 2 +- 12 files changed, 14 insertions(+), 10 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index cd378576..d6e9c273 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -835,6 +835,8 @@ LOADER_GUI_SETTINGS_DELETE=§cDelete LOADER_GUI_WAIT_TITLE=Settings LOADER_GUI_WAIT_BACK=§8Back +LOADER_GUI_CLICK_TO_EDIT=§7Click to edit + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Starts the simple Loadtimer diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 2515d945..692c5253 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -808,6 +808,8 @@ LOADER_GUI_SETTINGS_DELETE=§cLöschen LOADER_GUI_WAIT_TITLE=Wartezeit LOADER_GUI_WAIT_BACK=§8Zurück +LOADER_GUI_CLICK_TO_EDIT=§7Click to edit + # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone LOADTIMER_HELP_START_1=§8/§eloadtimer start §8-§7 Startet den einfachen Loadtimer diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java index 52d51fe5..25f874c3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java @@ -57,7 +57,7 @@ public class LoaderComparator extends LoaderInteractionElement Date: Tue, 9 May 2023 17:19:27 +0200 Subject: [PATCH 15/17] Update LoaderDaylightDetector Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 10 +++++++++- BauSystem_Main/src/BauSystem_de.properties | 2 +- .../bausystem/features/loadern/LoaderRecorder.java | 2 +- .../features/loadern/elements/ElementSettings.java | 5 +++++ .../loadern/elements/LoaderInteractionElement.java | 5 +++++ .../elements/impl/LoaderDaylightDetector.java | 12 ++++++------ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index d6e9c273..5dfba6ed 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -800,7 +800,7 @@ LOADER_BUTTON_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Pressure plate LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock -LOADER_BUTTON_DAYLIGHTSENSOR=Daylightsensor +LOADER_BUTTON_DAYLIGHT_DETECTOR=Daylight Detector LOADER_BUTTON_COMPARATOR=Comparator LOADER_BUTTON_REPEATER=Repeater LOADER_BUTTON_LECTERN=Lectern @@ -836,6 +836,14 @@ LOADER_GUI_WAIT_TITLE=Settings LOADER_GUI_WAIT_BACK=§8Back LOADER_GUI_CLICK_TO_EDIT=§7Click to edit +LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1} +LOADER_SETTING_NAME=§7{0} +LOADER_SETTING_MODES=§7Modes§8: §e{0} +LOADER_SETTING_POWER=§7Power§8: §e{0} +LOADER_INTERACTION_NOOP=NOOP +LOADER_INTERACTION_INTERACT=Interact +LOADER_INTERACTION_POWERED=Powered +LOADER_INTERACTION_UNPOWERED=Unpowered # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 692c5253..5495c3be 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -773,7 +773,7 @@ LOADER_BUTTON_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_WEIGHTED_PRESSURE_PLATE=Druckplatte LOADER_BUTTON_TRIPWIRE=Tripwire LOADER_BUTTON_NOTEBLOCK=Noteblock -LOADER_BUTTON_DAYLIGHTSENSOR=Tageslichtsensor +LOADER_BUTTON_DAYLIGHT_DETECTOR=Tageslichtsensor LOADER_BUTTON_COMPARATOR=Comparator LOADER_BUTTON_REPEATER=Repeater LOADER_BUTTON_LECTERN=Lectern diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java index 16a41002..135cd7ac 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java @@ -115,7 +115,7 @@ public class LoaderRecorder implements Listener { break; case DAYLIGHT_DETECTOR: loaderElementList.add(new LoaderDaylightDetector(block.getLocation())); - message("LOADER_BUTTON_DAYLIGHTSENSOR"); + message("LOADER_BUTTON_DAYLIGHT_DETECTOR"); break; case LECTERN: loaderElementList.add(new LoaderLectern(block.getLocation())); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java index 5142e8cf..f2a63b69 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements; +import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; import org.bukkit.entity.Player; @@ -28,4 +29,8 @@ public interface ElementSettings { void click(Player player, Runnable backAction, Runnable deleteAction); default void playerInteract() {} + + default String translateItemName(String name, String mode, Player player) { + return BauSystem.MESSAGE.parse("LOADER_GUI_ITEM_NAME", player, BauSystem.MESSAGE.parse(name, player), BauSystem.MESSAGE.parse(mode, player)); + } } 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 0d38cd7a..eabd054f 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,6 +19,7 @@ package de.steamwar.bausystem.features.loadern.elements; +import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import org.bukkit.Location; @@ -117,4 +118,8 @@ public abstract class LoaderInteractionElement implem } public abstract T createNewElement(); + + protected final String translateItemName(String name, Player player) { + return BauSystem.MESSAGE.parse("LOADER_SETTING_NAME", player, BauSystem.MESSAGE.parse(name, player)); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java index d5c0192e..f81236c7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java @@ -53,11 +53,11 @@ public class LoaderDaylightDetector extends LoaderInteractionElement Date: Tue, 9 May 2023 18:28:53 +0200 Subject: [PATCH 16/17] Add all translations Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 38 +++++++++++++++---- BauSystem_Main/src/BauSystem_de.properties | 30 +++++++++++++++ .../bausystem/features/loadern/Loader.java | 9 ++--- .../loadern/elements/ElementSettings.java | 4 +- .../elements/impl/LoaderDaylightDetector.java | 4 +- .../loadern/elements/impl/LoaderLectern.java | 12 +++--- .../loadern/elements/impl/LoaderLever.java | 10 ++--- .../loadern/elements/impl/LoaderMovement.java | 22 +++++------ .../elements/impl/LoaderNoteBlock.java | 8 ++-- .../loadern/elements/impl/LoaderOpenable.java | 10 ++--- .../loadern/elements/impl/LoaderRepeater.java | 10 ++--- .../loadern/elements/impl/LoaderTNT.java | 4 +- .../loadern/elements/impl/LoaderTicks.java | 10 ++--- .../loadern/elements/impl/LoaderWait.java | 8 ++-- 14 files changed, 107 insertions(+), 72 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 5dfba6ed..9f4b2edb 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -791,8 +791,8 @@ LOADER_RUNNING = §aRunning LOADER_PAUSE = §7Pause LOADER_END = §8Finished -LOADER_MESSAGE_INTERACT = §e{0} added {1} -LOADER_BUTTON_TNT = TNT +LOADER_MESSAGE_INTERACT=§e{0} added {1} +LOADER_BUTTON_TNT=TNT LOADER_BUTTON_SWITCH=Lever LOADER_BUTTON_WOOD_BUTTON=Wooden Button LOADER_BUTTON_STONE_BUTTON=Stone Button @@ -835,15 +835,37 @@ LOADER_GUI_SETTINGS_DELETE=§cDelete LOADER_GUI_WAIT_TITLE=Settings LOADER_GUI_WAIT_BACK=§8Back -LOADER_GUI_CLICK_TO_EDIT=§7Click to edit +LOADER_GUI_CLICK_TO_EDIT=§7Klicke zum editieren LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1} LOADER_SETTING_NAME=§7{0} -LOADER_SETTING_MODES=§7Modes§8: §e{0} -LOADER_SETTING_POWER=§7Power§8: §e{0} +LOADER_SETTING_MODES=§7Modi§8: §e{0} +LOADER_SETTING_POWER=§7Redstone Stärke§8: §e{0} +LOADER_SETTING_TICKS=§7Ticks§8: §e{0} +LOADER_SETTING_REPEATER=§7Repeater§8: §e{0} +LOADER_SETTING_WAIT=§7Wartezeit§8: §e{0} Tick(s) +LOADER_SETTING_WAIT_NAME=Wartezeit +LOADER_SETTING_TICKS_NAME=Ticks +LOADER_SETTING_TICKS_REMOVE_ONE=§c-1 +LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5 +LOADER_SETTING_TICKS_ADD_ONE=§a+1 +LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5 +LOADER_SETTING_TNT_NAME=§cTNT +LOADER_SETTING_TNT_X=§7X§8: §e{0} +LOADER_SETTING_TNT_Y=§7Y§8: §e{0} +LOADER_SETTING_TNT_Z=§7Z§8: §e{0} LOADER_INTERACTION_NOOP=NOOP -LOADER_INTERACTION_INTERACT=Interact -LOADER_INTERACTION_POWERED=Powered -LOADER_INTERACTION_UNPOWERED=Unpowered +LOADER_INTERACTION_INTERACT=Interagiere +LOADER_INTERACTION_POWERED=Aktiviert +LOADER_INTERACTION_UNPOWERED=Deaktiviert +LOADER_INTERACTION_PAGE_PREV=Vorherige Seite +LOADER_INTERACTION_PAGE_NEXT=Nächste Seite +LOADER_INTERACTION_PAGE=Seite {0} +LOADER_INTERACTION_ACTIVE=Aktiviert +LOADER_INTERACTION_INACTIVE=Deaktiviert +LOADER_INTERACTION_WAIT_FOR=Darauf warten +LOADER_INTERACTION_NO_WAIT_FOR=Nicht darauf warten +LOADER_INTERACTION_OPEN=Geöffnet +LOADER_INTERACTION_CLOSED=Geschlossen # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Compete with your friends loading your cannon and get information about the cannon diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 5495c3be..97ba1f97 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -809,6 +809,36 @@ LOADER_GUI_WAIT_TITLE=Wartezeit LOADER_GUI_WAIT_BACK=§8Zurück LOADER_GUI_CLICK_TO_EDIT=§7Click to edit +LOADER_GUI_ITEM_NAME=§7{0}§8: §e{1} +LOADER_SETTING_NAME=§7{0} +LOADER_SETTING_MODES=§7Modes§8: §e{0} +LOADER_SETTING_POWER=§7Power§8: §e{0} +LOADER_SETTING_TICKS=§7Ticks§8: §e{0} +LOADER_SETTING_REPEATER=§7Repeater§8: §e{0} +LOADER_SETTING_WAIT=§7Wait§8: §e{0} Tick(s) +LOADER_SETTING_WAIT_NAME=Wait +LOADER_SETTING_TICKS_NAME=Ticks +LOADER_SETTING_TICKS_REMOVE_ONE=§c-1 +LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT=§7Shift§8: §c-5 +LOADER_SETTING_TICKS_ADD_ONE=§a+1 +LOADER_SETTING_TICKS_ADD_ONE_SHIFT=§7Shift§8: §a+5 +LOADER_SETTING_TNT_NAME=§cTNT +LOADER_SETTING_TNT_X=§7X§8: §e{0} +LOADER_SETTING_TNT_Y=§7Y§8: §e{0} +LOADER_SETTING_TNT_Z=§7Z§8: §e{0} +LOADER_INTERACTION_NOOP=NOOP +LOADER_INTERACTION_INTERACT=Interact +LOADER_INTERACTION_POWERED=Powered +LOADER_INTERACTION_UNPOWERED=Unpowered +LOADER_INTERACTION_PAGE_PREV=Previous Page +LOADER_INTERACTION_PAGE_NEXT=Next Page +LOADER_INTERACTION_PAGE=Page {0} +LOADER_INTERACTION_ACTIVE=Active +LOADER_INTERACTION_INACTIVE=Inactive +LOADER_INTERACTION_WAIT_FOR=Wait for +LOADER_INTERACTION_NO_WAIT_FOR=No wait for +LOADER_INTERACTION_OPEN=Open +LOADER_INTERACTION_CLOSED=Closed # Loadtimer LOADTIMER_HELP_OVERVIEW=§7Messe dich und deine Freunde beim Beladen einer Kanone und bekomme informationen über die Kanone 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 a50ad0bc..612ebd28 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java @@ -36,10 +36,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class Loader implements Listener { @@ -135,7 +132,9 @@ public class Loader implements Listener { continue; } } - list.add(new SWListInv.SWListEntry<>(element.menu(p), element)); + SWItem item = element.menu(p); + item.setLore(Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_MODES", p, elements.size()), "§8", BauSystem.MESSAGE.parse("LOADER_GUI_CLICK_TO_EDIT", p))); + list.add(new SWListInv.SWListEntry<>(item, element)); } SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("LOADER_GUI_TITLE", p), false, list, (clickType, loaderElement) -> {}); swListInv.setCallback((clickType, entry) -> entry.click(p, swListInv::open)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java index f2a63b69..be62173c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java @@ -30,7 +30,7 @@ public interface ElementSettings { default void playerInteract() {} - default String translateItemName(String name, String mode, Player player) { - return BauSystem.MESSAGE.parse("LOADER_GUI_ITEM_NAME", player, BauSystem.MESSAGE.parse(name, player), BauSystem.MESSAGE.parse(mode, player)); + default String translateItemName(String name, String mode, Player player, Object... args) { + return BauSystem.MESSAGE.parse("LOADER_GUI_ITEM_NAME", player, BauSystem.MESSAGE.parse(name, player), BauSystem.MESSAGE.parse(mode, player, args)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java index f81236c7..42d1909f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java @@ -148,9 +148,7 @@ public class LoaderDaylightDetector extends LoaderInteractionElement {}).getItemStack(), clickType -> { + swInventory.setItem(12, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { ticks -= clickType.isShiftClick() ? 5 : 1; if (ticks < 1) ticks = 1; swInventory.setItem(13, item(player)); }); swInventory.setItem(13, item(player).getItemStack(), clickType -> { - SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Ticks", ticks + ""); + SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_NAME", player), ticks + ""); swAnvilInv.setCallback(s -> { try { ticks = Long.parseLong(s); @@ -175,7 +175,7 @@ public class LoaderMovement extends LoaderInteractionElement {}).getItemStack(), clickType -> { + swInventory.setItem(14, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { ticks += clickType.isShiftClick() ? 5 : 1; swInventory.setItem(13, item(player)); }); @@ -205,25 +205,23 @@ public class LoaderMovement extends LoaderInteractionElement backAction.run()); - swInventory.setItem(3, new SWItem(SWItem.getDye(1), "§c-1", Arrays.asList("§7Shift: §c-5"), false, clickType -> {}).getItemStack(), clickType -> { + swInventory.setItem(3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { delay -= clickType.isShiftClick() ? 5 : 1; if (delay < 0) delay = 0; swInventory.setItem(4, menu(player)); }); swInventory.setItem(4, menu(player).getItemStack(), clickType -> { - SWAnvilInv swAnvilInv = new SWAnvilInv(player, "§7Wartezeit", delay + ""); + SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_SETTING_WAIT_NAME", player), delay + ""); swAnvilInv.setCallback(s -> { try { delay = Long.parseLong(s); @@ -84,7 +84,7 @@ public class LoaderWait implements LoaderElement, Listener { }); swAnvilInv.open(); }); - swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§a+1", Arrays.asList("§7Shift: §a+5"), false, clickType -> {}).getItemStack(), clickType -> { + swInventory.setItem(5, new SWItem(SWItem.getDye(10), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_ADD_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> { delay += clickType.isShiftClick() ? 5 : 1; swInventory.setItem(4, menu(player)); }); -- 2.39.2 From f6357c2a376b401411fb1b8b725f1d24e3db28ad Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 9 May 2023 18:31:03 +0200 Subject: [PATCH 17/17] Fix package name Signed-off-by: yoyosource --- .../bausystem/features/{loadern => loader}/Loader.java | 8 ++++---- .../features/{loadern => loader}/LoaderCommand.java | 2 +- .../features/{loadern => loader}/LoaderRecorder.java | 6 +++--- .../{loadern => loader}/LoaderScoreboardElement.java | 2 +- .../{loadern => loader}/elements/ElementSettings.java | 2 +- .../{loadern => loader}/elements/LoaderElement.java | 2 +- .../elements/LoaderInteractionElement.java | 2 +- .../elements/impl/LoaderComparator.java | 6 +++--- .../elements/impl/LoaderDaylightDetector.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderLectern.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderLever.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderMovement.java | 6 +++--- .../elements/impl/LoaderNoteBlock.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderOpenable.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderRepeater.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderTNT.java | 4 ++-- .../{loadern => loader}/elements/impl/LoaderTicks.java | 6 +++--- .../{loadern => loader}/elements/impl/LoaderWait.java | 4 ++-- .../bausystem/features/script/variables/Constants.java | 2 +- 19 files changed, 44 insertions(+), 44 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/Loader.java (97%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/LoaderCommand.java (98%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/LoaderRecorder.java (97%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/LoaderScoreboardElement.java (97%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/ElementSettings.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/LoaderElement.java (94%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/LoaderInteractionElement.java (98%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderComparator.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderDaylightDetector.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderLectern.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderLever.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderMovement.java (97%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderNoteBlock.java (95%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderOpenable.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderRepeater.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderTNT.java (94%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderTicks.java (96%) rename BauSystem_Main/src/de/steamwar/bausystem/features/{loadern => loader}/elements/impl/LoaderWait.java (96%) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index 612ebd28..6b61f14f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -17,12 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern; +package de.steamwar.bausystem.features.loader; 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.features.loader.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT; +import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait; import de.steamwar.bausystem.shared.EnumDisplay; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java similarity index 98% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index 070b2e95..ee03be16 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern; +package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java index 135cd7ac..f42ad0db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java @@ -17,12 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern; +package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.loadern.elements.LoaderElement; -import de.steamwar.bausystem.features.loadern.elements.impl.*; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.impl.*; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java index e9fc9004..b3e2ba2f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/LoaderScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern; +package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java index be62173c..7650878c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/ElementSettings.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/ElementSettings.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements; +package de.steamwar.bausystem.features.loader.elements; import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java similarity index 94% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java index 4b1734bd..eb173dc5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderElement.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements; +package de.steamwar.bausystem.features.loader.elements; import de.steamwar.inventory.SWItem; import org.bukkit.entity.Player; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java similarity index 98% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java index eabd054f..dad60ebf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/LoaderInteractionElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/LoaderInteractionElement.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements; +package de.steamwar.bausystem.features.loader.elements; import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java index 25f874c3..fef006f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderComparator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderComparator.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java index 42d1909f..10c2b74c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderDaylightDetector.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderDaylightDetector.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java index 5ed7cfdf..b2cf3ff4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLectern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLectern.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java index 1e20094c..911daf57 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderLever.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderLever.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java index 00d6855d..55c41fd7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderMovement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderMovement.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java index 40a7a198..b8c04fe8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderNoteBlock.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderNoteBlock.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Instrument; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java index a63cbdb1..de4abe42 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderOpenable.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderOpenable.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java index b73f3a56..26234c54 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderRepeater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderRepeater.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java similarity index 94% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java index 929b14c2..6c95bf71 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTNT.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTNT.java @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java index 6f09ba4a..098d29ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderTicks.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderTicks.java @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.ElementSettings; -import de.steamwar.bausystem.features.loadern.elements.LoaderInteractionElement; +import de.steamwar.bausystem.features.loader.elements.ElementSettings; +import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java index 2dc8eb19..0c694a87 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadern/elements/impl/LoaderWait.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/elements/impl/LoaderWait.java @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.loadern.elements.impl; +package de.steamwar.bausystem.features.loader.elements.impl; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.loadern.elements.LoaderElement; +import de.steamwar.bausystem.features.loader.elements.LoaderElement; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; 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 10d4a75d..e0ec0872 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.loadern.Loader; +import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tracer.record.ActiveTracer; -- 2.39.2