From 75f11561b77761a460188a0ff2c2014fafc63897 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 1 Dec 2021 20:26:56 +0100 Subject: [PATCH] Update BlockCounter Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 2 +- .../features/testblock/blockcounter/BlockCount.java | 6 ++++-- .../features/testblock/blockcounter/BlockCounter.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index ed25a20d..8c9a45e7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -514,7 +514,7 @@ SMART_PLACE_DISABLE = §cSmartPlace deaktiviert BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus -BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke Schaden am Testblock +BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke Schaden §e{1} §7TNT §e{2} §7Blöcke/TNT BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java index 503ea661..5b42ea59 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java @@ -39,6 +39,7 @@ public class BlockCount { private Region region; private int count = 0; + private int tntCount = 0; private long lastUpdate = TPSUtils.currentTick.get(); @@ -49,13 +50,13 @@ public class BlockCount { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { Set toRemove = new HashSet<>(); for (BlockCount blockCount : BlockCounter.blockCountMap.values()) { - if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 20) { + if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 40) { continue; } toRemove.add(region); if (count > 10) { - RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count)); + RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, (double) blockCount.count / blockCount.tntCount)); } } toRemove.forEach(BlockCounter.blockCountMap::remove); @@ -69,6 +70,7 @@ public class BlockCount { public void update(List blocks) { count += blocks.size(); + tntCount++; lastUpdate = TPSUtils.currentTick.get(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java index e9464e95..ac2321ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java @@ -48,9 +48,9 @@ public class BlockCounter { Config.getInstance().get(p).put("blockCounter", false); } - public String getMessage(Player player, int count) { + public String getMessage(Player player, int count, int tntCount, double countPerTNT) { if (isActive(player)) { - return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE", player, count); + return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0); } return null; }