SteamWar/BauSystem2.0
Archiviert
12
0

Update BlockCounter.getMessage
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-01 20:40:21 +01:00
Ursprung 17d869203d
Commit 0895757971
3 geänderte Dateien mit 8 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -514,7 +514,7 @@ SMART_PLACE_DISABLE = §cSmartPlace deaktiviert
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus 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_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus 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_ENABLE = §7BlockCounter angemacht
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht

Datei anzeigen

@ -40,6 +40,7 @@ public class BlockCount {
private Region region; private Region region;
private int count = 0; private int count = 0;
private int tntCount = 0; private int tntCount = 0;
private final long tick = TPSUtils.currentTick.get();
private long lastUpdate = TPSUtils.currentTick.get(); private long lastUpdate = TPSUtils.currentTick.get();
@ -50,13 +51,13 @@ public class BlockCount {
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
Set<Region> toRemove = new HashSet<>(); Set<Region> toRemove = new HashSet<>();
for (BlockCount blockCount : BlockCounter.blockCountMap.values()) { for (BlockCount blockCount : BlockCounter.blockCountMap.values()) {
if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 40) { if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 60) {
continue; continue;
} }
toRemove.add(region); toRemove.add(region);
if (count > 10) { 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); toRemove.forEach(BlockCounter.blockCountMap::remove);

Datei anzeigen

@ -48,9 +48,11 @@ public class BlockCounter {
Config.getInstance().get(p).put("blockCounter", false); 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)) { 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; return null;
} }