scoreboard_add returns current criterion and null
This commit is contained in:
1 parent
b120f46764
commit
5771d42c98
2 files changed
+3
-1
No files matched your search
@@ -11,7 +11,7 @@ With specified `objective` and
|
|||||||
### `scoreboard_add(objective, criterion?)`
|
### `scoreboard_add(objective, criterion?)`
|
||||||
|
|
||||||
Adds a new objective to scoreboard. If `criterion` is not specified, assumes `'dummy'`.
|
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`
|
If the objective was added, returns `true`. If nothing is affected, returns `null`
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ public class Scoreboards {
|
|||||||
|
|
||||||
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
|
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
|
||||||
if (objective != null) {
|
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);
|
((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().get(objective.getCriterion()).remove(objective);
|
||||||
((ScoreboardObjective_scarpetMixin) objective).setCriterion(criterion);
|
((ScoreboardObjective_scarpetMixin) objective).setCriterion(criterion);
|
||||||
(((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().computeIfAbsent(criterion, (criterion1) -> Lists.newArrayList())).add(objective);
|
(((Scoreboard_scarpetMixin)scoreboard).getObjectivesByCriterion().computeIfAbsent(criterion, (criterion1) -> Lists.newArrayList())).add(objective);
|
||||||
|
|||||||
Reference in new issue
Block a user