Commit faa9d0b5 authored by Adam Gausmann's avatar Adam Gausmann

Fixed access lists to allow case preservation.

parent 4eab95aa
Pipeline #4291346 passed with stages
in 10 seconds
...@@ -6,12 +6,12 @@ import java.io.FileReader; ...@@ -6,12 +6,12 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import ninja.nonemu.samurai.BotImpl; import ninja.nonemu.samurai.BotImpl;
import ninja.nonemu.samurai.connection.ChatEvent; import ninja.nonemu.samurai.connection.ChatEvent;
import ninja.nonemu.samurai.connection.User; import ninja.nonemu.samurai.connection.User;
...@@ -30,16 +30,15 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -30,16 +30,15 @@ public class CommandSystemImpl implements CommandSystem {
private final Queue<Runnable> executionQueue; private final Queue<Runnable> executionQueue;
private String commandPrefix; private String commandPrefix;
private boolean whitelistEnabled;
public CommandSystemImpl(BotImpl bot) { public CommandSystemImpl(BotImpl bot) {
logger = bot.getLogger(); logger = bot.getLogger();
this.bot = bot; this.bot = bot;
oplist = new HashSet<>(); oplist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
whitelist = new HashSet<>(); whitelist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
blacklist = new HashSet<>(); blacklist = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
infoMap = new HashMap<>(); infoMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
executorMap = new HashMap<>(); executorMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
executionQueue = new LinkedList<>(); executionQueue = new LinkedList<>();
} }
...@@ -157,7 +156,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -157,7 +156,7 @@ public class CommandSystemImpl implements CommandSystem {
private void clearAccessLists() { private void clearAccessLists() {
logger.debug("Clearing access lists"); logger.debug("Clearing access lists");
;
oplist.clear(); oplist.clear();
whitelist.clear(); whitelist.clear();
blacklist.clear(); blacklist.clear();
...@@ -225,8 +224,8 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -225,8 +224,8 @@ public class CommandSystemImpl implements CommandSystem {
@Override @Override
public void registerCommand(CommandInfo info, CommandExecutor executor) { public void registerCommand(CommandInfo info, CommandExecutor executor) {
infoMap.put(info.getName().toLowerCase(), info); infoMap.put(info.getName(), info);
executorMap.put(info.getName().toLowerCase(), executor); executorMap.put(info.getName(), executor);
} }
@Override @Override
...@@ -239,7 +238,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -239,7 +238,7 @@ public class CommandSystemImpl implements CommandSystem {
@Override @Override
public CommandInfo getCommand(String name) { public CommandInfo getCommand(String name) {
return infoMap.get(name.toLowerCase()); return infoMap.get(name);
} }
@Override @Override
...@@ -255,7 +254,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -255,7 +254,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public boolean isOperator(String name) { public boolean isOperator(String name) {
return oplist.contains(name.toLowerCase()); return oplist.contains(name);
} }
/** /**
...@@ -265,7 +264,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -265,7 +264,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void addOperator(String name) { public void addOperator(String name) {
oplist.add(name.toLowerCase()); oplist.add(name);
} }
/** /**
...@@ -275,7 +274,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -275,7 +274,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void removeOperator(String name) { public void removeOperator(String name) {
oplist.remove(name.toLowerCase()); oplist.remove(name);
} }
/** /**
...@@ -287,7 +286,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -287,7 +286,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public boolean isWhitelisted(String name) { public boolean isWhitelisted(String name) {
return whitelist.contains(name.toLowerCase()); return whitelist.contains(name);
} }
/** /**
...@@ -297,7 +296,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -297,7 +296,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void addWhitelisted(String name) { public void addWhitelisted(String name) {
whitelist.add(name.toLowerCase()); whitelist.add(name);
} }
/** /**
...@@ -307,7 +306,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -307,7 +306,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void removeWhitelisted(String name) { public void removeWhitelisted(String name) {
whitelist.remove(name.toLowerCase()); whitelist.remove(name);
} }
@Override @Override
...@@ -328,7 +327,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -328,7 +327,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public boolean isBlacklisted(String name) { public boolean isBlacklisted(String name) {
return blacklist.contains(name.toLowerCase()); return blacklist.contains(name);
} }
/** /**
...@@ -338,7 +337,7 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -338,7 +337,7 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void addBlacklisted(String name) { public void addBlacklisted(String name) {
blacklist.add(name.toLowerCase()); blacklist.add(name);
} }
/** /**
...@@ -348,6 +347,6 @@ public class CommandSystemImpl implements CommandSystem { ...@@ -348,6 +347,6 @@ public class CommandSystemImpl implements CommandSystem {
*/ */
@Override @Override
public void removeBlacklisted(String name) { 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