made score staying the highest ever reached

This commit is contained in:
2025-12-24 00:49:50 +01:00
parent fc502e3da8
commit 2ca97c88fc

View File

@@ -53,9 +53,6 @@ public class EventScoreboardBuilder {
objective.numberFormat(NumberFormat.blank());
UUID uuid = p.getUniqueId();
scoreList.removeIf(e -> e.playerUuid().equals(uuid));
scoreList.add(new EventScoreEntry(uuid, p.getName(), this.scorable.getScore(p)));
scoreList.sort(this.scoreComparator);
int size = scoreList.size();
@@ -140,8 +137,19 @@ public class EventScoreboardBuilder {
}
private void updateScore(Player p) {
this.playerScores.removeIf(entry -> entry.playerUuid().equals(p.getUniqueId()));
this.playerScores.add(new EventScoreEntry(p.getUniqueId(), p.getName(), this.scorable.getScore(p)));
EventScoreEntry previousEntry = this.playerScores.stream()
.filter(entry -> entry.playerUuid().equals(p.getUniqueId()))
.findFirst()
.orElse(null);
if(previousEntry == null) {
this.playerScores.add(new EventScoreEntry(p.getUniqueId(), p.getName(), this.scorable.getScore(p)));
return;
}
int currentScore = this.scorable.getScore(p);
if(previousEntry.score() < currentScore) {
this.playerScores.removeIf(entry -> entry.playerUuid().equals(p.getUniqueId()));
this.playerScores.add(new EventScoreEntry(p.getUniqueId(), p.getName(), currentScore));
}
}
public void updateScoreboards() {