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 ff545a86..2f4b0f8b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -141,8 +141,7 @@ public class SimulatorCursor implements Listener { public synchronized void calcCursor(Player player) { if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) { - if (removeCursor(player)) { - SimulatorWatcher.show(null, player); + if (removeCursor(player) || SimulatorWatcher.show(null, player)) { SWUtils.sendToActionbar(player, ""); } return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java index 4ea413d8..d5f98986 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorWatcher.java @@ -41,6 +41,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.util.Vector; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @UtilityClass @@ -104,15 +105,18 @@ public class SimulatorWatcher { return server; } - public synchronized void show(Simulator sim, Player player) { + public synchronized boolean show(Simulator sim, Player player) { + AtomicBoolean removed = new AtomicBoolean(); entityServers.forEach((simulator, rEntityServer) -> { if (rEntityServer == null) return; if (rEntityServer.getPlayers().contains(player) && sim != simulator) { rEntityServer.removePlayer(player); + removed.set(true); } }); - if (sim == null) return; + if (sim == null) return removed.get(); entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player); + return removed.get(); } synchronized List getEntitiesOfSimulator(Simulator simulator) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java index 07f55a73..70a1bf9c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java @@ -76,7 +76,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { //Tick Offset int offset = redstone.getTickOffset(); - inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { + inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { redstone.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1)); SimulatorWatcher.update(simulator); }); @@ -90,16 +90,16 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { }, this).setItem(Material.REPEATER).open(); }); offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64))); - inventory.setItem(20, offsetItem); + inventory.setItem(19, offsetItem); - inventory.setItem(29, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { + inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { redstone.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); //Lifetime int lifetime = redstone.getLifetime(); - inventory.setItem(12, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { + inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { redstone.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1)); SimulatorWatcher.update(simulator); }); @@ -113,9 +113,9 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { }, this).setItem(Material.CLOCK).open(); }); lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64))); - inventory.setItem(21, lifetimeItem); + inventory.setItem(20, lifetimeItem); - inventory.setItem(30, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { + inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java index 6541c112..01ec8b04 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java @@ -116,7 +116,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui { inventory.setItem(19, offsetItem); inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { - tnt.setTickOffset(Math.max(1, offset - (clickType.isShiftClick() ? 5 : 1))); + tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); @@ -129,7 +129,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui { SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> { new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> { - if (integer < 0) return false; + if (integer < 1) return false; tnt.setLifetime(integer); SimulatorWatcher.update(simulator); return true;