From eec706e604c86747d2d0d8f2a7d1bd3f964cfbb6 Mon Sep 17 00:00:00 2001 From: Cow Date: Fri, 25 Sep 2020 01:20:43 +0200 Subject: Various small feature fixes - Auctions per item prices: now working when creating a new auction - Dungeon party finder: entered vs queued floor wasn't detected correctly - A dead player leaving a SkyBlock dungeon counted twice --- .../cowtipper/cowlection/handler/DungeonCache.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main/java/de/cowtipper/cowlection/handler') diff --git a/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java b/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java index 07a1fe4..d7fd5da 100644 --- a/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java +++ b/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java @@ -15,6 +15,7 @@ import java.util.stream.Collectors; public class DungeonCache { private final Cowlection main; private final Map deathCounter; + private final Set deadPlayers; private final Set failedPuzzles; private final Set destroyedCrypts; @@ -22,11 +23,13 @@ public class DungeonCache { private int elapsedMinutes; private int classMilestone; private long lastScoreboardCheck; + private long nextPerformanceSend; private String queuedFloor; public DungeonCache(Cowlection main) { this.main = main; deathCounter = new HashMap<>(); + deadPlayers = new HashSet<>(); failedPuzzles = new HashSet<>(); destroyedCrypts = new HashSet<>(); } @@ -58,6 +61,10 @@ public class DungeonCache { } public void sendDungeonPerformance() { + if (System.currentTimeMillis() < nextPerformanceSend) { + // already sent dungeon performance less than 260ms ago + return; + } String dungeonPerformance; boolean hasPointPenalty = false; if (deathCounter.isEmpty()) { @@ -77,6 +84,7 @@ public class DungeonCache { dungeonPerformance += "\n" + EnumChatFormatting.LIGHT_PURPLE + "➜ " + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "Skill " + EnumChatFormatting.RED + "score penalty: " + EnumChatFormatting.DARK_RED + getSkillScorePenalty() + " points"; } main.getChatHelper().sendMessage(EnumChatFormatting.WHITE, dungeonPerformance); + nextPerformanceSend = System.currentTimeMillis() + 260; } public void updateElapsedMinutesFromScoreboard() { @@ -117,13 +125,21 @@ public class DungeonCache { this.queuedFloor = floorNr; } - public void addDeath(String playerName) { + public void addDeath(String playerName, boolean ghostByDisconnecting) { + if (!deadPlayers.add(playerName) && ghostByDisconnecting) { + // dead player disconnected from the game; don't count again! + return; + } int previousPlayerDeaths = deathCounter.getOrDefault(playerName, 0); deathCounter.put(playerName, previousPlayerDeaths + 1); new TickDelay(this::sendDungeonPerformance, 1); } + public void revivedPlayer(String playerName) { + deadPlayers.remove(playerName); + } + public void addFailedPuzzle(String text) { failedPuzzles.add(text); } @@ -176,10 +192,12 @@ public class DungeonCache { // resetter private void resetCounters() { deathCounter.clear(); + deadPlayers.clear(); failedPuzzles.clear(); destroyedCrypts.clear(); elapsedMinutes = 0; classMilestone = 0; + nextPerformanceSend = 0; queuedFloor = null; } } -- cgit