aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/cowtipper/cowlection/handler
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-09-25 01:20:43 +0200
committerCow <cow@volloeko.de>2020-09-25 01:20:43 +0200
commiteec706e604c86747d2d0d8f2a7d1bd3f964cfbb6 (patch)
tree8ee1c1291aff23ab550a473627d7f5de678d7fa7 /src/main/java/de/cowtipper/cowlection/handler
parent574247ab30050f2b3cf6b32c7057b4106996bc12 (diff)
downloadCowlection-eec706e604c86747d2d0d8f2a7d1bd3f964cfbb6.tar.gz
Cowlection-eec706e604c86747d2d0d8f2a7d1bd3f964cfbb6.tar.bz2
Cowlection-eec706e604c86747d2d0d8f2a7d1bd3f964cfbb6.zip
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
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/handler')
-rw-r--r--src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java20
1 files changed, 19 insertions, 1 deletions
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<String, Integer> deathCounter;
+ private final Set<String> deadPlayers;
private final Set<String> failedPuzzles;
private final Set<UUID> 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;
}
}