forked from GeyserMC/Geyser
		
	Fix more scoreboard crashing and oddities (#1665)
* Various fixes * Apply updateType fix as well * Slight optimization
This commit is contained in:
		
							parent
							
								
									feaaf9edec
								
							
						
					
					
						commit
						55cf7d1c54
					
				
					 2 changed files with 13 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue