Refactor
This commit is contained in:
@@ -184,9 +184,14 @@ public final class Config {
|
||||
|
||||
public static String GCFORMAT = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message></gray></white>";
|
||||
public static String GCPERMISSION = "proxy.globalchat";
|
||||
public static List<String> GCALIAS = new ArrayList<>();
|
||||
public static String GCNOTENABLED = "You don't have global chat enabled.";
|
||||
private static void globalChat() {
|
||||
MESSAGERECIEVER = getString("commands.globalchat.format", MESSAGERECIEVER);
|
||||
GCPERMISSION = getString("commands.globalchat.view-chat-permission", GCPERMISSION);
|
||||
GCALIAS.clear();
|
||||
GCALIAS = getList("commands.globalchat.alias", Lists.newArrayList("gc", "global"));
|
||||
GCNOTENABLED = getString("commands.globalchat.not-enabled", GCNOTENABLED);
|
||||
}
|
||||
|
||||
public static List<String> GACECOMMANDALIASES = new ArrayList<>();
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.alttd.chat.managers;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.config.RegexConfig;
|
||||
import com.alttd.chat.objects.ChatFilterType;
|
||||
import com.alttd.chat.objects.FilterType;
|
||||
import com.google.common.collect.Lists;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// TODO rebuild this class, All regexes go in a single list where we use the ChatFilter object and a matcher
|
||||
public class RegexManager {
|
||||
|
||||
private static final HashMap<Pattern, ArrayList<String>> cancelRegex = new HashMap<>();
|
||||
@@ -23,9 +24,9 @@ public class RegexManager {
|
||||
// maiby a REGEXobject and a list<Regex> would be better here?
|
||||
for(ConfigurationNode node : Config.REGEXNODE.getChildrenMap().values()) {
|
||||
RegexConfig regexConfig = new RegexConfig(node.getString());
|
||||
if (ChatFilterType.getType(regexConfig.TYPE) == ChatFilterType.BLOCK) {
|
||||
if (FilterType.getType(regexConfig.TYPE) == FilterType.BLOCK) {
|
||||
cancelRegex.put(Pattern.compile(regexConfig.REGEX), Lists.newArrayList(regexConfig.REPLACEMENT));
|
||||
} else if (ChatFilterType.getType(regexConfig.TYPE) == ChatFilterType.REPLACE) {
|
||||
} else if (FilterType.getType(regexConfig.TYPE) == FilterType.REPLACE) {
|
||||
replaceRegex.put(regexConfig.REGEX, regexConfig.REPLACEMENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.alttd.chat.objects;
|
||||
public class ChatFilter {
|
||||
|
||||
private final String regex;
|
||||
private final ChatFilterType type;
|
||||
private final FilterType type;
|
||||
private String replacement = "";
|
||||
|
||||
public ChatFilter(String regex, ChatFilterType type) {
|
||||
public ChatFilter(String regex, FilterType type) {
|
||||
this.regex = regex;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ChatFilter(String regex, ChatFilterType type, String replacement) {
|
||||
public ChatFilter(String regex, FilterType type, String replacement) {
|
||||
this.regex = regex;
|
||||
this.type = type;
|
||||
this.replacement = replacement;
|
||||
@@ -21,7 +21,7 @@ public class ChatFilter {
|
||||
return regex;
|
||||
}
|
||||
|
||||
public ChatFilterType getType() {
|
||||
public FilterType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ public class ChatUser {
|
||||
|
||||
private LinkedList<Mail> mails;
|
||||
|
||||
/**
|
||||
* Not all of the objects are relevant to proxy or server, so the saving should only update if the value has been changed?
|
||||
*/
|
||||
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp, boolean toggle_Gc) {
|
||||
this.uuid = uuid;
|
||||
this.partyId = partyId;
|
||||
@@ -37,9 +34,9 @@ public class ChatUser {
|
||||
prefix = Utility.getPrefix(uuid, true);
|
||||
staffPrefix = Utility.getStaffPrefix(uuid);
|
||||
|
||||
prefixAll = prefix + staffPrefix; //TODO test what this does cus I barely understand lp api
|
||||
// a boolean is lighter then a permission check, it's what I'd suggest doing here
|
||||
toggleGc = toggle_Gc;//Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
||||
prefixAll = Utility.getPrefix(uuid, false);
|
||||
|
||||
toggleGc = toggle_Gc;
|
||||
replyTarget = null;
|
||||
mails = new LinkedList<>(); // todo load mails
|
||||
}
|
||||
@@ -58,7 +55,7 @@ public class ChatUser {
|
||||
|
||||
public void togglePartyChat() {
|
||||
toggledPartyChat = !toggledPartyChat;
|
||||
Queries.setPartyChatState(toggledPartyChat, uuid); //TODO: Async pls
|
||||
Queries.setPartyChatState(toggledPartyChat, uuid); //TODO: Async pls - no CompleteableFuture<>!
|
||||
}
|
||||
|
||||
public boolean ForceTp() {
|
||||
@@ -67,7 +64,7 @@ public class ChatUser {
|
||||
|
||||
public void toggleForceTp() {
|
||||
forceTp = !forceTp;
|
||||
Queries.setForceTpState(forceTp, uuid); //TODO: Async pls
|
||||
Queries.setForceTpState(forceTp, uuid); //TODO: Async pls - no CompleteableFuture<>!
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -121,4 +118,8 @@ public class ChatUser {
|
||||
public LinkedList<Mail> getMails() {
|
||||
return mails;
|
||||
}
|
||||
|
||||
public void addMail(Mail mail) {
|
||||
mails.add(mail);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,17 +1,17 @@
|
||||
package com.alttd.chat.objects;
|
||||
|
||||
public enum ChatFilterType {
|
||||
public enum FilterType {
|
||||
REPLACE("replace"),
|
||||
BLOCK("block");
|
||||
|
||||
private final String name;
|
||||
|
||||
ChatFilterType(String name) {
|
||||
FilterType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static ChatFilterType getType(String name) {
|
||||
for (ChatFilterType type : ChatFilterType.values()) {
|
||||
public static FilterType getType(String name) {
|
||||
for (FilterType type : FilterType.values()) {
|
||||
if (type.name.equalsIgnoreCase(name)) {
|
||||
return type;
|
||||
}
|
||||
Reference in New Issue
Block a user