From bd7c13dfd7cc049c487606b8f36894c580bf2cb7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 10 Jun 2022 22:56:28 +0200 Subject: [PATCH] Fix stuff and fix bugs Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 1 - BauSystem_Main/src/BauSystem_de.properties | 1 - .../simulator/AbstractSimulatorEntity.java | 38 +++++++++++++++++++ .../features/simulator/SimulatorCursor.java | 4 +- .../features/simulator/TNTSimulator.java | 4 +- .../features/simulator/gui/TNTElementGUI.java | 2 +- .../simulator/gui/TNTSimulatorGui.java | 8 ++-- 7 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 00980ba4..7bcff795 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -593,7 +593,6 @@ SIMULATOR_MATERIAL_NAME = §e{0} SIMULATOR_MATERIAL_NAME_LORE = §7Material §8- §e{0} SIMULATOR_MATERIAL_CLICK = §eClick to choose SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE = §eAdd prime phase -SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT = §eShift-Click§8: §7Add prime phase with 1 tick offset SIMULATOR_TNT_SPAWN_ADD_TNT = §eAdd TNT SIMULATOR_TNT_SPAWN_REMOVE_TNT = §cRemove SIMULATOR_TNT_SPAWN_POSITION_ANVIL_GUI_NAME = Position diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index ddc061ea..bcf62f73 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -581,7 +581,6 @@ SIMULATOR_TNT_SPAWN_MATERIAL_LORE_3 = §eRechts-Click §7Zum zurücksetzten SIMULATOR_MATERIAL_GUI_NAME = Material ändern SIMULATOR_MATERIAL_CLICK = §eKlicken zum wählen SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE = §eZündphase hinzufügen -SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT = §eShift-Click§8: §7Zündphase hinzufügen und +1 Tick Offset SIMULATOR_TNT_SPAWN_ADD_TNT = §eTNT hinzufügen SIMULATOR_TNT_SPAWN_REMOVE_TNT = §cEntfernen SIMULATOR_TNT_SPAWN_POSITION_ANVIL_GUI_NAME = Position diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java new file mode 100644 index 00000000..faf81588 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java @@ -0,0 +1,38 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 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.simulator; + +import de.steamwar.bausystem.shared.AbstractEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public interface AbstractSimulatorEntity extends AbstractEntity { + + void display(Player player); + + void setPosition(Vector position); + + boolean hide(Player player, boolean always); + + int getId(); + + Entity getBukkitEntity(); +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index 50ba17c0..7f8a670f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -54,14 +54,14 @@ public class SimulatorCursor { List elements = tntSimulator.getEntity(result.getHitEntity()); tntSimulator.hide(player, elements); - cursor = SimulatorEntityShowMode.createEntity(player, elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition(), true); + cursor = SimulatorEntityShowMode.createEntity(elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition(), true); cursor.display(player); cursors.put(player, cursor); BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR); return; } - cursor = SimulatorEntityShowMode.createEntity(player, getPos(player, result), false); + cursor = SimulatorEntityShowMode.createEntity(getPos(player, result), false); cursor.display(player); cursors.put(player, cursor); BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 65185f18..ee73a8c3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -152,7 +152,7 @@ public class TNTSimulator { public void edit(Player player, RayTraceResult result) { if (result == null) { - TNTSimulatorGui.open(player, this, null, getTntElementList(), null); + TNTSimulatorGui.open(player, this, null, this::getTntElementList, null); return; } @@ -165,7 +165,7 @@ public class TNTSimulator { if (elements.size() == 1) { TNTElementGUI.open(player, (TNTElement) elements.get(0), null); } else { - TNTSimulatorGui.open(player, null, null, elements, null); + TNTSimulatorGui.open(player, null, null, () -> elements, null); } return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java index 29412935..ae40232f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java @@ -360,7 +360,7 @@ public class TNTElementGUI { })); if (!tntElement.hasParent()) { - inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE_SHIFT", player)), false, clickType -> { + inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> { // Create TNTGroup tntSimulator.getTntElementList().remove(tntElement); Vector vector = tntElement.getOwnPosition().clone(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java index 8731af59..2016bd67 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java @@ -32,22 +32,22 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; @UtilityClass public class TNTSimulatorGui { - public void open(Player player, TNTSimulator currentTntSimulator, TNTGroup currentTntGroup, List simulatorElements, Runnable back) { + public void open(Player player, TNTSimulator currentTntSimulator, TNTGroup currentTntGroup, Supplier> simulatorElements, Runnable back) { List> swListEntryList = new ArrayList<>(); - for (SimulatorElement element : simulatorElements) { + for (SimulatorElement element : simulatorElements.get()) { swListEntryList.add(new SWListInv.SWListEntry<>(element.menu(player), element)); } SWListInv inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_NAME", player), false, swListEntryList, (clickType, simulatorElement) -> { if (simulatorElement instanceof TNTGroup) { TNTGroup tntGroup = (TNTGroup) simulatorElement; - List elements = new ArrayList<>(tntGroup.getElements()); - open(player, null, tntGroup, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); + open(player, null, tntGroup, () -> new ArrayList<>(tntGroup.getElements()), () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); } else { TNTElementGUI.open(player, (TNTElement) simulatorElement, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); }