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;
|
2022-02-05 20:16:20 +00:00
|
|
|
import net.kyori.adventure.text.minimessage.placeholder.Replacement;
|
2021-07-31 21:27:29 +00:00
|
|
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
2022-02-05 20:16:20 +00:00
|
|
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
2021-07-31 21:27:29 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
2022-02-05 20:16:20 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
2021-08-25 10:12:29 +00:00
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
public class GalaxyUtility {
|
|
|
|
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
2022-02-05 20:16:20 +00:00
|
|
|
Map<String, Replacement<?>> placeholders = new HashMap<>();
|
|
|
|
|
placeholders.put("prefix", Replacement.miniMessage(prefix));
|
|
|
|
|
placeholders.put("displayname", Replacement.miniMessage(Utility.getDisplayName(player.getUniqueId(), player.getName())));
|
|
|
|
|
placeholders.put("target", Replacement.miniMessage((target.isEmpty() ? " tried to say: " : " -> " + target + ": ")));
|
|
|
|
|
placeholders.put("input", Replacement.miniMessage(input));
|
|
|
|
|
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, placeholders);
|
2021-08-25 10:12:29 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
});
|
2022-01-27 20:05:50 +00:00
|
|
|
player.sendMessage(Utility.parseMiniMessage("<red>The language you used in your message is not allowed, " +
|
2021-07-31 21:27:29 +00:00
|
|
|
"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) {
|
2022-02-05 20:16:20 +00:00
|
|
|
sendBlockedNotification(prefix, player, PlainTextComponentSerializer.plainText().serialize(input), target);
|
2021-07-31 21:27:29 +00:00
|
|
|
}
|
|
|
|
|
}
|