From de28cc9c1d9ae297f64760c6126bb436bf8f580d Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 8 Feb 2021 20:48:45 +0100 Subject: [PATCH] Fix pr stuff --- .../src/de/steamwar/bausystem/world/TNTSimulator.java | 8 +++++--- .../de/steamwar/bausystem/world/TNTSimulatorListener.java | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java index 82f4812..98f7cb6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java @@ -50,6 +50,7 @@ public class TNTSimulator { static final Map TNT_SIMULATOR_MAP = new HashMap<>(); private final Set TNT_SPAWNS = new HashSet<>(); + private int number = 0; public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eKanonensimulator", Arrays.asList("§eRechtsklick Block §8- §7Füge einen TNT hinzu", "§eRechtsklick Luft §8- §7Öffne den Simulator", "§eLinksklick §8- §7Starte die Simulation"), false, null).getItemStack(); @@ -84,8 +85,8 @@ public class TNTSimulator { openSimulator(player); })); swListInv.setItem(47, new SWItem(Material.FLINT_AND_STEEL, "§eSimulation starten", clickType -> { - startSimulation(player); player.closeInventory(); + startSimulation(player); })); swListInv.open(); } @@ -108,7 +109,6 @@ public class TNTSimulator { swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> { SWAnvilInv tntSimulatorAnvil = new SWAnvilInv(player, "Name", tntSpawn.getName()); tntSimulatorAnvil.setCallback(s -> { - if (s.startsWith("»")) s = s.substring(1); tntSpawn.setName(s); editTNT(player, tntSpawn); }); @@ -262,7 +262,9 @@ public class TNTSimulator { } static void addTNT(Player player, TNTSpawn tntSpawn) { - TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator()).TNT_SPAWNS.add(tntSpawn); + TNTSimulator tntSimulator = TNT_SIMULATOR_MAP.computeIfAbsent(player, player1 -> new TNTSimulator()); + if (tntSpawn.name.isEmpty()) tntSpawn.name = (++tntSimulator.number) + ""; + tntSimulator.TNT_SPAWNS.add(tntSpawn); } private static String active(boolean b) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java index b6e26b6..a0210ac 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulatorListener.java @@ -47,8 +47,12 @@ public class TNTSimulatorListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (event.getItem() == null) return; - if (!event.getItem().isSimilar(WAND)) return; + if (event.getItem() == null) { + return; + } + if (!event.getItem().isSimilar(WAND)) { + return; + } event.setCancelled(true); if (!permissionCheck(event.getPlayer())) { return;