Fix more scoreboard crashing and oddities (#1665)

* Various fixes

* Apply updateType fix as well

* Slight optimization
This commit is contained in:
Camotoy 2020-12-14 18:22:31 -05:00 committed by GitHub
parent feaaf9edec
commit 55cf7d1c54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -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) {

View file

@ -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());
}