diff --git a/docs/scarpet/api/Scoreboard.md b/docs/scarpet/api/Scoreboard.md index b638fb93..d2feb12d 100644 --- a/docs/scarpet/api/Scoreboard.md +++ b/docs/scarpet/api/Scoreboard.md @@ -3,7 +3,8 @@ ### `scoreboard()`, `scoreboard(objective)`, `scoreboard(objective, key)`, `scoreboard(objective, key, value)` Displays or modifies individual scoreboard values. With no arguments, returns the list of current objectives. -With specified `objective`, lists all keys (players) associated with current objective. With specified `objective`, +With specified `objective`, lists all keys (players) associated with current objective, or `null` if objective does not exist. +With specified `objective` and `key`, returns current value of the objective for a given player (key). With additional `value` sets a new scoreboard value, returning previous value associated with the `key`. @@ -26,4 +27,5 @@ for the objective. ### `scoreboard_display(place, objective)` -sets display location for a specified `objective`. If `objective` is `null`, then display is cleared. +sets display location for a specified `objective`. If `objective` is `null`, then display is cleared. If objective is invalid, +returns `null`. diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index 748d1124..fbce0245 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -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); });