From 07a1dd719517ad519becc7335b39b6c1b752488c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 21 Jul 2022 14:32:32 +0200 Subject: [PATCH] Update stuff Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 1 + BauSystem_Main/src/BauSystem_de.properties | 1 + .../features/simulator/SimulatorCursor.java | 4 +++ .../features/simulator/SimulatorStorage.java | 2 +- .../features/simulator/TNTSimulator.java | 4 +++ .../simulator/TNTSimulatorListener.java | 28 +++++++++++-------- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index fc7fc8d9..c5c1c613 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -529,6 +529,7 @@ SIMULATOR_WAND_LORE_1 = §eRight click §8- §7adds a position SIMULATOR_WAND_LORE_2 = §eSneaking §8- §7Free movement SIMULATOR_WAND_LORE_3 = §eLeft click §8- §7Start the simulation SIMULATOR_WAND_LORE_4 = §eRight click in air §8- §7Opens the gui +SIMULATOR_WAND_LORE_5 = §eOffhand §8- §7Simulator preview SIMULATOR_REGION_FROZEN = §cSimulator cannot be used inside frozen regions diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 4b500f14..a2b671bc 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -530,6 +530,7 @@ SIMULATOR_WAND_LORE_1 = §eRechtsklick §8- §7Füge eine Position hinzu SIMULATOR_WAND_LORE_2 = §eSneaken §8- §7Freie Bewegung SIMULATOR_WAND_LORE_3 = §eLinksklick §8- §7Starte die Simulation SIMULATOR_WAND_LORE_4 = §eRechtsklick Luft §8- §7Öffne die GUI +SIMULATOR_WAND_LORE_5 = §eOffhand §8- §7Simulator Vorschau SIMULATOR_REGION_FROZEN = §cSimulator kann nicht in eingefrorenen Regionen genutzt werden 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 0918d7c6..fcc11942 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -60,6 +60,10 @@ public class SimulatorCursor { return; } + if (SimulatorStorage.getSimulator(player.getInventory().getItemInOffHand()) != null && result.getHitPosition().distanceSquared(player.getLocation().toVector()) < 25) { + return; + } + cursor = SimulatorEntityShowMode.createEntity(getPos(player, result), false); cursor.display(player); cursors.put(player, cursor); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java index 15f01945..d22a9c4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java @@ -123,7 +123,7 @@ public class SimulatorStorage implements Enable, Disable { } public static ItemStack getWand(Player p) { - ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p)), false, null).getItemStack(); + ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_5", p)), false, null).getItemStack(); ItemUtils.setItem(itemStack, "simulator"); return itemStack; } 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 c660e0b4..210c66f5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -204,6 +204,10 @@ public class TNTSimulator { return; } + if (SimulatorStorage.getSimulator(player.getInventory().getItemInOffHand()) != null && result.getHitPosition().distanceSquared(player.getLocation().toVector()) < 25) { + return; + } + TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result)); tntElementList.add(tntElement); TNTElementGUI.open(player, tntElement, null); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java index 1c010766..4be1c2ed 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java @@ -22,14 +22,8 @@ package de.steamwar.bausystem.features.simulator; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.shared.Pair; -import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.utils.ItemUtils; import org.bukkit.Bukkit; import org.bukkit.FluidCollisionMode; @@ -103,8 +97,11 @@ public class TNTSimulatorListener implements Listener { public void onPlayerMove(PlayerMoveEvent e) { if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) { simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo()); + TNTSimulator tntSimulator = SimulatorStorage.getSimulator(e.getPlayer().getInventory().getItemInOffHand()); + if (tntSimulator != null) SimulatorPreviewStorage.hide(e.getPlayer()); } else { - simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getTo()); + TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getTo()); + if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator); } } @@ -118,16 +115,25 @@ public class TNTSimulatorListener implements Listener { simulatorShowHide(e.getPlayer(), i -> e.getItemDrop().getItemStack(), i -> null, e.getPlayer().getLocation()); } - private void simulatorShowHide(Player player, Function oldItemFunction, Function newItemFunction, Location location) { + private TNTSimulator simulatorShowHide(Player player, Function oldItemFunction, Function newItemFunction, Location location) { TNTSimulator oldSimulator = SimulatorStorage.getSimulator(oldItemFunction.apply(player.getInventory())); SimulatorCursor.hide(player, oldSimulator); TNTSimulator simulator = SimulatorStorage.getSimulator(newItemFunction.apply(player.getInventory())); - if (simulator == null) { - return; - } + if (simulator == null) return null; SimulatorCursor.show(player, simulator, trace(player, location, simulator)); + return simulator; + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent e) { + if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) { + simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation()); + } else { + TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation()); + if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator); + } } @EventHandler