made score staying the highest ever reached
This commit is contained in:
@@ -53,9 +53,6 @@ public class EventScoreboardBuilder {
|
|||||||
objective.numberFormat(NumberFormat.blank());
|
objective.numberFormat(NumberFormat.blank());
|
||||||
|
|
||||||
UUID uuid = p.getUniqueId();
|
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);
|
scoreList.sort(this.scoreComparator);
|
||||||
|
|
||||||
int size = scoreList.size();
|
int size = scoreList.size();
|
||||||
@@ -140,8 +137,19 @@ public class EventScoreboardBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateScore(Player p) {
|
private void updateScore(Player p) {
|
||||||
this.playerScores.removeIf(entry -> entry.playerUuid().equals(p.getUniqueId()));
|
EventScoreEntry previousEntry = this.playerScores.stream()
|
||||||
this.playerScores.add(new EventScoreEntry(p.getUniqueId(), p.getName(), this.scorable.getScore(p)));
|
.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() {
|
public void updateScoreboards() {
|
||||||
|
|||||||
Reference in New Issue
Block a user