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
.gitignore vendored
View File

@ -3,7 +3,6 @@
.idea
testserver
run
notes
# Compiled class file
*.class

View File

@ -1,6 +1,7 @@
package com.alttd.chat.config;
import com.alttd.chat.objects.channels.CustomChannel;
import com.alttd.chat.util.Utility;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.reflect.TypeToken;
@ -163,6 +164,7 @@ public final class Config {
public static String MINIMIUMSTAFFRANK = "trainee";
public static String CONSOLENAME = "Console";
public static UUID CONSOLEUUID = UUID.randomUUID();
public static String NOTIFICATIONFORMAT = "<red>[<prefix>] <displayname> <target> <input>";
private static void settings() {
PREFIXGROUPS = getList("settings.prefix-groups",
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch", "developer"));
@ -173,6 +175,7 @@ public final class Config {
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
CONSOLEUUID = UUID.fromString(getString("settings.console-uuid", CONSOLEUUID.toString()));
MINIMIUMSTAFFRANK = getString("settings.minimum-staff-rank", MINIMIUMSTAFFRANK);
NOTIFICATIONFORMAT = getString("settings.blockedmessage-notification", NOTIFICATIONFORMAT);
}
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();

View File

@ -97,7 +97,7 @@
<dependency><!-- Galaxy -->
<groupId>com.alttd</groupId>
<artifactId>galaxy-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -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, " +