Scoreboard for invalid objective shouldn't fail since objective names are not fixed and provided by players.

This commit is contained in:
gnembon committed 2020-11-23 22:08:06 -04:00
1 parent a297fd1441
commit 550e53aec7
2 files changed
+6 -4

No files matched your search

@@ -56,7 +56,7 @@ public class Scoreboards {
}
String objectiveName = lv.get(0).evalValue(c).getString();
ScoreboardObjective objective = scoreboard.getObjective(objectiveName);
if (objective == null) throw new InternalExpressionException("Unknown objective: "+objectiveName);
if (objective == null) return LazyValue.NULL;
if (lv.size()==1)
{
Value ret = ListValue.wrap(scoreboard.getAllPlayerScores(objective).stream().map(s -> new StringValue(s.getPlayerName())).collect(Collectors.toList()));
@@ -143,7 +143,7 @@ public class Scoreboards {
}
String objectiveString = target.getString();
ScoreboardObjective objective = scoreboard.getObjective(objectiveString);
if (objective == null) throw new InternalExpressionException("Objective doesn't exist: "+objectiveString);
if (objective == null) return LazyValue.NULL;
scoreboard.setObjectiveSlot(slot, objective);
return (_c, _t) -> new NumericValue(slot);
});