Merge branch 'main' into party
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.alttd.chat.config;
|
||||
|
||||
import com.alttd.chat.objects.Channel;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
@@ -14,9 +15,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Config {
|
||||
@@ -238,6 +237,25 @@ public final class Config {
|
||||
|
||||
}
|
||||
|
||||
private static void chatChannels() {
|
||||
ConfigurationNode node = getNode("chat-channels");
|
||||
if (node.isEmpty()) {
|
||||
getString("chat-channels.ac.format", "<white><gray><sender></gray> <hover:show_text:on <server>><yellow>to <channel></yellow></hover><gray>: <message>");
|
||||
getList("chat-channels.ac.servers", List.of("lobby"));
|
||||
getBoolean("chat-channels.ac.proxy", false);
|
||||
node = getNode("chat-channels");
|
||||
}
|
||||
|
||||
for (ConfigurationNode configurationNode : node.getChildrenMap().values()) {
|
||||
String channelName = Objects.requireNonNull(configurationNode.getKey()).toString();
|
||||
String key = "chat-channels." + channelName + ".";
|
||||
new Channel(channelName,
|
||||
getString(key + "format", ""),
|
||||
getList(key + "servers", Collections.EMPTY_LIST),
|
||||
getBoolean(key + "proxy", false));
|
||||
}
|
||||
}
|
||||
|
||||
public static String SERVERMUTEPERMISSION = "command.mute-server";
|
||||
public static String SPYPERMISSION = "chat.socialspy";
|
||||
private static void permissions() {
|
||||
|
||||
@@ -173,8 +173,15 @@ public final class RegexConfig {
|
||||
String regex = entry.getValue().getNode("regex").getString();
|
||||
String replacement = entry.getValue().getNode("replacement").getString();
|
||||
List<String> exclusions = entry.getValue().getNode("exclusions").getList(TypeToken.of(String.class), new ArrayList<>());
|
||||
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions);
|
||||
RegexManager.addFilter(chatFilter);
|
||||
if (type == null || type.isEmpty() || regex == null || regex.isEmpty()) {
|
||||
ALogger.warn("Filter: " + name + " was set up incorrectly");
|
||||
} else {
|
||||
if (replacement == null || replacement.isEmpty()) {
|
||||
replacement = name;
|
||||
}
|
||||
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions);
|
||||
RegexManager.addFilter(chatFilter);
|
||||
}
|
||||
} catch(ObjectMappingException ex) {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Channel {
|
||||
public static HashMap<String, Channel> channels = new HashMap<>();
|
||||
private String permission;
|
||||
private String channelName;
|
||||
private String format;
|
||||
private List<String> servers;
|
||||
private boolean proxy;
|
||||
|
||||
public Channel(String channelName, String format, List<String> servers, boolean proxy) {
|
||||
this.permission = "chat.channel." + channelName.toLowerCase();
|
||||
this.channelName = channelName;
|
||||
this.format = format;
|
||||
this.servers = servers;
|
||||
this.proxy = proxy;
|
||||
channels.put(channelName.toLowerCase(), this);
|
||||
}
|
||||
|
||||
public static Collection<Channel> getChannels() {
|
||||
return channels.values();
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public List<String> getServers() {
|
||||
return servers;
|
||||
}
|
||||
|
||||
public boolean isProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public static Channel getChatChannel(String channelName) {
|
||||
return channels.get(channelName.toLowerCase());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user