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;
|
2022-09-26 21:53:50 +00:00
|
|
|
import com.alttd.chat.managers.RegexManager;
|
2021-07-31 21:27:29 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
2022-09-26 21:53:50 +00:00
|
|
|
import net.kyori.adventure.text.format.TextDecoration;
|
2022-02-19 14:14:41 +00:00
|
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
|
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
2022-09-26 21:53:50 +00:00
|
|
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
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-09-26 21:53:50 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
public class GalaxyUtility {
|
2022-03-14 15:48:35 +00:00
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
2022-02-19 14:14:41 +00:00
|
|
|
TagResolver placeholders = TagResolver.resolver(
|
|
|
|
|
Placeholder.parsed("prefix", prefix),
|
|
|
|
|
Placeholder.parsed("displayname", Utility.getDisplayName(player.getUniqueId(), player.getName())),
|
2022-10-08 23:21:10 +00:00
|
|
|
Placeholder.parsed("target", (target.isEmpty() ? "tried to say:" : "-> " + target + ":")),
|
2022-02-19 14:14:41 +00:00
|
|
|
Placeholder.parsed("input", input)
|
|
|
|
|
);
|
2022-02-05 20:16:20 +00:00
|
|
|
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-10-08 23:18:13 +00:00
|
|
|
TagResolver placeholders = TagResolver.resolver(
|
|
|
|
|
Placeholder.parsed("prefix", prefix),
|
|
|
|
|
Placeholder.parsed("displayname", Utility.getDisplayName(player.getUniqueId(), player.getName())),
|
2022-10-08 23:21:10 +00:00
|
|
|
Placeholder.parsed("target", (target.isEmpty() ? "tried to say:" : "-> " + target + ":")),
|
2022-10-08 23:18:13 +00:00
|
|
|
Placeholder.component("input", input)
|
|
|
|
|
);
|
|
|
|
|
Component blockedNotification = Utility.parseMiniMessage(Config.NOTIFICATIONFORMAT, placeholders);
|
|
|
|
|
|
|
|
|
|
Bukkit.getOnlinePlayers().forEach(a ->{
|
|
|
|
|
if (a.hasPermission("chat.alert-blocked")) {
|
|
|
|
|
a.sendMessage(blockedNotification);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
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>"));
|
2021-07-31 21:27:29 +00:00
|
|
|
}
|
2022-03-14 15:48:35 +00:00
|
|
|
|
2022-09-26 21:53:50 +00:00
|
|
|
public static void addAdditionalChatCompletions(Player player) {
|
|
|
|
|
List<String> completions = new ArrayList<>(RegexManager.emotesList);
|
|
|
|
|
Utility.formattingPerms.forEach((perm, pair) -> {
|
|
|
|
|
if (player.hasPermission(perm)) {
|
|
|
|
|
completions.addAll(pair.getY());
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-12-17 11:37:21 +00:00
|
|
|
player.addCustomChatCompletions(completions);
|
2022-09-26 21:53:50 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-31 21:27:29 +00:00
|
|
|
}
|