From 0895757971c0153ef60f0961b956f139f35d9055 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 1 Dec 2021 20:40:21 +0100 Subject: [PATCH] Update BlockCounter.getMessage Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 2 +- .../features/testblock/blockcounter/BlockCount.java | 5 +++-- .../features/testblock/blockcounter/BlockCounter.java | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 8c9a45e7..69ab30c5 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 §e{1} §7TNT §e{2} §7Blöcke/TNT +BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke Schaden §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s 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 5b42ea59..38c1425a 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 @@ -40,6 +40,7 @@ public class BlockCount { private Region region; private int count = 0; private int tntCount = 0; + private final long tick = TPSUtils.currentTick.get(); private long lastUpdate = TPSUtils.currentTick.get(); @@ -50,13 +51,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 < 40) { + if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 60) { continue; } toRemove.add(region); if (count > 10) { - RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, (double) blockCount.count / blockCount.tntCount)); + RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, blockCount.tick, blockCount.lastUpdate)); } } toRemove.forEach(BlockCounter.blockCountMap::remove); 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 5a625faa..0b90666a 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,11 @@ public class BlockCounter { Config.getInstance().get(p).put("blockCounter", false); } - public String getMessage(Player player, int count, int tntCount, double countPerTNT) { + public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) { + double countPerTNT = (double) count / tntCount; + double countPerTick = (double) count / Math.max((lastTick - tick), 1); if (isActive(player)) { - return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0); + return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 10) / 200.0); } return null; }