Commit c82abda7 authored by Adam Gausmann's avatar Adam Gausmann

Merge branch 'tree' into 'master'

Fixed access lists to allow case preservation.



See merge request !12
parents 4eab95aa faa9d0b5
Pipeline #4291350 passed with stages
in 10 seconds
......@@ -6,12 +6,12 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import ninja.nonemu.samurai.BotImpl;
import ninja.nonemu.samurai.connection.ChatEvent;
import ninja.nonemu.samurai.connection.User;
......@@ -30,16 +30,15 @@ public class CommandSystemImpl implements CommandSystem {
private final Queue<Runnable> executionQueue;
private String commandPrefix;
private boolean whitelistEnabled;
public CommandSystemImpl(BotImpl bot) {
logger = bot.getLogger();
this.bot = bot;
oplist = new HashSet<>();
whitelist = new HashSet<>();
blacklist = new HashSet<>();
infoMap = new HashMap<>();
executorMap = new HashMap<>();
oplist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
whitelist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
blacklist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
infoMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
executorMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
executionQueue = new LinkedList<>();
}
......@@ -157,7 +156,7 @@ public class CommandSystemImpl implements CommandSystem {
private void clearAccessLists() {
logger.debug("Clearing access lists");
;
oplist.clear();
whitelist.clear();
blacklist.clear();
......@@ -225,8 +224,8 @@ public class CommandSystemImpl implements CommandSystem {
@Override
public void registerCommand(CommandInfo info, CommandExecutor executor) {
infoMap.put(info.getName().toLowerCase(), info);
executorMap.put(info.getName().toLowerCase(), executor);
infoMap.put(info.getName(), info);
executorMap.put(info.getName(), executor);
}
@Override
......@@ -239,7 +238,7 @@ public class CommandSystemImpl implements CommandSystem {
@Override
public CommandInfo getCommand(String name) {
return infoMap.get(name.toLowerCase());
return infoMap.get(name);
}
@Override
......@@ -255,7 +254,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public boolean isOperator(String name) {
return oplist.contains(name.toLowerCase());
return oplist.contains(name);
}
/**
......@@ -265,7 +264,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void addOperator(String name) {
oplist.add(name.toLowerCase());
oplist.add(name);
}
/**
......@@ -275,7 +274,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void removeOperator(String name) {
oplist.remove(name.toLowerCase());
oplist.remove(name);
}
/**
......@@ -287,7 +286,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public boolean isWhitelisted(String name) {
return whitelist.contains(name.toLowerCase());
return whitelist.contains(name);
}
/**
......@@ -297,7 +296,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void addWhitelisted(String name) {
whitelist.add(name.toLowerCase());
whitelist.add(name);
}
/**
......@@ -307,7 +306,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void removeWhitelisted(String name) {
whitelist.remove(name.toLowerCase());
whitelist.remove(name);
}
@Override
......@@ -328,7 +327,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public boolean isBlacklisted(String name) {
return blacklist.contains(name.toLowerCase());
return blacklist.contains(name);
}
/**
......@@ -338,7 +337,7 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void addBlacklisted(String name) {
blacklist.add(name.toLowerCase());
blacklist.add(name);
}
/**
......@@ -348,6 +347,6 @@ public class CommandSystemImpl implements CommandSystem {
*/
@Override
public void removeBlacklisted(String name) {
blacklist.remove(name.toLowerCase());
blacklist.remove(name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment