diff --git a/connector/src/main/java/org/geysermc/connector/scoreboard/Objective.java b/connector/src/main/java/org/geysermc/connector/scoreboard/Objective.java index 41d35d42f..5a7748f79 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/Objective.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/Objective.java @@ -150,20 +150,6 @@ public final class Objective { updateType = UpdateType.REMOVE; } - public ScoreboardPosition getPositionCategory() { - return switch (displaySlot) { - case PLAYER_LIST -> ScoreboardPosition.PLAYER_LIST; - case BELOW_NAME -> ScoreboardPosition.BELOW_NAME; - default -> ScoreboardPosition.SIDEBAR; - }; - } - - public boolean hasTeamColor() { - return displaySlot != ScoreboardPosition.PLAYER_LIST && - displaySlot != ScoreboardPosition.BELOW_NAME && - displaySlot != ScoreboardPosition.SIDEBAR; - } - public TeamColor getTeamColor() { return switch (displaySlot) { case SIDEBAR_TEAM_RED -> TeamColor.RED; 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 c32353b78..682ff8331 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java @@ -104,7 +104,7 @@ public final class Scoreboard { Objective storedObjective = objectiveSlots.get(displaySlot); if (storedObjective != null && storedObjective != objective) { - objective.pendingRemove(); + storedObjective.pendingRemove(); } objectiveSlots.put(displaySlot, objective); @@ -166,6 +166,12 @@ public final class Scoreboard { correctSidebar = objectiveSlots.get(ScoreboardPosition.SIDEBAR); } + for (Objective objective : removedObjectives) { + // Deletion must be handled before the active objectives are handled - otherwise if a scoreboard display is changed before the current + // scoreboard is removed, the client can crash + deleteObjective(objective, true); + } + handleObjective(objectiveSlots.get(ScoreboardPosition.PLAYER_LIST), addScores, removeScores); handleObjective(correctSidebar, addScores, removeScores); handleObjective(objectiveSlots.get(ScoreboardPosition.BELOW_NAME), addScores, removeScores); @@ -194,10 +200,6 @@ public final class Scoreboard { session.sendUpstreamPacket(setScorePacket); } - for (Objective objective : removedObjectives) { - deleteObjective(objective, true); - } - lastAddScoreCount = addScores.size(); lastRemoveScoreCount = removeScores.size(); }