+ Added command enabler
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
indicator=on
|
||||||
|
boop=on
|
||||||
|
tony, stark, dontfeelgood, dontfeelsogood=on
|
||||||
|
yeet=on
|
||||||
|
role=on
|
||||||
|
ping=on
|
||||||
|
rating=on
|
||||||
|
roll=on
|
||||||
|
blur=on
|
||||||
|
choose=on
|
||||||
|
poll=on
|
||||||
|
rpstart=on
|
||||||
|
bet=on
|
||||||
|
perish, thenperish=on
|
||||||
|
teey=on
|
||||||
|
stats=on
|
||||||
|
beans=on
|
||||||
|
eightball, 8ball=on
|
||||||
|
vote=on
|
||||||
|
results=on
|
||||||
|
wolfram=on
|
||||||
|
map=on
|
||||||
|
info, about=on
|
||||||
|
givebeans=on
|
||||||
|
c++, g++, cplus, cpp=on
|
||||||
|
work=on
|
||||||
|
showpoll=on
|
||||||
|
rpend=on
|
||||||
|
rpg=on
|
||||||
|
tweet=on
|
||||||
|
java, jdoodle=on
|
||||||
|
help=on
|
||||||
|
buildHelp=on
|
||||||
|
invite=on
|
||||||
|
shutdown=on
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[ObjectBuilderFactory]
|
[ObjectBuilderFactory]
|
||||||
indicator=
|
indicator=
|
||||||
boop=bap, spaghetti, turboyeet
|
boop=
|
||||||
tony, stark, dontfeelgood, dontfeelsogood=
|
tony, stark, dontfeelgood, dontfeelsogood=
|
||||||
yeet=
|
yeet=
|
||||||
role=
|
role=
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class CommandEnabler
|
|||||||
|
|
||||||
public CommandEnabler()
|
public CommandEnabler()
|
||||||
{
|
{
|
||||||
|
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||||
enabledMap = new HashMap<>();
|
enabledMap = new HashMap<>();
|
||||||
keyList = new ArrayList<>();
|
keyList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -45,18 +46,22 @@ public class CommandEnabler
|
|||||||
File f = new File(filename);
|
File f = new File(filename);
|
||||||
if(f.isFile() && f.canRead())
|
if(f.isFile() && f.canRead())
|
||||||
{
|
{
|
||||||
String content = FileUtils.ReadContent(f);
|
String content = FileUtils.ReadContent(f).trim();
|
||||||
String[] lines = content.split("" + pairSeparator);
|
String[] lines = content.split("" + pairSeparator);
|
||||||
|
|
||||||
for(int i = 0; i < lines.length; ++i)
|
for(int i = 0; i < lines.length; ++i)
|
||||||
{
|
{
|
||||||
String[] pair = lines[i].split(pairSplit);
|
String[] pair = lines[i].split(pairSplit);
|
||||||
|
|
||||||
|
if(pair.length < 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
String key = pair[0].trim();
|
String key = pair[0].trim();
|
||||||
String value = pair[0].trim().toLowerCase();
|
String value = pair[1].trim().toLowerCase();
|
||||||
|
|
||||||
keyList.add(key);
|
keyList.add(key);
|
||||||
|
|
||||||
if(value == enabled)
|
if(value.equalsIgnoreCase(enabled))
|
||||||
enabledMap.putIfAbsent(key, true);
|
enabledMap.putIfAbsent(key, true);
|
||||||
else
|
else
|
||||||
enabledMap.putIfAbsent(key, false);
|
enabledMap.putIfAbsent(key, false);
|
||||||
@@ -71,7 +76,14 @@ public class CommandEnabler
|
|||||||
ArrayList<String> unloc = LocCommands.GetUnlocalizedCommands();
|
ArrayList<String> unloc = LocCommands.GetUnlocalizedCommands();
|
||||||
|
|
||||||
for(int i = 0; i < unloc.size(); ++i)
|
for(int i = 0; i < unloc.size(); ++i)
|
||||||
enabledMap.putIfAbsent(unloc.get(i), defaultEnabledState);
|
{
|
||||||
|
String command = unloc.get(i);
|
||||||
|
if(enabledMap.putIfAbsent(command, defaultEnabledState) == null)
|
||||||
|
{
|
||||||
|
GlobalLog.Log(LogFilter.Strings, "Identified new toggleable raw command: " + command);
|
||||||
|
keyList.add(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write out enabled/disabled file info.
|
// Write out enabled/disabled file info.
|
||||||
@@ -101,6 +113,7 @@ public class CommandEnabler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Looks up a key to see if it's enabled or not
|
||||||
public boolean IsEnabled(String key)
|
public boolean IsEnabled(String key)
|
||||||
{
|
{
|
||||||
if(enabledMap.containsKey(key))
|
if(enabledMap.containsKey(key))
|
||||||
|
|||||||
Reference in New Issue
Block a user