Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ public void open() {
AxRewards.getDatabase().claimReward(player, reward);

Scheduler.get().run(scheduledTask -> {
String playerName = player.getName();
String strippedPlayerName = stripNamePrefix(playerName);
for (String command : reward.claimCommands()) {
command = command.replace("%player%", player.getName());
command = command
.replace("%player%", playerName == null ? "" : playerName)
.replace("%player_with_prefix%", playerName == null ? "" : playerName)
.replace("%player_without_prefix%", strippedPlayerName)
.replace("%player_uuid%", player.getUniqueId().toString());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), AxRewards.getPlaceholderParser().setPlaceholders(player, command));
}
for (Map<?, ?> map : reward.claimItems()) {
Expand Down Expand Up @@ -181,6 +187,13 @@ public static Set<RewardGui> getOpenMenus() {
return openMenus;
}

private static String stripNamePrefix(String playerName) {
if (playerName == null) return "";
if (!playerName.startsWith(".")) return playerName;
if (playerName.length() == 1) return playerName;
return playerName.substring(1);
}

private static Map<Object, Object> normalizeItemMap(Map<?, ?> original) {
final Map<Object, Object> copy = new LinkedHashMap<>();
for (Map.Entry<?, ?> entry : original.entrySet()) {
Expand Down
Loading