scoreboard_add returns current criterion and null

This commit is contained in:
replaceitem committed 2020-12-28 12:44:17 +01:00
1 parent b120f46764
commit 5771d42c98
2 files changed
+3 -1

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ With specified `objective` and
### `scoreboard_add(objective, criterion?)`
Adds a new objective to scoreboard. If `criterion` is not specified, assumes `'dummy'`.
If the objective already exists, changes the criterion of that objective and returns false.
If the objective already exists, changes the criterion of that objective and returns `false`. If the criterion was not specified but the objective already exists, returns the current criterion.
If the objective was added, returns `true`. If nothing is affected, returns `null`
<pre>
@@ -137,6 +137,8 @@ public class Scoreboards {
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
if (objective != null) {
if(lv.size() == 1) return (_c, _t) -> StringValue.of(objective.getCriterion().getName());
if(objective.getCriterion().equals(criterion) || lv.size() == 1) return LazyValue.NULL;
((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().get(objective.getCriterion()).remove(objective);
((ScoreboardObjective_scarpetMixin) objective).setCriterion(criterion);
(((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().computeIfAbsent(criterion, (criterion1) -> Lists.newArrayList())).add(objective);