The bug
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but does not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
How to reproduce
Add scoreboard objective
/scoreboard objectives add test triggerSet sidebar display
/scoreboard objectives setdisplay sidebar testEnable trigger
/scoreboard players enable @a testNotice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]Remove scoreboard display
/scoreboard objectives setdisplay sidebarPut back display
/scoreboard objectives setdisplay sidebar testNotice score is now displaying as 0 for player
Code analysis
The problem is that the game creates a Score object when enabling a trigger for a player who has no score. As the score value inside the Score object is stored as an int, its default value is 0 (see MC-107049). Creating a Score object does not send a packet to the player. Changing this would cause the server to send a packet twice is you set a value for a player who had no Score object before, which could cause problems. A solution might be to store the score as an Integer. Then the default value would be null. Some methods would need to be changed then to test if the player has a Score object and the score value is not null instead of testing if the Score object is null.
A problem which should appear already is that using /scoreboard players reset also disables the trigger as it removes the Score object. With the suggested change a parameter like resetScore could be added which only sets the score of the Score object to null and by that remains the trigger state.
The problem is that the game creates a
Scoreobject when enabling a trigger for a player who has no score. As the score value inside theScoreobject is stored as anint, its default value is 0 (see MC-107049). Creating aScoreobject does not send a packet to the player. Changing this would cause the server to send a packet twice is you set a value for a player who had noScoreobject before, which could cause problems. A solution might be to store the score as anInteger. Then the default value would benull. Some methods would need to be changed then to test if the player has aScoreobject and the score value is notnullinstead of testing if theScoreobject isnull.A problem which should appear already is that using
/scoreboard players resetalso disables the trigger as it removes theScoreobject. With the suggested change a parameter likeresetScorecould be added which only sets the score of theScoreobject tonulland by that remains the trigger state.