Attempt to load regexes from config
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package com.alttd.chat.util;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.config.RegexConfig;
|
||||
import com.alttd.chat.config.ServerConfig;
|
||||
import com.alttd.chat.objects.RegexType;
|
||||
import com.google.common.collect.Lists;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -13,6 +20,17 @@ public class Regex {
|
||||
|
||||
// IDEA: Regex object -> RegexPattern, shatteredPattern, replacement, replacements
|
||||
public static void initRegex() {
|
||||
// LOAD REGEXES, sad way of doing it:(
|
||||
// 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 (RegexType.getType(regexConfig.TYPE) == RegexType.BLOCK) {
|
||||
cancelRegex.put(Pattern.compile(regexConfig.REGEX), Lists.newArrayList(regexConfig.REPLACEMENT));
|
||||
} else if (RegexType.getType(regexConfig.TYPE) == RegexType.REPLACE) {
|
||||
replaceRegex.put(regexConfig.REGEX, regexConfig.REPLACEMENT);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO load data from config (a regex string, and it's exceptions if there are any)
|
||||
cancelRegex.put(Pattern.compile("\\b([R]+[^\\w]?[4A]+[^\\w]?[P]+(([^\\w]?[E3]+[^\\w]?[DT]*)|([^\\w]?[I!1]+[^\\w]?[S5]+[^\\w]?[T7]+)|([^\\w]?[I!1]+[^\\w]?[N]+[^\\w]?[G69]+)))\\b"), new ArrayList<>());
|
||||
//TODO load data from config (a regex string and what to replace it with)
|
||||
|
||||
Reference in New Issue
Block a user