2021-07-31 21:27:29 +00:00
|
|
|
package com.alttd.chat.util;
|
|
|
|
|
|
2021-08-25 10:12:29 +00:00
|
|
|
import com.alttd.chat.config.Config;
|
2021-07-31 21:27:29 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
2021-08-25 10:12:29 +00:00
|
|
|
import net.kyori.adventure.text.minimessage.Template;
|
2021-07-31 21:27:29 +00:00
|
|
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
2021-08-25 10:12:29 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
public class GalaxyUtility {
|
|
|
|
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
|
|
|
|
MiniMessage miniMessage = MiniMessage.get();
|
2021-08-25 10:12:29 +00:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
Bukkit.getOnlinePlayers().forEach(a ->{
|
|
|
|
|
if (a.hasPermission("chat.alert-blocked")) {
|
2021-08-25 10:12:29 +00:00
|
|
|
a.sendMessage(blockedNotification);
|
2021-07-31 21:27:29 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
player.sendMessage(miniMessage.parse("<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>"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void sendBlockedNotification(String prefix, Player player, Component input, String target) {
|
|
|
|
|
sendBlockedNotification(prefix, player, PlainComponentSerializer.plain().serialize(input), target);
|
|
|
|
|
}
|
|
|
|
|
}
|