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
18 changes: 10 additions & 8 deletions src/main/java/com/bitaspire/cyberlevels/cache/Rewards.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@ String parseFormat(String prefix, String line) {
}

public void executeCommands(Player player) {
for (String command : commands) {
command = command.trim();
for (String rawCommand : commands) {
String command = rawCommand.trim();
if (StringUtils.isBlank(command)) continue;

if (main.isEnabled("PlaceholderAPI"))
command = PlaceholderAPI.setPlaceholders(player, main.levelSystem().replacePlaceholders(command, player.getUniqueId(), false));

if (command.toLowerCase().startsWith("[player]")) {
Bukkit.dispatchCommand(player, parseFormat("[player]", command));
continue;
}

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parseFormat("[console]", command));
final String toExecute = command;
Bukkit.getScheduler().runTask(main, () -> {
if (toExecute.toLowerCase().startsWith("[player]")) {
Bukkit.dispatchCommand(player, parseFormat("[player]", toExecute));
} else {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), parseFormat("[console]", toExecute));
}
});
}
}

Expand Down