Add blockednotification format in config

This commit is contained in:
destro174
2021-08-25 12:12:29 +02:00
parent b6e4e56118
commit 728cac3281
4 changed files with 19 additions and 7 deletions
@@ -1,21 +1,31 @@
package com.alttd.chat.util;
import com.alttd.chat.config.Config;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.ArrayList;
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)
));
Component blockedNotification = miniMessage.parse(Config.NOTIFICATIONFORMAT, templates);
Bukkit.getOnlinePlayers().forEach(a ->{
Component blockedNotification = miniMessage.parse("<red>[" + prefix + "] "
+ Utility.getDisplayName(player.getUniqueId(), player.getName())
+ (target.isEmpty() ? " tried to say: " : " -> " + target + ": ")
+ input + "</red>");
if (a.hasPermission("chat.alert-blocked")) {
a.sendMessage(blockedNotification);//TODO make configurable (along with all the messages)
a.sendMessage(blockedNotification);
}
});
player.sendMessage(miniMessage.parse("<red>The language you used in your message is not allowed, " +