1 change: 1 addition & 0 deletions docs/user/default-placeholders.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Prior to 1.19, arguments were separated with a slash (`/`) instead of space.
- `%server:mod_description [modid]%` - Returns description of the specified mod.
- `%server:objective_name_top [objective] [position]%` - Shows name of the player at the `position`th place in the scoreboard `objective`.
- `%server:objective_score_top [objective] [position]%` - Shows score of the player at the `position`th place in the scoreboard `objective`.
- `%server:objective_score_player [objective] [player]%` - Shows score of the specified `player` in the scoreboard `objective`.

*[TPS]: Ticks Per Second. The number of ticks per second executing on the server. <20 TPS means the server is lagging.
*[MSPT]: Milliseconds Per Tick. The number of milliseconds it takes for a tick on the server. >50 MSPT means the server is lagging.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ org.gradle.jvmargs=-Xmx1G
fabric_version=0.119.1+1.21.5

# Mod Properties
mod_version = 2.6.3+1.21.5
mod_version = 2.6.4+1.21.5
maven_group = eu.pb4
archives_base_name = placeholder-api
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ public interface Format {
if (x != null) {
return x;
}
if (string.charAt(i) == '\\' && maxLength > i + 1) {
i++;
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,25 @@ public static void register() {
}
return PlaceholderResult.invalid("Not enough arguments!");
});

Placeholders.register(Identifier.of("server", "objective_score_player"), (ctx, arg) -> {
var args = arg.split(" ");
if (args.length >= 2) {
ServerScoreboard scoreboard = ctx.server().getScoreboard();
ScoreboardObjective scoreboardObjective = scoreboard.getNullableObjective(args[0]);
if (scoreboardObjective == null) {
return PlaceholderResult.invalid("Invalid Objective!");
}
try {
Collection<ScoreboardEntry> scoreboardEntries = scoreboard.getScoreboardEntries(scoreboardObjective);
ScoreboardEntry entry = scoreboardEntries.stream().filter(scoreboardEntry -> scoreboardEntry.name().getString().equals(args[1])).toList().getFirst();

return PlaceholderResult.value(String.valueOf(entry.value()));
} catch (Exception e) {
return PlaceholderResult.invalid("Player Not Found!");
}
}
return PlaceholderResult.invalid("Not enough arguments!");
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ protected void handleLiteral(String value, Context context) {
}

if (tag == null) {
if (value.charAt(tPos) == '\\' && value.length() > tPos + 1) {
tPos++;
}
tPos++;
} else {
break;
Expand Down