From 55cf7d1c540064eb7df18d8f50dc86734954667d Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Mon, 14 Dec 2020 18:22:31 -0500 Subject: [PATCH] Fix more scoreboard crashing and oddities (#1665) * Various fixes * Apply updateType fix as well * Slight optimization --- .../org/geysermc/connector/scoreboard/Score.java | 12 +++++++++--- .../geysermc/connector/scoreboard/Scoreboard.java | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/scoreboard/Score.java b/connector/src/main/java/org/geysermc/connector/scoreboard/Score.java index e5f97b459..668cd73dc 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/Score.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/Score.java @@ -36,8 +36,14 @@ public final class Score { private final String name; private ScoreInfo cachedInfo; - private ScoreData currentData; - private ScoreData cachedData; + /** + * Changes that have been made since the last cached data. + */ + private Score.ScoreData currentData; + /** + * The data that is currently displayed to the Bedrock client. + */ + private Score.ScoreData cachedData; public Score(long id, String name) { this.id = id; @@ -79,7 +85,7 @@ public final class Score { } public UpdateType getUpdateType() { - return cachedData != null ? cachedData.updateType : currentData.updateType; + return currentData.updateType; } public Score setUpdateType(UpdateType updateType) { diff --git a/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java b/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java index 8eaa2e277..a389a373b 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java @@ -189,7 +189,10 @@ public final class Scoreboard { remove = false; } - if (score.shouldUpdate()) { + if (objectiveRemove && score.getCachedData() != null) { + // This score has been sent to the client and needs to be removed since the objective is being removed + remove = true; + } else if (score.shouldUpdate()) { score.update(objective.getObjectiveName()); }