Using /trigger first time on player gives score of 0 but not displayed on scoreboard
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 trigger
- Set sidebar display
/scoreboard objectives setdisplay sidebar test
- Enable trigger
/scoreboard players enable @a test
- Notice 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 sidebar
- Put back display
/scoreboard objectives setdisplay sidebar test
- Notice 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.
- Fixed
Onnowhere
[Mojang] Nathan Adams- 7
- 7
- Confirmed
- score scoreboard trigger
1.8.3 - 17w46a
1.8.3 1.8.4 1.8.5 1.8.6 15w45a 15w46a 15w49b 15w50a 15w51b 16w03a 16w04a 16w05a 16w05b 16w06a 16w07a 16w07b 1.9-pre1 1.9-pre2 1.9-pre3 1.9-pre4 1.9 1.9.1-pre1 1.9.1-pre2 1.9.1-pre3 1.9.1 1.9.2 1.9.4 16w21a 1.10-pre2 1.10 16w35a 16w39c 1.11 1.11.2 17w15a 17w16a 1.12-pre2 1.12 1.12.2 17w46a- 17w47a
Created Issue:
using /trigger first time on player gives score of 0 but not displayed on scoreboard
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1. /scoreboard objectives add test trigger
2. /scoreboard objectives setdisplay sidebar test
3. /scoreboard players enable @a test
4. notice score does not display on side bar
5. remove scoreboard display /scoreboard objectives setdisplay sidebar
6. put back display /scoreboard objectives setdisplay sidebar test
7. notice score is now 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1. /scoreboard objectives add test trigger
2. /scoreboard objectives setdisplay sidebar test
3. /scoreboard players enable @a test
4. notice score does not display on side bar
5. remove scoreboard display /scoreboard objectives setdisplay sidebar
6. put back display /scoreboard objectives setdisplay sidebar test
7. notice score is now 0 for playerEnabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2. /scoreboard objectives setdisplay sidebar test
3. /scoreboard players enable @a test
4. notice score does not display on side bar
5. remove scoreboard display /scoreboard objectives setdisplay sidebar
6. put back display /scoreboard objectives setdisplay sidebar test
7. notice score is now 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2. /scoreboard objectives setdisplay sidebar test
3. /scoreboard players enable @a test4. notice score does not display on side bar
5. remove scoreboard display/scoreboard objectives setdisplay sidebar
6. put back display /scoreboard objectives setdisplay sidebar test
7. notice score is now 0 for playerEnabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2.
/scoreboard objectives setdisplay sidebar test3.
/scoreboard players enable @a test4. notice score does not display on side bar
5. remove scoreboard display/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2.
/scoreboard objectives setdisplay sidebar test3.
/scoreboard players enable @a test4. notice score does not display on side bar
5. remove scoreboard display/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2.
/scoreboard objectives setdisplay sidebar test3.
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1.
/scoreboard objectives add test trigger2.
/scoreboard objectives setdisplay sidebar test3.
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but seems to not display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.
To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
Enabling a /trigger for a player who has not yet been enabled before will set their score for the objective to 0, but
seems tonot display this on the sidebar scoreboard if the scoreboard is displaying when their trigger is enabled.To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
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.
To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
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.
To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice score is now displaying as 0 for player
relates to
relates to
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.
To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice 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.
relates to
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.
To test:
1. add scoreboard objective
/scoreboard objectives add test trigger2. set sidebar display
/scoreboard objectives setdisplay sidebar test3. enable trigger
/scoreboard players enable @a test4. notice score does not display on side bar but player has score of 0
/say @a[score_test_min=0]5. remove scoreboard display
/scoreboard objectives setdisplay sidebar6. put back display
/scoreboard objectives setdisplay sidebar test7. notice 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 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 trigger- Set sidebar display
/scoreboard objectives setdisplay sidebar test- Enable trigger
/scoreboard players enable @a test- Notice 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 sidebar- Put back display
/scoreboard objectives setdisplay sidebar test- Notice 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.
using /trigger first time on player gives score of 0 but not displayed on scoreboardUsing /trigger first time on player gives score of 0 but not displayed on scoreboard
relates to
The bug
Using /trigger for a player who has no score for an objective (see MC-79255) shows the error message commands.trigger.invalidObjective:
Invalid trigger name [objective name]
This is pretty misleading and should instead be something like
The player [player name] has no score entry for the objective [objective name]
If this is no bug, tab-completing the objective argument on /trigger should not return invalid objectives.
How to reproduce
/scoreboard objectives add someObjective trigger /trigger someObjective set 1
Will print "Invalid trigger name someObjective" in chat. Note that trigger objectives that aren't enabled print a different message: "Trigger someObjective is not enabled". Giving the objective a value or enabling its trigger for the player will make it work:
/scoreboard players set @p someObjective 0 /trigger someObjective set 1
Will set someObjective to 1 for me.
I've thought about this confusing behavior a lot, and to me it seems like the only sane way to fix it is by making trigger objectives disabled by default. First, let's look at the situation:
- Set up a trigger objective:
/scoreboard objectives add t trigger
- Try to trigger it:
/trigger t
→ "You cannot trigger this objective yet"
- Enable the objective:
/scoreboard players enable @p t
→ "Nothing changed, that trigger is already enabled"
- Try another time to trigger the objective:
/trigger t
→ This time, it works!
Now, why does it work in step 4, but not in step 2? Because step 3 initialized the objective, which seems to be WAI considering a bug related to exactly this behavior was fixed recently (MC-79255).
Note that this situation changed slightly from 1.12.2, in that enabling a trigger objective always succeeded in 1.12.2, even if it was already enabled.
Misunderstood the report. Not fixed, but WAI per the fix of MC-79255.
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.
Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.
This is an automated comment on any open or reopened issue with out-of-date affected versions.