From e7eb12e4b71372ea4be31e652a6f0bdbb73fbd04 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 Mar 2021 16:59:16 +0100 Subject: [PATCH] Add TNTSimulator count --- .../bausystem/world/TNTSimulator.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java index 7a9fb2d..8da8dd7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java @@ -74,7 +74,9 @@ public class TNTSimulator { lore.add("§7X§8: §e" + tntSpawn.getPosition().getX()); lore.add("§7Y§8: §e" + tntSpawn.getPosition().getY()); lore.add("§7Z§8: §e" + tntSpawn.getPosition().getZ()); - swListEntryList.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, "§eTNT", lore, false, null), tntSpawn)); + SWItem swItem = new SWItem(Material.TNT, "§eTNT", lore, false, null); + swItem.getItemStack().setAmount(tntSpawn.count); + swListEntryList.add(new SWListInv.SWListEntry<>(swItem, tntSpawn)); }); swListEntryList.sort(Comparator.comparing(SWListInv.SWListEntry::getObject)); @@ -114,14 +116,16 @@ public class TNTSimulator { } editTNT(player, tntSpawn); })); - swInventory.setItem(19, new SWItem(Material.TNT, "§7Anzahl §8- §e" + tntSpawn.getCount(), LORE, false, clickType -> { + SWItem countItem = new SWItem(Material.TNT, "§7Anzahl §8- §e" + tntSpawn.getCount(), LORE, false, clickType -> { changeCount(player, "Anzahl TNT", tntSpawn.getCount(), count -> { if (count < 1) count = 1; if (count > 400) count = 400; tntSpawn.setCount(count); editTNT(player, tntSpawn); }, () -> editTNT(player, tntSpawn)); - })); + }); + countItem.getItemStack().setAmount(tntSpawn.getCount()); + swInventory.setItem(19, countItem); swInventory.setItem(28, new SWItem(SWItem.getDye(1), "§7-1", clickType -> { tntSpawn.setCount(tntSpawn.getCount() - 1); if (tntSpawn.getCount() < 1) { @@ -138,14 +142,16 @@ public class TNTSimulator { } editTNT(player, tntSpawn); })); - swInventory.setItem(20, new SWItem(Material.CLOCK, "§7Tick §8- §e" + tntSpawn.getTickOffset(), LORE, false, clickType -> { + SWItem tickItem = new SWItem(Material.CLOCK, "§7Tick §8- §e" + tntSpawn.getTickOffset(), LORE, false, clickType -> { changeCount(player, "Tick Offset", tntSpawn.getTickOffset(), tick -> { if (tick < 0) tick = 0; if (tick > 8000) tick = 8000; tntSpawn.setTickOffset(tick); editTNT(player, tntSpawn); }, () -> editTNT(player, tntSpawn)); - })); + }); + tickItem.getItemStack().setAmount(Math.max(tntSpawn.getTickOffset(), 1)); + swInventory.setItem(20, tickItem); swInventory.setItem(29, new SWItem(SWItem.getDye(1), "§7-1", clickType -> { tntSpawn.setTickOffset(tntSpawn.getTickOffset() - 1); if (tntSpawn.getTickOffset() < 0) { @@ -162,14 +168,16 @@ public class TNTSimulator { } editTNT(player, tntSpawn); })); - swInventory.setItem(21, new SWItem(Material.CLOCK, "§7Fuse-Ticks §8- §e" + tntSpawn.getFuseTicks(), LORE, false, clickType -> { + SWItem fuseTickItem = new SWItem(Material.CLOCK, "§7Fuse-Ticks §8- §e" + tntSpawn.getFuseTicks(), LORE, false, clickType -> { changeCount(player, "Fuse-Ticks", tntSpawn.getFuseTicks(), tick -> { if (tick < 0) tick = 0; if (tick > 80) tick = 80; tntSpawn.setFuseTicks(tick); editTNT(player, tntSpawn); }, () -> editTNT(player, tntSpawn)); - })); + }); + fuseTickItem.getItemStack().setAmount(Math.max(tntSpawn.getFuseTicks(), 1)); + swInventory.setItem(21, fuseTickItem); swInventory.setItem(30, new SWItem(SWItem.getDye(1), "§7-1", clickType -> { tntSpawn.setFuseTicks(tntSpawn.getFuseTicks() - 1); if (tntSpawn.getFuseTicks() < 1) {