Allow the use of placeholders in config messages

This commit is contained in:
ASangarin 2020-06-13 21:31:47 +02:00
parent 0926641839
commit 26159e3a10

View File

@ -160,23 +160,27 @@ public class ConfigManager {
public class SimpleMessage {
private final String message;
private final boolean actionbar;
private final boolean hasPlaceholders;
public SimpleMessage(String message) {
this.message = message;
this.actionbar = message.startsWith("%");
this.message = actionbar ? message.substring(1) : message;
this.hasPlaceholders = this.message.contains("%");
}
public String message() {
return message.startsWith("%") ? message.substring(1) : message;
return message;
}
public boolean send(Player player) {
if (!message.isEmpty()) {
if (message.startsWith("%"))
PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1));
else
player.sendMessage(message);
String msg = hasPlaceholders ? MMOCore.plugin.placeholderParser.parse(player, message) : message;
if (!msg.isEmpty()) {
if (actionbar) PlayerData.get(player.getUniqueId()).displayActionBar(msg);
else player.sendMessage(msg);
}
return !message.isEmpty();
return !msg.isEmpty();
}
}
}