Add blockednotification format in config
This commit is contained in:
parent
b6e4e56118
commit
728cac3281
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,7 +3,6 @@
|
||||||
.idea
|
.idea
|
||||||
testserver
|
testserver
|
||||||
run
|
run
|
||||||
notes
|
|
||||||
|
|
||||||
# Compiled class file
|
# Compiled class file
|
||||||
*.class
|
*.class
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.alttd.chat.config;
|
package com.alttd.chat.config;
|
||||||
|
|
||||||
import com.alttd.chat.objects.channels.CustomChannel;
|
import com.alttd.chat.objects.channels.CustomChannel;
|
||||||
|
import com.alttd.chat.util.Utility;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
@ -163,6 +164,7 @@ public final class Config {
|
||||||
public static String MINIMIUMSTAFFRANK = "trainee";
|
public static String MINIMIUMSTAFFRANK = "trainee";
|
||||||
public static String CONSOLENAME = "Console";
|
public static String CONSOLENAME = "Console";
|
||||||
public static UUID CONSOLEUUID = UUID.randomUUID();
|
public static UUID CONSOLEUUID = UUID.randomUUID();
|
||||||
|
public static String NOTIFICATIONFORMAT = "<red>[<prefix>] <displayname> <target> <input>";
|
||||||
private static void settings() {
|
private static void settings() {
|
||||||
PREFIXGROUPS = getList("settings.prefix-groups",
|
PREFIXGROUPS = getList("settings.prefix-groups",
|
||||||
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch", "developer"));
|
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch", "developer"));
|
||||||
|
|
@ -173,6 +175,7 @@ public final class Config {
|
||||||
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
|
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
|
||||||
CONSOLEUUID = UUID.fromString(getString("settings.console-uuid", CONSOLEUUID.toString()));
|
CONSOLEUUID = UUID.fromString(getString("settings.console-uuid", CONSOLEUUID.toString()));
|
||||||
MINIMIUMSTAFFRANK = getString("settings.minimum-staff-rank", MINIMIUMSTAFFRANK);
|
MINIMIUMSTAFFRANK = getString("settings.minimum-staff-rank", MINIMIUMSTAFFRANK);
|
||||||
|
NOTIFICATIONFORMAT = getString("settings.blockedmessage-notification", NOTIFICATIONFORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
<dependency><!-- Galaxy -->
|
<dependency><!-- Galaxy -->
|
||||||
<groupId>com.alttd</groupId>
|
<groupId>com.alttd</groupId>
|
||||||
<artifactId>galaxy-api</artifactId>
|
<artifactId>galaxy-api</artifactId>
|
||||||
<version>1.17-R0.1-SNAPSHOT</version>
|
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,31 @@
|
||||||
package com.alttd.chat.util;
|
package com.alttd.chat.util;
|
||||||
|
|
||||||
|
import com.alttd.chat.config.Config;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GalaxyUtility {
|
public class GalaxyUtility {
|
||||||
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
public static void sendBlockedNotification(String prefix, Player player, String input, String target) {
|
||||||
MiniMessage miniMessage = MiniMessage.get();
|
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 ->{
|
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")) {
|
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, " +
|
player.sendMessage(miniMessage.parse("<red>The language you used in your message is not allowed, " +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user