Update minimessage and add helper methods

This commit is contained in:
destro174
2022-01-27 21:05:50 +01:00
parent eb31a141d0
commit 831bac1be9
18 changed files with 173 additions and 159 deletions
@@ -13,22 +13,20 @@ import java.util.List;
public class GalaxyUtility {
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
MiniMessage miniMessage = MiniMessage.get();
List<Template> templates = new ArrayList<>(List.of(
Template.of("prefix", prefix),
Template.of("displayname", Utility.getDisplayName(player.getUniqueId(), player.getName())),
Template.of("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
Template.of("input", input)
Template.template("prefix", prefix),
Template.template("displayname", Utility.getDisplayName(player.getUniqueId(), player.getName())),
Template.template("target", (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")),
Template.template("input", input)
));
Component blockedNotification = miniMessage.parse(Config.NOTIFICATIONFORMAT, templates);
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, templates);
Bukkit.getOnlinePlayers().forEach(a ->{
if (a.hasPermission("chat.alert-blocked")) {
a.sendMessage(blockedNotification);
}
});
player.sendMessage(miniMessage.parse("<red>The language you used in your message is not allowed, " +
player.sendMessage(Utility.parseMiniMessage("<red>The language you used in your message is not allowed, " +
"this constitutes as your only warning. Any further attempts at bypassing the filter will result in staff intervention.</red>"));
}