Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
+1
-1
@@ -14,6 +14,6 @@
|
||||
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.7-javadoc.jar"/>
|
||||
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/luaj-jse-3.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="F:/Shared/Coding/Java/workspace/ProKitty/lib/fuzzywuzzy-1.2.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/fuzzywuzzy-1.2.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -61,4 +61,4 @@ fetch=
|
||||
crouton=
|
||||
invite=
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
local time = os.time();
|
||||
|
||||
function plugin(message, user)
|
||||
if(string.match(string.lower(message), "purple"))then
|
||||
local timedif = os.time() - time;
|
||||
time = os.time();
|
||||
days = (timedif / (60*60*24));
|
||||
hours = ((timedif / (60*60)) % 24);
|
||||
mins = ((timedif / (60)) % 60);
|
||||
secs = timedif % 60;
|
||||
return "*GASP!!!* \n" .. user.name .. " said **THE** word! It's been " .. round(days) .. " days, " .. round(hours) .. " hours, " .. round(mins) .. " minutes, and " .. round(secs) .. " seconds since the last time!";
|
||||
end
|
||||
|
||||
return nil;
|
||||
end
|
||||
|
||||
function round(num)
|
||||
return math.floor(num + 0.5)
|
||||
local time = os.time();
|
||||
|
||||
function plugin(message, user)
|
||||
if(string.match(string.lower(message), "purple"))then
|
||||
local timedif = os.time() - time;
|
||||
time = os.time();
|
||||
days = (timedif / (60*60*24));
|
||||
hours = ((timedif / (60*60)) % 24);
|
||||
mins = ((timedif / (60)) % 60);
|
||||
secs = timedif % 60;
|
||||
return "*GASP!!!* \n" .. user.name .. " said **THE** word! It's been " .. round(days) .. " days, " .. round(hours) .. " hours, " .. round(mins) .. " minutes, and " .. round(secs) .. " seconds since the last time!";
|
||||
end
|
||||
|
||||
return nil;
|
||||
end
|
||||
|
||||
function round(num)
|
||||
return math.floor(num + 0.5)
|
||||
end
|
||||
@@ -9,21 +9,21 @@ public class CommandBeansShow extends Command
|
||||
public CommandBeansShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BeansShowInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("BeansShowInfo"); };
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.mentions == null)
|
||||
res.Call(String.format(LocStrings.Stub("BeansShowDisplay"), user.GetBeans()));
|
||||
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
|
||||
else
|
||||
{
|
||||
String mentionedBeans = "";
|
||||
for(KittyUser mentioned:input.mentions)
|
||||
{
|
||||
mentionedBeans += mentioned.name + " has " + mentioned.GetBeans() + " ";
|
||||
mentionedBeans += mentioned.name + " has " + mentioned.getBeans() + " ";
|
||||
}
|
||||
res.Call(String.format(LocStrings.Stub("BeansShowMentioned"), mentionedBeans));
|
||||
res.send(String.format(LocStrings.stub("BeansShowMentioned"), mentionedBeans));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,32 +25,32 @@ public class CommandBenchmark extends Command
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BenchmarkInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("BenchmarkInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.Update();
|
||||
framework.update();
|
||||
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
{
|
||||
String output = HelpText();
|
||||
res.Call(output);
|
||||
String output = getHelpText();
|
||||
res.send(output);
|
||||
return;
|
||||
}
|
||||
|
||||
BenchmarkFormattable commandOutput = null;
|
||||
synchronized(framework)
|
||||
{
|
||||
commandOutput = framework.Run(input.args.trim());
|
||||
commandOutput = framework.run(input.args.trim());
|
||||
}
|
||||
|
||||
if(commandOutput == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BenchmarkInvalid"));
|
||||
res.send(LocStrings.stub("BenchmarkInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
commandOutput.Call(res);
|
||||
commandOutput.call(res);
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,10 @@ public class CommandBetBeans extends Command
|
||||
public CommandBetBeans(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BetBeansInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("BetBeansInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String call = "";
|
||||
int bet = 0;
|
||||
@@ -24,41 +24,41 @@ public class CommandBetBeans extends Command
|
||||
bet = Integer.parseInt(input.args);
|
||||
if(bet < 50)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BetBeansLowBet"));
|
||||
res.send(LocStrings.stub("BetBeansLowBet"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BetBeansNotValid"));
|
||||
res.send(LocStrings.stub("BetBeansNotValid"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(user.GetBeans() < bet)
|
||||
if(user.getBeans() < bet)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BetBeansNotEnough"));
|
||||
res.send(LocStrings.stub("BetBeansNotEnough"));
|
||||
return;
|
||||
}
|
||||
|
||||
user.ChangeBeans(-bet);
|
||||
user.changeBeans(-bet);
|
||||
int [] slots = getSlots();
|
||||
call += slotString(slots);
|
||||
slots = sort(slots);
|
||||
|
||||
win = getWinning(slots);
|
||||
|
||||
res.Call(call);
|
||||
res.send(call);
|
||||
|
||||
if(win == 0)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BetBeansLose"));
|
||||
guild.beans.Add(bet);
|
||||
res.send(LocStrings.stub("BetBeansLose"));
|
||||
guild.beans.add(bet);
|
||||
return;
|
||||
}
|
||||
|
||||
user.ChangeBeans(bet*win);
|
||||
guild.beans.Subtract(bet*win);
|
||||
res.Call(String.format(LocStrings.Stub("BetBeansWin"), "" + (bet*win)));
|
||||
user.changeBeans(bet*win);
|
||||
guild.beans.subtract(bet*win);
|
||||
res.send(String.format(LocStrings.stub("BetBeansWin"), "" + (bet*win)));
|
||||
}
|
||||
|
||||
private int getWinning(int [] slots)
|
||||
|
||||
@@ -15,11 +15,11 @@ public class CommandBetHistory extends Command
|
||||
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BetHistoryInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("BetHistoryOutput"), guild.beans.Get()));
|
||||
res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get()));
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,12 @@ public class CommandBlurry extends Command
|
||||
public CommandBlurry(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BlurryInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
String filename = null;
|
||||
@@ -39,7 +39,7 @@ public class CommandBlurry extends Command
|
||||
{
|
||||
try
|
||||
{
|
||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
||||
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||
preProcessed = new File(filename);
|
||||
}
|
||||
catch(Exception e)
|
||||
@@ -48,12 +48,12 @@ public class CommandBlurry extends Command
|
||||
if(input.mentions != null)
|
||||
person = input.mentions[0];
|
||||
|
||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(filename == null)
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
ApplySnap(ImageIO.read(preProcessed), name);
|
||||
applySnap(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -61,13 +61,13 @@ public class CommandBlurry extends Command
|
||||
}
|
||||
|
||||
postProcessed = new File(name);
|
||||
res.CallFile(postProcessed, "png");
|
||||
res.sendFile(postProcessed, "png");
|
||||
|
||||
ImageUtils.BlockingFileDelete(preProcessed);
|
||||
ImageUtils.BlockingFileDelete(postProcessed);
|
||||
ImageUtils.blockingFileDelete(preProcessed);
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void ApplySnap(BufferedImage image, String name) throws IOException
|
||||
private static void applySnap(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
BufferedImage blurred = ImageUtils.copyImage(image);
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
|
||||
@@ -19,22 +19,22 @@ public class CommandBoop extends Command
|
||||
|
||||
public BoopTracker() { super("booptracker"); }
|
||||
|
||||
public void ApplyBoop()
|
||||
public void applyBoop()
|
||||
{
|
||||
++boops;
|
||||
MarkDirty();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public int HowMany()
|
||||
public int howMany()
|
||||
{
|
||||
return boops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Serialize() { return "" + boops; }
|
||||
public String serialize() { return "" + boops; }
|
||||
|
||||
@Override
|
||||
public void DeSerialzie(String string)
|
||||
public void deSerialzie(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -42,9 +42,9 @@ public class CommandBoop extends Command
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
GlobalLog.Warn(LogFilter.Command, "No valid value was found for boops! Starting over at 0!");
|
||||
GlobalLog.warn(LogFilter.Command, "No valid value was found for boops! Starting over at 0!");
|
||||
boops = 0;
|
||||
MarkDirty();
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,37 +60,37 @@ public class CommandBoop extends Command
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BoopInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("BoopInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.mentions == null)
|
||||
{
|
||||
boopTracker.ApplyBoop();
|
||||
res.Call(String.format(LocStrings.Stub("BoopStandard"), user.name, boopTracker.HowMany()));
|
||||
boopTracker.applyBoop();
|
||||
res.send(String.format(LocStrings.stub("BoopStandard"), user.name, boopTracker.howMany()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(input.mentions.length == 1)
|
||||
{
|
||||
boopTracker.ApplyBoop();
|
||||
res.Call(String.format(LocStrings.Stub("BoopPerson"), user.name, input.mentions[0].name));
|
||||
boopTracker.applyBoop();
|
||||
res.send(String.format(LocStrings.stub("BoopPerson"), user.name, input.mentions[0].name));
|
||||
return;
|
||||
}
|
||||
|
||||
String booped = "";
|
||||
for(int i = 0; i < input.mentions.length; i++)
|
||||
{
|
||||
boopTracker.ApplyBoop();
|
||||
boopTracker.applyBoop();
|
||||
if(i < input.mentions.length-1)
|
||||
booped += input.mentions[i].name + ", ";
|
||||
else
|
||||
booped += "and " + input.mentions[i].name;
|
||||
}
|
||||
|
||||
res.Call(String.format(LocStrings.Stub("BoopMultiple"), user.name, booped));
|
||||
res.send(String.format(LocStrings.stub("BoopMultiple"), user.name, booped));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,11 @@ public class CommandCatch extends Command
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CatchInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CatchInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File catchFile = null;
|
||||
@@ -48,13 +48,13 @@ public class CommandCatch extends Command
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String catchFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
String catchFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(catchFilename == null)
|
||||
return;
|
||||
|
||||
catcheeFile = new File(catchFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/catch/frames/", "catch ", 92, 18);
|
||||
builder.Overlay(ImageIO.read(catcheeFile), name);
|
||||
builder.overlay(ImageIO.read(catcheeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -62,10 +62,10 @@ public class CommandCatch extends Command
|
||||
}
|
||||
|
||||
catchFile = new File (name);
|
||||
res.CallFile(catchFile, "gif");
|
||||
res.sendFile(catchFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.BlockingFileDelete(catchFile);
|
||||
ImageUtils.BlockingFileDelete(catcheeFile);
|
||||
ImageUtils.blockingFileDelete(catchFile);
|
||||
ImageUtils.blockingFileDelete(catcheeFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ public class CommandChangeIndicator extends Command
|
||||
public CommandChangeIndicator(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("ChangeIndicatorInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("ChangeIndicatorInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String arg = input.args.trim();
|
||||
if(arg.length() == 0)
|
||||
{
|
||||
res.Call(LocStrings.Stub("ChangeIndicatorError"));
|
||||
res.send(LocStrings.stub("ChangeIndicatorError"));
|
||||
return;
|
||||
}
|
||||
|
||||
String indicator = arg.substring(0, 1);
|
||||
if(indicator.charAt(0) == '\n' || indicator.charAt(0) == '\t' || indicator.charAt(0) == '\r')
|
||||
{
|
||||
res.Call(LocStrings.Lookup("ChangeIndicatorError"));
|
||||
res.send(LocStrings.lookup("ChangeIndicatorError"));
|
||||
return;
|
||||
}
|
||||
|
||||
guild.SetCommandIndicator(indicator);
|
||||
res.Call(String.format(LocStrings.Stub("ChangeIndicatorChanged"), guild.GetCommandIndicator()));
|
||||
guild.setCommandIndicator(indicator);
|
||||
res.send(String.format(LocStrings.stub("ChangeIndicatorChanged"), guild.getCommandIndicator()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,22 +16,22 @@ public class CommandCharacterCreate extends Command
|
||||
public CommandCharacterCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CharacterCreateInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CharacterCreateInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String [] info = input.args.split(",");
|
||||
if(info.length < 3)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterCreateNullInfo"));
|
||||
res.send(LocStrings.stub("CharacterCreateNullInfo"));
|
||||
return;
|
||||
}
|
||||
if(CharacterManager.instance.addCharacter(user, info[0], info[1], info[2]))
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterCreateSuccess"));
|
||||
res.send(LocStrings.stub("CharacterCreateSuccess"));
|
||||
return;
|
||||
}
|
||||
res.Call(LocStrings.Stub("CharacterCreateDuplicate"));
|
||||
res.send(LocStrings.stub("CharacterCreateDuplicate"));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class CommandCharacterEditBio extends Command
|
||||
public CommandCharacterEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CharacterEditBioInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditBioInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -21,18 +21,18 @@ public class CommandCharacterEditBio extends Command
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditBioNotValid"));
|
||||
res.send(LocStrings.stub("CharacterEditBioNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editBio(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.Call(LocStrings.Stub("CharacterEditBioSuccess"));
|
||||
res.send(LocStrings.stub("CharacterEditBioSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditBioNotAuth"));
|
||||
res.send(LocStrings.stub("CharacterEditBioNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class CommandCharacterEditName extends Command
|
||||
public CommandCharacterEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CharacterEditNameInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditNameInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -21,18 +21,18 @@ public class CommandCharacterEditName extends Command
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditNameNotValid"));
|
||||
res.send(LocStrings.stub("CharacterEditNameNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editName(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.Call(LocStrings.Stub("CharacterEditNameSuccess"));
|
||||
res.send(LocStrings.stub("CharacterEditNameSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditNameNotAuth"));
|
||||
res.send(LocStrings.stub("CharacterEditNameNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ public class CommandCharacterEditURL extends Command
|
||||
public CommandCharacterEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CharacterEditURLInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditURLInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -21,18 +21,18 @@ public class CommandCharacterEditURL extends Command
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditURLNotValid"));
|
||||
res.send(LocStrings.stub("CharacterEditURLNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editRefImage(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.Call(LocStrings.Stub("CharacterEditURLSuccess"));
|
||||
res.send(LocStrings.stub("CharacterEditURLSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterEditURLNotAuth"));
|
||||
res.send(LocStrings.stub("CharacterEditURLNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,29 +12,29 @@ public class CommandCharacterSearch extends Command
|
||||
public CommandCharacterSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CharacterSearchInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("CharacterSearchInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input.args);
|
||||
if(characters.size() < 1)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterSearchNoCharacterFound"));
|
||||
res.send(LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||
return;
|
||||
}
|
||||
if(characters.size() > 1)
|
||||
{
|
||||
res.Call(LocStrings.Stub("CharacterSearchMultipleCharacterHeader"));
|
||||
res.send(LocStrings.stub("CharacterSearchMultipleCharacterHeader"));
|
||||
for(KittyCharacter character:characters)
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("CharacterSearchMultipleCharacter"), character.getName(), character.getOwner().name, character.getUID()));
|
||||
res.send(String.format(LocStrings.stub("CharacterSearchMultipleCharacter"), character.getName(), character.getOwner().name, character.getUID()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("CharacterSearchOneCharacter"), characters.get(0).getOwner().name, characters.get(0).getName(), characters.get(0).getBio(), characters.get(0).getRefImage(), characters.get(0).getUID()));
|
||||
res.send(String.format(LocStrings.stub("CharacterSearchOneCharacter"), characters.get(0).getOwner().name, characters.get(0).getName(), characters.get(0).getBio(), characters.get(0).getRefImage(), characters.get(0).getUID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,14 @@ public class CommandChoose extends Command
|
||||
public CommandChoose(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("ChooseInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("ChooseInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args.trim().length() == 0)
|
||||
{
|
||||
res.Call(Stats.instance.GetHelpText(input.key));
|
||||
res.send(Stats.instance.getHelpText(input.key));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ public class CommandChoose extends Command
|
||||
|
||||
if(choices.length == 1)
|
||||
{
|
||||
res.Call(LocStrings.Stub("ChooseOne"));
|
||||
res.send(LocStrings.stub("ChooseOne"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(String.format(LocStrings.Stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString()));
|
||||
res.send(String.format(LocStrings.stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,18 @@ public class CommandColiru extends Command
|
||||
public CommandColiru(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("ColiruInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("ColiruInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args.trim().length() < 1)
|
||||
{
|
||||
res.Call(LocStrings.Stub("ColiruError"));
|
||||
res.send(LocStrings.stub("ColiruError"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(compiler.compileCPlus(input.args));
|
||||
res.send(compiler.compileCPlusPlus(input.args));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package commands;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
@@ -16,37 +15,69 @@ import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import network.NetworkTheColorAPI;
|
||||
import network.NetworkTheColorAPI.ColorData;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandColor extends Command
|
||||
{
|
||||
private NetworkTheColorAPI theColorAPI = new NetworkTheColorAPI();
|
||||
|
||||
public CommandColor(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("ColorInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("ColorInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
int sideLength = 50;
|
||||
// First, try and parse out the color to make sure we can even get it.
|
||||
ColorData colorData = theColorAPI.lookupHex(input.args.trim());
|
||||
|
||||
float r = 0;
|
||||
float g = 0;
|
||||
float b = 0;
|
||||
float a = 1;
|
||||
// Verify the color was even found
|
||||
if(colorData == null)
|
||||
{
|
||||
res.send(LocStrings.stub("ColorNotSearchable"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the variables we'll be using based on the color, and get the color itself.
|
||||
int sideLength = 80; // It's 80x80 because as far as I know, that's the size of a thumbnail in discord.
|
||||
int r = colorData.rgb.r;
|
||||
int g = colorData.rgb.g;
|
||||
int b = colorData.rgb.b;
|
||||
int a = 255; // Alpha not supported at this time
|
||||
Color parsed = new Color(r, g, b, a);
|
||||
|
||||
// Construct the image example file that we intend to display locally
|
||||
BufferedImage img = new BufferedImage(sideLength, sideLength, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
graphics.setColor(parsed);
|
||||
graphics.fillRect(0, 0, sideLength, sideLength);
|
||||
graphics.dispose();
|
||||
|
||||
String tempFileName = ImageUtils.writeTempImageData(img, ".png");
|
||||
File file = new File(tempFileName);
|
||||
|
||||
// Build the response
|
||||
KittyEmbed response = new KittyEmbed();
|
||||
String postEntry = ", ";
|
||||
response.title = colorData.name.value + (colorData.name.exact_match_name ? "" : " (ish)");
|
||||
response.color = parsed;
|
||||
response.thumbnailURL = "attachment://test.png";
|
||||
response.descriptionText = "```";
|
||||
response.descriptionText += "\n hex: #" + colorData.hex.clean;
|
||||
response.descriptionText += "\n rgb: " + String.format("%1$03d", r) + postEntry + String.format("%1$03d", g) + postEntry + String.format("%1$03d", b);
|
||||
response.descriptionText += "\n hsl: " + String.format("%1$03d", colorData.hsl.h) + postEntry + String.format("%1$02d", colorData.hsl.s) + "%" + postEntry + String.format("%1$02d", colorData.hsl.l) + "%";
|
||||
response.descriptionText += "\n hsv: " + String.format("%1$03d", colorData.hsv.h) + postEntry + String.format("%1$02d", colorData.hsv.s) + "%" + postEntry + String.format("%1$02d", colorData.hsv.v) + "%";
|
||||
response.descriptionText += "\n xyz: " + String.format("%1$03d", colorData.XYZ.X) + postEntry + String.format("%1$03d", colorData.XYZ.Y) + postEntry + String.format("%1$03d", colorData.XYZ.Z);
|
||||
response.descriptionText += "\ncmyk: " + String.format("%1$03d", colorData.cmyk.c) + postEntry + String.format("%1$03d", colorData.cmyk.m) + postEntry + String.format("%1$03d", colorData.cmyk.y) + postEntry + String.format("%1$03d", colorData.cmyk.k);
|
||||
response.descriptionText += "```";
|
||||
response.thumbnailURL = "attachment://" + tempFileName;
|
||||
response.footerText = "All percentages and values are rounded to the nearest whole number!" + (colorData.name.exact_match_name ? "" : " '" + colorData.name.value + "' is actually " + colorData.name.closest_named_hex + ".");
|
||||
|
||||
res.CallEmbed(response);
|
||||
//ImageIO.write(bufferedImage, "png", file);
|
||||
// Send then delete the temp local files
|
||||
res.send(response);
|
||||
ImageUtils.blockingFileDelete(file);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ public class CommandCrouton extends Command
|
||||
public CommandCrouton(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("CroutonInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("CroutonInfo"); };
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.authorImage = "https://crouton.net/crouton.png";
|
||||
@@ -34,7 +34,7 @@ public class CommandCrouton extends Command
|
||||
|
||||
embed.imageURL = "https://crouton.net/crouton.png";
|
||||
|
||||
res.CallEmbed(embed);
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public class CommandDBFlush extends Command
|
||||
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("DBFlushInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
int numUpdated = DatabaseManager.instance.upkeep();
|
||||
|
||||
@@ -30,6 +30,6 @@ public class CommandDBFlush extends Command
|
||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||
embed.color = Config.ColorDefault;
|
||||
|
||||
res.CallEmbed(embed);
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ public class CommandDBStats extends Command
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("DBStatsInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database Info";
|
||||
@@ -38,6 +38,6 @@ public class CommandDBStats extends Command
|
||||
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
||||
embed.color = Config.ColorDefault;
|
||||
|
||||
res.CallEmbed(embed);
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ public class CommandDoWork extends Command
|
||||
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("DoWorkInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
long thispieceofshit = 0;
|
||||
@@ -28,6 +28,6 @@ public class CommandDoWork extends Command
|
||||
thispieceofshit += Math.log((double)i);
|
||||
}
|
||||
|
||||
res.Call(LocStrings.Stub("DoWorkFinished"));
|
||||
res.send(LocStrings.stub("DoWorkFinished"));
|
||||
}
|
||||
}
|
||||
@@ -8,41 +8,41 @@ public class CommandEightBall extends Command
|
||||
{
|
||||
String [] answers =
|
||||
{
|
||||
LocStrings.Stub("EightBallYes1")
|
||||
, LocStrings.Stub("EightBallYes2")
|
||||
, LocStrings.Stub("EightBallYes3")
|
||||
, LocStrings.Stub("EightBallYes4")
|
||||
, LocStrings.Stub("EightBallYes5")
|
||||
, LocStrings.Stub("EightBallYes6")
|
||||
, LocStrings.Stub("EightBallYes7")
|
||||
, LocStrings.Stub("EightBallYes8")
|
||||
, LocStrings.Stub("EightBallYes9")
|
||||
, LocStrings.Stub("EightBallYes10")
|
||||
LocStrings.stub("EightBallYes1")
|
||||
, LocStrings.stub("EightBallYes2")
|
||||
, LocStrings.stub("EightBallYes3")
|
||||
, LocStrings.stub("EightBallYes4")
|
||||
, LocStrings.stub("EightBallYes5")
|
||||
, LocStrings.stub("EightBallYes6")
|
||||
, LocStrings.stub("EightBallYes7")
|
||||
, LocStrings.stub("EightBallYes8")
|
||||
, LocStrings.stub("EightBallYes9")
|
||||
, LocStrings.stub("EightBallYes10")
|
||||
|
||||
, LocStrings.Stub("EightBallMaybe1")
|
||||
, LocStrings.Stub("EightBallMaybe2")
|
||||
, LocStrings.Stub("EightBallMaybe3")
|
||||
, LocStrings.Stub("EightBallMaybe4")
|
||||
, LocStrings.Stub("EightBallMaybe5")
|
||||
, LocStrings.stub("EightBallMaybe1")
|
||||
, LocStrings.stub("EightBallMaybe2")
|
||||
, LocStrings.stub("EightBallMaybe3")
|
||||
, LocStrings.stub("EightBallMaybe4")
|
||||
, LocStrings.stub("EightBallMaybe5")
|
||||
|
||||
, LocStrings.Stub("EightBallNo1")
|
||||
, LocStrings.Stub("EightBallNo2")
|
||||
, LocStrings.Stub("EightBallNo3")
|
||||
, LocStrings.Stub("EightBallNo4")
|
||||
, LocStrings.Stub("EightBallNo5")
|
||||
, LocStrings.stub("EightBallNo1")
|
||||
, LocStrings.stub("EightBallNo2")
|
||||
, LocStrings.stub("EightBallNo3")
|
||||
, LocStrings.stub("EightBallNo4")
|
||||
, LocStrings.stub("EightBallNo5")
|
||||
};
|
||||
|
||||
public CommandEightBall(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("EightBallInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("EightBallInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args.trim().length() < 1)
|
||||
res.Call(LocStrings.Stub("EightBallError"));
|
||||
res.send(LocStrings.stub("EightBallError"));
|
||||
|
||||
res.Call(answers[(int) (Math.random()*answers.length)]);
|
||||
res.send(answers[(int) (Math.random()*answers.length)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ public class CommandFetch extends Command
|
||||
public CommandFetch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("FetchInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("FetchInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String emote = input.args.split(" ")[0];
|
||||
if(emote.startsWith("<") && emote.endsWith(">"))
|
||||
@@ -27,30 +27,30 @@ public class CommandFetch extends Command
|
||||
switch(num)
|
||||
{
|
||||
case 1:
|
||||
res.Call(String.format(LocStrings.Stub("FetchBringBack"), emote));
|
||||
res.send(String.format(LocStrings.stub("FetchBringBack"), emote));
|
||||
break;
|
||||
case 2:
|
||||
res.Call(String.format(LocStrings.Stub("FetchRunAway")));
|
||||
res.send(String.format(LocStrings.stub("FetchRunAway")));
|
||||
break;
|
||||
case 3:
|
||||
res.Call(String.format(LocStrings.Stub("FetchBringBackWrong"), guild.emoji.get((int)(Math.random() * guild.emoji.size()) + 1)));
|
||||
res.send(String.format(LocStrings.stub("FetchBringBackWrong"), guild.emoji.get((int)(Math.random() * guild.emoji.size()) + 1)));
|
||||
break;
|
||||
case 4:
|
||||
res.Call(String.format(LocStrings.Stub("FetchEat"), emote));
|
||||
res.send(String.format(LocStrings.stub("FetchEat"), emote));
|
||||
break;
|
||||
case 5:
|
||||
res.Call(String.format(LocStrings.Stub("FetchCatchRun"), emote));
|
||||
res.send(String.format(LocStrings.stub("FetchCatchRun"), emote));
|
||||
break;
|
||||
case 6:
|
||||
res.Call(String.format(LocStrings.Stub("FetchStare"), user.name));
|
||||
res.send(String.format(LocStrings.stub("FetchStare"), user.name));
|
||||
break;
|
||||
default:
|
||||
res.Call("" + num);
|
||||
res.send("" + num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("FetchError")));
|
||||
res.send(String.format(LocStrings.stub("FetchError")));
|
||||
System.out.println(emote);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ public class CommandGiveBeans extends Command
|
||||
public CommandGiveBeans (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("GiveBeansInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("GiveBeansInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// First, make sure someone is mentioned
|
||||
if(input.mentions == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("GiveBeansNoneMentioned"));
|
||||
res.send(LocStrings.stub("GiveBeansNoneMentioned"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,15 +42,15 @@ public class CommandGiveBeans extends Command
|
||||
// If there wasn't a number we could find, well, nothing we can do.
|
||||
if(beans == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("GiveBeansInvalid"));
|
||||
res.send(LocStrings.stub("GiveBeansInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Go through all the mentions and make sure every user is given beans!
|
||||
for(int i = 0; i < input.mentions.length; i++)
|
||||
{
|
||||
input.mentions[i].ChangeBeans(beans);
|
||||
res.Call(String.format(LocStrings.Stub("GiveBeansSuccess"), input.mentions[i].name, "" + beans));
|
||||
input.mentions[i].changeBeans(beans);
|
||||
res.send(String.format(LocStrings.stub("GiveBeansSuccess"), input.mentions[i].name, "" + beans));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,26 +15,26 @@ public class CommandGuildRoleAdd extends Command
|
||||
public CommandGuildRoleAdd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("GuildRoleAddInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleAddInfo"); };
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String role = input.args.split(" ")[0];
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
if(guild.control.addRole(user.discordID, role))
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleAddSuccess"), role, user.name));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleAddSuccess"), role, user.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleAddFailure"), role, user.name));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleAddFailure"), role, user.name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleAddNotAllowed"), role));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleAddNotAllowed"), role));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ public class CommandGuildRoleAllowed extends Command
|
||||
public CommandGuildRoleAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("GuildRoleAllowedInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleAllowedInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String [] roles = input.args.split(",");
|
||||
String role;
|
||||
@@ -27,12 +27,12 @@ public class CommandGuildRoleAllowed extends Command
|
||||
role = roles[i].trim();
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
res.Call(LocStrings.Stub("GuildRoleAllowedDuplicate"));
|
||||
res.send(LocStrings.stub("GuildRoleAllowedDuplicate"));
|
||||
}
|
||||
else
|
||||
{
|
||||
guild.roleList.add(role);
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleAllowedSuccess"), role));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleAllowedSuccess"), role));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ public class CommandGuildRoleList extends Command
|
||||
public CommandGuildRoleList(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String roles = "";
|
||||
if(guild.roleList.isEmpty())
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleListEmpty")));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleListEmpty")));
|
||||
return;
|
||||
}
|
||||
for(int i = 0; i < guild.roleList.size(); i++)
|
||||
@@ -26,6 +26,6 @@ public class CommandGuildRoleList extends Command
|
||||
roles += " and ";
|
||||
roles += guild.roleList.get(i);
|
||||
}
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleListOutput"), roles));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleListOutput"), roles));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ public class CommandGuildRoleNotAllowed extends Command
|
||||
public CommandGuildRoleNotAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("GuildRoleNotAllowedInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleNotAllowedInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String [] roles = input.args.split(",");
|
||||
String role;
|
||||
@@ -28,11 +28,11 @@ public class CommandGuildRoleNotAllowed extends Command
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
guild.roleList.remove(role);
|
||||
res.Call(LocStrings.Stub("GuildRoleNotAllowedSuccess"));
|
||||
res.send(LocStrings.stub("GuildRoleNotAllowedSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleNotAllowedFailure"), role));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleNotAllowedFailure"), role));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,26 +15,26 @@ public class CommandGuildRoleRemove extends Command
|
||||
public CommandGuildRoleRemove(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("GuildRoleRemoveInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("GuildRoleRemoveInfo"); };
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String role = input.args.split(" ")[0];
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
if(guild.control.removeRole(user.discordID, role))
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleRemoveSuccess"), role, user.name));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleRemoveSuccess"), role, user.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleRemoveFailure"), role, user.name));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleRemoveFailure"), role, user.name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("GuildRoleRemoveNotAllowed"), role));
|
||||
res.send(String.format(LocStrings.stub("GuildRoleRemoveNotAllowed"), role));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,19 +15,19 @@ public class CommandHelp extends Command
|
||||
public CommandHelp(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("HelpInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("HelpInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String help = Stats.instance.GetHelpText(input.args);
|
||||
String help = Stats.instance.getHelpText(input.args);
|
||||
|
||||
if(help == null)
|
||||
{
|
||||
help = LocStrings.Stub("HelpDisplay");
|
||||
help = LocStrings.stub("HelpDisplay");
|
||||
}
|
||||
|
||||
res.Call(help);
|
||||
res.send(help);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,10 +26,10 @@ public class CommandHelpBuilder extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("HelpBuilderInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Holds command groups
|
||||
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
||||
@@ -39,18 +39,18 @@ public class CommandHelpBuilder extends Command {
|
||||
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
||||
|
||||
// Sort commands out
|
||||
ArrayList<Command> commands = Stats.instance.GetAllCommands();
|
||||
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
Command current = commands.get(i);
|
||||
commandsByRole.get(current.RequiredRole()).add(current);
|
||||
commandsByRole.get(current.requiredRole()).add(current);
|
||||
}
|
||||
|
||||
// Format outstring and send it back for now
|
||||
String out = "";
|
||||
out += PopulateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||
out += PopulateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||
out += PopulateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||
|
||||
// Write out file
|
||||
String filename = "buildhelp_out.txt";
|
||||
@@ -63,17 +63,17 @@ public class CommandHelpBuilder extends Command {
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
GlobalLog.Error(e.toString());
|
||||
GlobalLog.error(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
File file = new File(filename);
|
||||
res.CallFile(file, "txt");
|
||||
ImageUtils.BlockingFileDelete(file);
|
||||
res.sendFile(file, "txt");
|
||||
ImageUtils.blockingFileDelete(file);
|
||||
}
|
||||
|
||||
// Generates the section for a specific role, optionally adding spacing after for another section
|
||||
private String PopulateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
||||
private String populateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
||||
{
|
||||
// Formatting variables
|
||||
final String headerStart = "<h2>";
|
||||
@@ -112,7 +112,7 @@ public class CommandHelpBuilder extends Command {
|
||||
commandsSoFar.add(command);
|
||||
|
||||
// Write out all the keys and the help text
|
||||
ArrayList<String> keys = command.RegisteredNames();
|
||||
ArrayList<String> keys = command.registeredNames();
|
||||
for(int j = 0; j < keys.size(); ++j)
|
||||
{
|
||||
if(j != 0)
|
||||
@@ -121,7 +121,7 @@ public class CommandHelpBuilder extends Command {
|
||||
accumulated += leadStart + keys.get(j) + leadEnd;
|
||||
}
|
||||
|
||||
accumulated += leadFollow + commands.get(i).HelpText() + lineDelimiter;;
|
||||
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
||||
}
|
||||
|
||||
accumulated += sectionEnd;
|
||||
|
||||
@@ -15,11 +15,11 @@ public class CommandInfo extends Command
|
||||
public CommandInfo(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("InfoInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("InfoInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.Call(LocStrings.Stub("InfoResponse"));
|
||||
res.send(LocStrings.stub("InfoResponse"));
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@ public class CommandInvite extends Command
|
||||
public CommandInvite(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("InviteInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("InviteInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.Call("https://discordapp.com/oauth2/authorize?&client_id="+ Ref.CliID
|
||||
res.send("https://discordapp.com/oauth2/authorize?&client_id="+ Ref.CliID
|
||||
+"&scope=bot&permissions=8");
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,17 @@ public class CommandJDoodle extends Command
|
||||
public CommandJDoodle(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("JDoodleInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("JDoodleInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args.trim().length() < 1)
|
||||
{
|
||||
res.Call(LocStrings.Stub("JDoodleError"));
|
||||
res.send(LocStrings.stub("JDoodleError"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(compiler.compileJava(input.args));
|
||||
res.send(compiler.compileJava(input.args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ public class CommandLeaderboard extends Command
|
||||
public CommandLeaderboard(KittyRole roleLevel, KittyRating contentRating) { super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("LeaderboardInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("LeaderboardInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Start by force-flushing. We need to be up-to-date.
|
||||
GlobalLog.Log("Flushed database for " + DatabaseManager.instance.upkeep() + " items.");
|
||||
GlobalLog.log("Flushed database for " + DatabaseManager.instance.upkeep() + " items.");
|
||||
|
||||
// Get all users associated with a guild and get their bean count
|
||||
String guildID = guild.uniqueID;
|
||||
@@ -74,13 +74,13 @@ public class CommandLeaderboard extends Command
|
||||
return (int)difference;
|
||||
});
|
||||
|
||||
GlobalLog.Log(LogFilter.Command, "Sorted through " + users.size() + " KittyUsers for leaderboard purposes.");
|
||||
GlobalLog.log(LogFilter.Command, "Sorted through " + users.size() + " KittyUsers for leaderboard purposes.");
|
||||
|
||||
// Configure output
|
||||
final int listSize = 10;
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.color = Config.ColorDefault;
|
||||
embed.title = LocStrings.Stub("LeaderboardTitle");
|
||||
embed.title = LocStrings.stub("LeaderboardTitle");
|
||||
embed.descriptionText = "";
|
||||
|
||||
for(int i = 0; i < listSize && i < users.size(); ++i)
|
||||
@@ -94,6 +94,6 @@ public class CommandLeaderboard extends Command
|
||||
}
|
||||
|
||||
// Write out embed result
|
||||
res.CallEmbed(embed);
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class CommandMap extends Command
|
||||
public CommandMap(KittyRole roleLevel, KittyRating contentRating) { super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return String.format(LocStrings.Stub("MapInfo"), "" + MaxWidth, "" + MaxHeight); }
|
||||
public String getHelpText() { return String.format(LocStrings.stub("MapInfo"), "" + MaxWidth, "" + MaxHeight); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Variables
|
||||
int width = 35;
|
||||
@@ -43,24 +43,24 @@ public class CommandMap extends Command
|
||||
{
|
||||
OptionParser parser = new OptionParser(input.args);
|
||||
|
||||
String seedStr = parser.GetOption("-s", true);
|
||||
String seedStr = parser.getOption("-s", true);
|
||||
if(seedStr != null)
|
||||
{
|
||||
seed = Long.parseLong(seedStr);
|
||||
hasSeed = true;
|
||||
}
|
||||
|
||||
String widthStr = parser.GetOption("-w", true);
|
||||
String widthStr = parser.getOption("-w", true);
|
||||
if(widthStr != null)
|
||||
width = ValidateSize(Integer.parseInt(widthStr), MaxWidth);
|
||||
width = validateSize(Integer.parseInt(widthStr), MaxWidth);
|
||||
|
||||
String heightStr = parser.GetOption("-h", true);
|
||||
String heightStr = parser.getOption("-h", true);
|
||||
if(heightStr != null)
|
||||
height = ValidateSize(Integer.parseInt(heightStr), MaxHeight);
|
||||
height = validateSize(Integer.parseInt(heightStr), MaxHeight);
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("MapInvalid"));
|
||||
res.send(LocStrings.stub("MapInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,22 +76,22 @@ public class CommandMap extends Command
|
||||
}
|
||||
|
||||
// Response header creation
|
||||
header += LocStrings.Stub("MapVersion") + "\n";
|
||||
header += LocStrings.Stub("MapSeed") + ": `" + seed + "`, ";
|
||||
header += LocStrings.Stub("MapWidth") + "`"+ width +"`, ";
|
||||
header += LocStrings.Stub("MapHeight") + ": `"+ height + "`\n";
|
||||
header += LocStrings.stub("MapVersion") + "\n";
|
||||
header += LocStrings.stub("MapSeed") + ": `" + seed + "`, ";
|
||||
header += LocStrings.stub("MapWidth") + "`"+ width +"`, ";
|
||||
header += LocStrings.stub("MapHeight") + ": `"+ height + "`\n";
|
||||
|
||||
// Response body creation
|
||||
body += "```\n";
|
||||
body += GenerateMap(width, height, randGenerator);
|
||||
body += generateMap(width, height, randGenerator);
|
||||
body += "\n```";
|
||||
|
||||
// Send back the map
|
||||
res.Call(header + body);
|
||||
res.send(header + body);
|
||||
}
|
||||
|
||||
// Verifies and appropriately caps input as necessary
|
||||
int ValidateSize(int input, int max)
|
||||
int validateSize(int input, int max)
|
||||
{
|
||||
if(input < 0)
|
||||
throw new NumberFormatException();
|
||||
@@ -104,7 +104,7 @@ public class CommandMap extends Command
|
||||
|
||||
|
||||
// Does the map generation
|
||||
String GenerateMap(int width, int height, Random gen)
|
||||
String generateMap(int width, int height, Random gen)
|
||||
{
|
||||
String landscape[][] = new String[width][height];
|
||||
int r1 = rand(gen);
|
||||
|
||||
@@ -23,12 +23,12 @@ public class CommandPerish extends Command
|
||||
public CommandPerish(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PerishInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("PerishInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
String filename = null;
|
||||
@@ -45,7 +45,7 @@ public class CommandPerish extends Command
|
||||
{
|
||||
try
|
||||
{
|
||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
||||
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||
preProcessed = new File(filename);
|
||||
}
|
||||
catch(Exception e)
|
||||
@@ -54,12 +54,12 @@ public class CommandPerish extends Command
|
||||
if(input.mentions != null)
|
||||
person = input.mentions[0];
|
||||
|
||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(filename == null)
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
ApplyTintEffect(ImageIO.read(preProcessed), name);
|
||||
applyTintEffect(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -67,13 +67,13 @@ public class CommandPerish extends Command
|
||||
}
|
||||
|
||||
postProcessed = new File(name);
|
||||
res.CallFile(postProcessed, "png");
|
||||
res.sendFile(postProcessed, "png");
|
||||
|
||||
ImageUtils.BlockingFileDelete(preProcessed);
|
||||
ImageUtils.BlockingFileDelete(postProcessed);
|
||||
ImageUtils.blockingFileDelete(preProcessed);
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void ApplyTintEffect(BufferedImage image, String name) throws IOException
|
||||
private static void applyTintEffect(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
for(int x = 0; x < image.getWidth(); ++x)
|
||||
|
||||
@@ -15,12 +15,12 @@ public class CommandPing extends Command
|
||||
public CommandPing(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PingInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("PingInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
res.Call(LocStrings.Stub("PingResponse"));
|
||||
res.send(LocStrings.stub("PingResponse"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,23 +14,23 @@ public class CommandPollManage extends Command
|
||||
public CommandPollManage(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PollManageInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("PollManageInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
switch(input.args.split(" ")[0].toLowerCase())
|
||||
{
|
||||
case "start":
|
||||
res.Call(guild.startPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
res.send(guild.startPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "choice":
|
||||
res.Call(guild.addChoiceToPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
res.send(guild.addChoiceToPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "stop":
|
||||
res.Call(guild.endPoll());
|
||||
res.send(guild.endPoll());
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -10,10 +10,10 @@ public class CommandPollResults extends Command
|
||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PollResultsInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("PollResultsInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String results = "";
|
||||
int totalVotes = 0;
|
||||
@@ -28,9 +28,9 @@ public class CommandPollResults extends Command
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
results += String.format(LocStrings.Stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100));
|
||||
results += String.format(LocStrings.stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100));
|
||||
}
|
||||
|
||||
res.Call(results);
|
||||
res.send(results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,23 @@ public class CommandPollShow extends Command
|
||||
public CommandPollShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PollShowInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("PollShowInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(!guild.polling)
|
||||
{
|
||||
res.Call(LocStrings.Stub("PollShowNoPoll"));
|
||||
res.send(LocStrings.stub("PollShowNoPoll"));
|
||||
return;
|
||||
}
|
||||
String poll = String.format(LocStrings.Stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.Stub("PollShowChoices");
|
||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.stub("PollShowChoices");
|
||||
for(int i = 0; i < guild.choices.size(); i++)
|
||||
{
|
||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||
}
|
||||
|
||||
res.Call(poll);
|
||||
res.send(poll);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ public class CommandPollVote extends Command
|
||||
public CommandPollVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("PollVoteInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("PollVoteInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.polling)
|
||||
{
|
||||
if(guild.hasVoted.contains(user.uniqueID))
|
||||
{
|
||||
res.Call(LocStrings.Stub("PollVoteAlreadyVoted"));
|
||||
res.send(LocStrings.stub("PollVoteAlreadyVoted"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
@@ -25,23 +25,23 @@ public class CommandPollVote extends Command
|
||||
int voteNum = Integer.parseInt(input.args)-1;
|
||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("PollVoteNotValidVote"), voteNum));
|
||||
res.send(String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||
return;
|
||||
}
|
||||
|
||||
KittyPoll polled = guild.choices.get(voteNum);
|
||||
polled.votes++;
|
||||
guild.hasVoted.add(user.uniqueID);
|
||||
res.Call(LocStrings.Stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
res.send(LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("PollVoteNotValidNumber"));
|
||||
res.send(LocStrings.stub("PollVoteNotValidNumber"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
res.Call(LocStrings.Stub("PollVoteNoPoll"));
|
||||
res.send(LocStrings.stub("PollVoteNoPoll"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public class CommandRPEnd extends Command
|
||||
public CommandRPEnd (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RPEndInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RPEndInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
File sending = null;
|
||||
|
||||
@@ -32,12 +32,12 @@ public class CommandRPEnd extends Command
|
||||
|
||||
if(sending != null)
|
||||
{
|
||||
res.CallFile(sending, "txt");
|
||||
res.Call(LocStrings.Stub("RPEndFileOut"));
|
||||
res.sendFile(sending, "txt");
|
||||
res.send(LocStrings.stub("RPEndFileOut"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("RPEndError"));
|
||||
res.send(LocStrings.stub("RPEndError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,31 +23,31 @@ public class CommandRPG extends Command
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RPGInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("RPGInfo"); };
|
||||
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
{
|
||||
String output = HelpText();
|
||||
res.Call(output);
|
||||
String output = getHelpText();
|
||||
res.send(output);
|
||||
return;
|
||||
}
|
||||
|
||||
String result = null;
|
||||
synchronized(framework)
|
||||
{
|
||||
result = framework.Run(user.uniqueID, input.args.trim());
|
||||
result = framework.run(user.uniqueID, input.args.trim());
|
||||
}
|
||||
|
||||
if(result == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("RPGInvalid"));
|
||||
res.send(LocStrings.stub("RPGInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(result);
|
||||
res.send(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ public class CommandRPStart extends Command
|
||||
public CommandRPStart (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RPStartInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RPStartInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
ArrayList <KittyUser> users = new ArrayList<KittyUser>();
|
||||
users.add(user);
|
||||
@@ -27,6 +27,6 @@ public class CommandRPStart extends Command
|
||||
}
|
||||
}
|
||||
|
||||
res.Call(RPManager.instance.newRP(channel, users));
|
||||
res.send(RPManager.instance.newRP(channel, users));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,18 @@ public class CommandRaffleEnd extends Command
|
||||
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RaffleEndInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RaffleEndInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.endRaffle())
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleEndSuccess"));
|
||||
res.send(LocStrings.stub("RaffleEndSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleEndFailure"));
|
||||
res.send(LocStrings.stub("RaffleEndFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,18 @@ public class CommandRaffleJoin extends Command
|
||||
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RaffleJoinInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RaffleJoinInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.joinRaffle(user))
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleJoinSuccess"));
|
||||
res.send(LocStrings.stub("RaffleJoinSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleJoinFailure"));
|
||||
res.send(LocStrings.stub("RaffleJoinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,18 @@ public class CommandRaffleSpin extends Command
|
||||
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RaffleSpinInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RaffleSpinInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
res.send(String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleSpinFailure"));
|
||||
res.send(LocStrings.stub("RaffleSpinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@ public class CommandRaffleStart extends Command
|
||||
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RaffleStartInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RaffleStartInfo"); }
|
||||
|
||||
public int beanCost;
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -30,13 +30,14 @@ public class CommandRaffleStart extends Command
|
||||
{
|
||||
beanCost = 100;
|
||||
}
|
||||
|
||||
if(guild.startRaffle(beanCost))
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("RaffleStartSuccess"), beanCost));
|
||||
res.send(String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.Call(LocStrings.Stub("RaffleStartFailure"));
|
||||
res.send(LocStrings.stub("RaffleStartFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ public class CommandRating extends Command
|
||||
public CommandRating(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RatingInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RatingInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String newRating = null;
|
||||
switch(input.args.toLowerCase().trim())
|
||||
@@ -55,11 +55,11 @@ public class CommandRating extends Command
|
||||
}
|
||||
|
||||
if(newRating != null)
|
||||
res.Call(LocStrings.Stub("RatingChanged") + " " + newRating);
|
||||
res.send(LocStrings.stub("RatingChanged") + " " + newRating);
|
||||
else
|
||||
res.Call(LocStrings.Stub("RatingInvalid") + " `" + input.args + "`");
|
||||
res.send(LocStrings.stub("RatingInvalid") + " `" + input.args + "`");
|
||||
|
||||
if(newRating.equals("Filtered"))
|
||||
res.Call(LocStrings.Stub("RatingWarning"));
|
||||
res.send(LocStrings.stub("RatingWarning"));
|
||||
}
|
||||
}
|
||||
@@ -9,20 +9,20 @@ public class CommandRole extends Command
|
||||
public CommandRole (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RoleInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RoleInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args.isEmpty())
|
||||
{
|
||||
res.Call(LocStrings.Stub("RoleStandardResponse") + " " + user.GetRole().name() + "!");
|
||||
res.send(LocStrings.stub("RoleStandardResponse") + " " + user.getRole().name() + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(user.GetRole().getValue() < KittyRole.Admin.getValue())
|
||||
if(user.getRole().getValue() < KittyRole.Admin.getValue())
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("RoleError"), KittyRole.Admin.toString()));
|
||||
res.send(String.format(LocStrings.stub("RoleError"), KittyRole.Admin.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,16 +46,16 @@ public class CommandRole extends Command
|
||||
break;
|
||||
|
||||
default:
|
||||
res.Call(LocStrings.Stub("RoleNeededRole"));
|
||||
res.send(LocStrings.stub("RoleNeededRole"));
|
||||
return;
|
||||
}
|
||||
String users = "";
|
||||
for(int i = 0; i < input.mentions.length; i++)
|
||||
{
|
||||
input.mentions[i].ChangeRole(newRole);
|
||||
input.mentions[i].changeRole(newRole);
|
||||
users += input.mentions[i].name + " ";
|
||||
}
|
||||
|
||||
res.Call(String.format(LocStrings.Stub("RoleChanged"), users, newRole.name()));
|
||||
res.send(String.format(LocStrings.stub("RoleChanged"), users, newRole.name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,18 @@ public class CommandRoll extends Command
|
||||
public CommandRoll(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("RollInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("RollInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
res.Call(rollDice(input.args));
|
||||
res.send(rollDice(input.args));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("RollError"));
|
||||
res.send(LocStrings.stub("RollError"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ public class CommandShutdown extends Command
|
||||
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("ShutdownInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
// Flag the shutdown immediately.
|
||||
Stats.instance.IndicateShutdown();
|
||||
Stats.instance.indicateShutdown();
|
||||
|
||||
boolean isSafe = false;
|
||||
switch(input.args.toLowerCase().trim())
|
||||
@@ -41,21 +41,19 @@ public class CommandShutdown extends Command
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isSafe)
|
||||
{
|
||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
||||
res.CallImmediate(LocStrings.Stub("ShutdownSafe"));
|
||||
res.sendImmediate(LocStrings.stub("ShutdownSafe"));
|
||||
DatabaseManager.instance.upkeep();
|
||||
GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe"));
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.CallImmediate(LocStrings.Stub("ShutdownUnsafe"));// "``");
|
||||
GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe"));
|
||||
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class CommandStark extends Command
|
||||
public CommandStark(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("StarkInfo"); };
|
||||
public String getHelpText() { return LocStrings.stub("StarkInfo"); };
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
String filename = null;
|
||||
@@ -39,7 +39,7 @@ public class CommandStark extends Command
|
||||
{
|
||||
try
|
||||
{
|
||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
||||
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||
preProcessed = new File(filename);
|
||||
}
|
||||
catch(Exception e)
|
||||
@@ -48,12 +48,12 @@ public class CommandStark extends Command
|
||||
if(input.mentions != null)
|
||||
person = input.mentions[0];
|
||||
|
||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(filename == null)
|
||||
return;
|
||||
}
|
||||
preProcessed = new File(filename);
|
||||
ApplySnap(ImageIO.read(preProcessed), name);
|
||||
applySnap(ImageIO.read(preProcessed), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -61,13 +61,13 @@ public class CommandStark extends Command
|
||||
}
|
||||
|
||||
postProcessed = new File(name);
|
||||
res.CallFile(postProcessed, "png");
|
||||
res.sendFile(postProcessed, "png");
|
||||
|
||||
ImageUtils.BlockingFileDelete(preProcessed);
|
||||
ImageUtils.BlockingFileDelete(postProcessed);
|
||||
ImageUtils.blockingFileDelete(preProcessed);
|
||||
ImageUtils.blockingFileDelete(postProcessed);
|
||||
}
|
||||
|
||||
private static void ApplySnap(BufferedImage image, String name) throws IOException
|
||||
private static void applySnap(BufferedImage image, String name) throws IOException
|
||||
{
|
||||
BufferedImage snap = ImageUtils.copyImage(image);
|
||||
// Iterate over each column left to right and touch up each pixel
|
||||
|
||||
@@ -3,7 +3,9 @@ package commands;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.CommandManager.ThreadData;
|
||||
import core.Config;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyEmbed;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
@@ -17,33 +19,38 @@ public class CommandStats extends Command
|
||||
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("StatsInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String out = "```\n";
|
||||
// Variables
|
||||
Stats stats = Stats.instance;
|
||||
String out = "";
|
||||
long seen = stats.getMessagesSeen();
|
||||
long processed = stats.getCommandsProcessed();
|
||||
|
||||
long seen = stats.GetMessagesSeen();
|
||||
long processed = stats.GetCommandsProcessed();
|
||||
|
||||
out += "----- [General] -----\n";
|
||||
// General
|
||||
out += "General";
|
||||
out += "```\n";
|
||||
out += " Messages observed: " + seen + "\n";
|
||||
out += "Commands processed: " + processed + "\n";
|
||||
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
||||
out += " KittyBot uptime: " + stats.GetFormattedUptime() + "\n";
|
||||
out += "\n";
|
||||
out += "----- [Health] -----\n";
|
||||
out += " SMT cores: " + stats.GetCPUAvailable() + "\n";
|
||||
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
||||
out += "```\n";
|
||||
|
||||
// If CPU load works on this OS, list it.
|
||||
double CPULoad = stats.GetSystemCPULoad();
|
||||
if(CPULoad > -0.9) // -1.0 is the error state
|
||||
out += "System CPU Load: " + (CPULoad * 100) + "%\n";
|
||||
// Health
|
||||
out += "Health";
|
||||
out += "```\n";
|
||||
out += " SMT cores: " + stats.getCPUAvailable() + "\n";
|
||||
|
||||
ThreadData data = stats.GetThreadData();
|
||||
// If CPU load works on this OS, list it. -1.0 is the error state
|
||||
double CPULoad = stats.getSystemCPULoad();
|
||||
out += CPULoad > -0.9
|
||||
? " CPU Load: " + (CPULoad * 100) + "%\n" : "";
|
||||
|
||||
ThreadData data = stats.getThreadData();
|
||||
Integer terminated = data.states.get(Thread.State.TERMINATED);
|
||||
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
||||
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
||||
@@ -58,14 +65,25 @@ public class CommandStats extends Command
|
||||
+ " term-" + (terminated == null ? 0 : terminated)
|
||||
+ "\n";
|
||||
|
||||
Integer guildCount = stats.GetGuildCount();
|
||||
Integer userCount = stats.GetUserCount();
|
||||
out += "```\n";
|
||||
|
||||
out += "\n----- [Cache] -----\n"
|
||||
|
||||
// Cache
|
||||
Integer guildCount = stats.getGuildCount();
|
||||
Integer userCount = stats.getUserCount();
|
||||
|
||||
out += "Cache";
|
||||
out += "```\n"
|
||||
+ "Cached Guilds: " + guildCount + "\n"
|
||||
+ " Cached Users: " + userCount;
|
||||
|
||||
out += "\n```";
|
||||
|
||||
res.Call(out);
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Bot Stats";
|
||||
embed.descriptionText = out;
|
||||
embed.color = Config.ColorDefault;
|
||||
|
||||
res.send(embed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Config;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
@@ -23,11 +24,11 @@ public class CommandTeey extends Command
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("TeeyInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("TeeyInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File teeyFile = null;
|
||||
@@ -48,13 +49,13 @@ public class CommandTeey extends Command
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
teeyeeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/teey/frames/", "teey ", 24, 18);
|
||||
builder.Overlay(ImageIO.read(teeyeeFile), name);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Config.AssetDirectory + "teey/frames/", "teey ", 24, 18);
|
||||
builder.overlay(ImageIO.read(teeyeeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -62,10 +63,10 @@ public class CommandTeey extends Command
|
||||
}
|
||||
|
||||
teeyFile = new File (name);
|
||||
res.CallFile(teeyFile, "gif");
|
||||
res.sendFile(teeyFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.BlockingFileDelete(teeyFile);
|
||||
ImageUtils.BlockingFileDelete(teeyeeFile);
|
||||
ImageUtils.blockingFileDelete(teeyFile);
|
||||
ImageUtils.blockingFileDelete(teeyeeFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ public class CommandTradeBeans extends Command
|
||||
public CommandTradeBeans(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("TradeBeansInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("TradeBeansInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.mentions == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("TradeBeansNoTargetError"));
|
||||
res.send(LocStrings.stub("TradeBeansNoTargetError"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,25 +32,25 @@ public class CommandTradeBeans extends Command
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("TradeBeansIntParseError"));
|
||||
res.send(LocStrings.stub("TradeBeansIntParseError"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(user.GetBeans() < beans)
|
||||
if(user.getBeans() < beans)
|
||||
{
|
||||
res.Call(LocStrings.Stub("TradeBeansNotEnoughError"));
|
||||
res.send(LocStrings.stub("TradeBeansNotEnoughError"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(beans < 0)
|
||||
{
|
||||
res.Call(String.format(LocStrings.Stub("TradeBeansStealingBeans"), user.name));
|
||||
user.ChangeBeans(-10);
|
||||
res.send(String.format(LocStrings.stub("TradeBeansStealingBeans"), user.name));
|
||||
user.changeBeans(-10);
|
||||
return;
|
||||
}
|
||||
|
||||
input.mentions[0].ChangeBeans(beans);
|
||||
user.ChangeBeans(-beans);
|
||||
res.Call(String.format(LocStrings.Stub("TradeBeansSuccess"), user.name, input.mentions[0].name, beans));
|
||||
input.mentions[0].changeBeans(beans);
|
||||
user.changeBeans(-beans);
|
||||
res.send(String.format(LocStrings.stub("TradeBeansSuccess"), user.name, input.mentions[0].name, beans));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,16 @@ public class CommandTweet extends Command
|
||||
public CommandTweet(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("TweetInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("TweetInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
//TODO: Figure out how to pass pictures correctly
|
||||
try {
|
||||
res.Call(tweet.tweet(input.args));
|
||||
res.send(tweet.tweet(input.args));
|
||||
} catch (Exception e) {
|
||||
res.Call(LocStrings.Stub("TweetError"));
|
||||
res.send(LocStrings.stub("TweetError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,23 +15,23 @@ public class CommandWolfram extends Command
|
||||
public CommandWolfram(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("WolframInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("WolframInfo"); }
|
||||
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.args == null || input.args.trim().length() == 0)
|
||||
res.Call(LocStrings.Stub("WolframNoArgs"));
|
||||
res.send(LocStrings.stub("WolframNoArgs"));
|
||||
|
||||
try
|
||||
{
|
||||
File pic = new File(searcher.getWolfram(input.args));
|
||||
res.CallFile(pic, "png");
|
||||
ImageUtils.BlockingFileDelete(pic);
|
||||
res.sendFile(pic, "png");
|
||||
ImageUtils.blockingFileDelete(pic);
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (IOException e)
|
||||
{
|
||||
res.Call(LocStrings.Stub("WolframError"));
|
||||
res.send(LocStrings.stub("WolframError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import core.Command;
|
||||
import core.Config;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
@@ -23,11 +24,11 @@ public class CommandYeet extends Command
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("YeetInfo"); }
|
||||
public String getHelpText() { return LocStrings.stub("YeetInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File yeetFile = null;
|
||||
@@ -48,13 +49,13 @@ public class CommandYeet extends Command
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
yeeteeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/yeet/frames/", "yeet ", 24, 18);
|
||||
builder.Overlay(ImageIO.read(yeeteeFile), name);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder(Config.AssetDirectory + "yeet/frames/", "yeet ", 24, 18);
|
||||
builder.overlay(ImageIO.read(yeeteeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -62,10 +63,10 @@ public class CommandYeet extends Command
|
||||
}
|
||||
|
||||
yeetFile = new File (name);
|
||||
res.CallFile(yeetFile, "gif");
|
||||
res.sendFile(yeetFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.BlockingFileDelete(yeetFile);
|
||||
ImageUtils.BlockingFileDelete(yeeteeFile);
|
||||
ImageUtils.blockingFileDelete(yeetFile);
|
||||
ImageUtils.blockingFileDelete(yeeteeFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import core.benchmark.BenchmarkManager;
|
||||
|
||||
public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||
{
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
final String lineDelimiter = "\n";
|
||||
String output = "";
|
||||
@@ -24,12 +24,12 @@ public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||
if(i != 0)
|
||||
output += lineDelimiter;
|
||||
|
||||
List<BenchmarkEntry> entries = manager.FindModel(inputSplit[i]);
|
||||
List<BenchmarkEntry> entries = manager.findModel(inputSplit[i]);
|
||||
|
||||
if(entries.size() < 1)
|
||||
output += "Couldn't find any models containing `" + inputSplit[i] + "`!";
|
||||
|
||||
output += BenchmarkCommandInfo.FormatInfo(entries.get(0));
|
||||
output += BenchmarkCommandInfo.formatInfo(entries.get(0));
|
||||
output += lineDelimiter;
|
||||
|
||||
if(entries.size() > 1)
|
||||
|
||||
@@ -9,12 +9,12 @@ public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
private final String lineDelimiter = "\n";
|
||||
private final int listMax = 30;
|
||||
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
String output = "";
|
||||
String searchString = input.value.trim();
|
||||
|
||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
||||
List<BenchmarkEntry> entries = manager.findModel(searchString);
|
||||
|
||||
if(entries.size() > 0)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
{
|
||||
static final String lineDelimiter = "\n";
|
||||
|
||||
public static String FormatInfo(BenchmarkEntry entry)
|
||||
public static String formatInfo(BenchmarkEntry entry)
|
||||
{
|
||||
String output = "";
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
return output;
|
||||
}
|
||||
|
||||
public static KittyEmbed FormatInfoEmbed(BenchmarkEntry entry)
|
||||
public static KittyEmbed formatInfoEmbed(BenchmarkEntry entry)
|
||||
{
|
||||
// Populate general embed info
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
@@ -74,18 +74,18 @@ public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
String searchString = input.value.trim();
|
||||
long start = System.currentTimeMillis();
|
||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
||||
List<BenchmarkEntry> entries = manager.findModel(searchString);
|
||||
|
||||
if(entries.size() < 1)
|
||||
return new BenchmarkFormattable("Couldn't find any models containing `" + searchString + "`!");
|
||||
|
||||
List<BenchmarkEntry> sortedEntries = manager.EvaluateLevenshteinDistance(entries, searchString);
|
||||
List<BenchmarkEntry> sortedEntries = manager.evaluateLevenshteinDistance(entries, searchString);
|
||||
BenchmarkEntry entry = sortedEntries.get(0);
|
||||
KittyEmbed embed = FormatInfoEmbed(entry);
|
||||
KittyEmbed embed = formatInfoEmbed(entry);
|
||||
|
||||
if(entries.size() > 1)
|
||||
embed.footerText += " (Chose the " + entry.model + " from " + entries.size() + " potential components. To see others, try the command 'benchmark find " + searchString +"')";
|
||||
|
||||
@@ -7,7 +7,7 @@ import core.rpg.RPGState;
|
||||
public class RPGCommandBattleFight extends RPGCommand
|
||||
{
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
public String onRun(RPGState state, RPGInput input)
|
||||
{
|
||||
if(state.battleContext == null)
|
||||
return "```There's nothing to fight!```";
|
||||
@@ -19,7 +19,7 @@ public class RPGCommandBattleFight extends RPGCommand
|
||||
reward = "+150xp";
|
||||
|
||||
state.battleContext = null;
|
||||
state.player.ApplyEXP(150);
|
||||
state.player.applyEXP(150);
|
||||
|
||||
if(out != null && reward != null)
|
||||
{
|
||||
|
||||
@@ -7,15 +7,15 @@ import core.rpg.RPGState;
|
||||
public class RPGCommandBattleRun extends RPGCommand
|
||||
{
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
public String onRun(RPGState state, RPGInput input)
|
||||
{
|
||||
if(state.battleContext == null)
|
||||
return "```There's nothing to run from!```";
|
||||
|
||||
long lostGold = (long)(state.player.GetGold() * .1);
|
||||
long lostGold = (long)(state.player.getGold() * .1);
|
||||
String out = null;
|
||||
|
||||
state.player.SpendGold(lostGold);
|
||||
state.player.spendGold(lostGold);
|
||||
state.battleContext = null;
|
||||
|
||||
out = "You duck behind a tree and manage to escape from encounter just barely!";
|
||||
|
||||
@@ -28,7 +28,7 @@ public class RPGCommandExplore extends RPGCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
public String onRun(RPGState state, RPGInput input)
|
||||
{
|
||||
Chance chance = new Chance(100);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RPGCommandExplore extends RPGCommand
|
||||
|
||||
out = "As you take a stroll, you spy a small shiny glint from a bush and decide to investigate! Looks like it's your lucky day!";
|
||||
reward = "+" + gp + "gp";
|
||||
state.player.GiveGold(gp);
|
||||
state.player.giveGold(gp);
|
||||
}
|
||||
else if(chance.Next(20))
|
||||
{
|
||||
@@ -59,8 +59,8 @@ public class RPGCommandExplore extends RPGCommand
|
||||
|
||||
out = "You head out on a lovely stroll down a familiar path - the sun is out and the birds are chirping! Nothing much comes of it, but you feel refreshed.";
|
||||
reward = "+" + xp + "xp, +" + healing + "hp";
|
||||
state.player.ApplyHealing(healing);
|
||||
state.player.ApplyEXP(xp);
|
||||
state.player.applyHealing(healing);
|
||||
state.player.applyEXP(xp);
|
||||
}
|
||||
else if(chance.Next(20))
|
||||
{
|
||||
@@ -69,8 +69,8 @@ public class RPGCommandExplore extends RPGCommand
|
||||
|
||||
out = "Today's the day you head out on a new path. You find a lot of little nicknacks and trinkets on the trail, but leave them be. The trail gets really steep, the rocks jagged, but you keep going. Eventually, you make it out to the other side into a small but pleasant town, and collapse on a bench to catch your breath.";
|
||||
reward = "+" + xp + "xp, -" + damage + "hp";
|
||||
state.player.ApplyEXP(xp);
|
||||
state.player.ApplyDamage(damage);
|
||||
state.player.applyEXP(xp);
|
||||
state.player.applyDamage(damage);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,7 +78,7 @@ public class RPGCommandExplore extends RPGCommand
|
||||
|
||||
out = "You step outside but it starts to rain. You decide not to do much today, and hang about the inn and the tavern.";
|
||||
reward = "+" + hp + "hp";
|
||||
state.player.ApplyHealing(hp);
|
||||
state.player.applyHealing(hp);
|
||||
}
|
||||
|
||||
if(out != null && reward != null)
|
||||
|
||||
@@ -8,9 +8,8 @@ import core.rpg.RPGWeapon;
|
||||
|
||||
public class RPGCommandInfo extends RPGCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
public String onRun(RPGState state, RPGInput input)
|
||||
{
|
||||
String out = null;
|
||||
switch(input.value.trim().toLowerCase())
|
||||
@@ -27,7 +26,7 @@ public class RPGCommandInfo extends RPGCommand
|
||||
case "hand":
|
||||
case "att":
|
||||
case "attack":
|
||||
out = WeaponStats(state.player.GetWeapon());
|
||||
out = weaponStats(state.player.getWeapon());
|
||||
break;
|
||||
|
||||
case "armour":
|
||||
@@ -44,7 +43,7 @@ public class RPGCommandInfo extends RPGCommand
|
||||
case "dress":
|
||||
case "wear":
|
||||
case "outfit":
|
||||
out = ArmorStats(state.player.GetArmor());
|
||||
out = armorStats(state.player.getArmor());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -54,38 +53,38 @@ public class RPGCommandInfo extends RPGCommand
|
||||
return out;
|
||||
}
|
||||
|
||||
private String WeaponStats(RPGWeapon weapon)
|
||||
private String weaponStats(RPGWeapon weapon)
|
||||
{
|
||||
if(weapon == null)
|
||||
return null;
|
||||
|
||||
String out = "";
|
||||
out += "[" + weapon.GetName() + "]";
|
||||
out += "[" + weapon.getName() + "]";
|
||||
out += "\n";
|
||||
out += " att: " + weapon.GetAttack();
|
||||
out += " att: " + weapon.getAttack();
|
||||
out += "\n";
|
||||
out += "value: " + weapon.GetValue() + "gp";
|
||||
out += "value: " + weapon.getValue() + "gp";
|
||||
out += "\n";
|
||||
out += "\n";
|
||||
out += weapon.GetDescription();
|
||||
out += weapon.getDescription();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
private String ArmorStats(RPGArmor armor)
|
||||
private String armorStats(RPGArmor armor)
|
||||
{
|
||||
if(armor == null)
|
||||
return null;
|
||||
|
||||
String out = "";
|
||||
out += "[" + armor.GetName() + "]";
|
||||
out += "[" + armor.getName() + "]";
|
||||
out += "\n";
|
||||
out += " def: " + armor.GetDefense();
|
||||
out += " def: " + armor.getDefense();
|
||||
out += "\n";
|
||||
out += "value: " + armor.GetValue() + "gp";
|
||||
out += "value: " + armor.getValue() + "gp";
|
||||
out += "\n";
|
||||
out += "\n";
|
||||
out += armor.GetDescription();
|
||||
out += armor.getDescription();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -11,18 +11,18 @@ import core.rpg.RPGWeapon;
|
||||
public class RPGCommandStats extends RPGCommand
|
||||
{
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
public String onRun(RPGState state, RPGInput input)
|
||||
{
|
||||
RPGPlayer player = state.player;
|
||||
long exp = player.GetEXP();
|
||||
long level = RPGExpTable.LevelFromEXP(player.GetEXP());
|
||||
long ceil = RPGExpTable.EXPCeil(level);
|
||||
long exp = player.getEXP();
|
||||
long level = RPGExpTable.levelFromEXP(player.getEXP());
|
||||
long ceil = RPGExpTable.expCeil(level);
|
||||
|
||||
String indent = "";
|
||||
String linebreak = "\n";
|
||||
|
||||
String out = "";
|
||||
out += indent + "[" + player.GetName() + ", lv. " + level + "]";
|
||||
out += indent + "[" + player.getName() + ", lv. " + level + "]";
|
||||
out += indent + linebreak;
|
||||
out += indent + "_______________";
|
||||
out += indent + linebreak;
|
||||
@@ -31,26 +31,26 @@ public class RPGCommandStats extends RPGCommand
|
||||
out += indent + " (until next: " + (ceil - exp) + ")";
|
||||
out += indent + linebreak;
|
||||
|
||||
out += indent + " Gold: " + player.GetGold();
|
||||
out += indent + " Gold: " + player.getGold();
|
||||
out += indent + linebreak;
|
||||
|
||||
out += indent + "Health: " + player.GetHealthCurrent() + "/" + player.GetHealthMax();
|
||||
out += indent + "Health: " + player.getHealthCurrent() + "/" + player.getHealthMax();
|
||||
out += indent + linebreak;
|
||||
|
||||
RPGWeapon weapon = player.GetWeapon();
|
||||
RPGWeapon weapon = player.getWeapon();
|
||||
out += indent + "_____";
|
||||
out += indent + linebreak;
|
||||
out += indent + "Weapon: " + weapon.GetName();
|
||||
out += indent + "Weapon: " + weapon.getName();
|
||||
out += indent + linebreak;
|
||||
out += indent + " att: " + weapon.GetAttack();
|
||||
out += indent + " att: " + weapon.getAttack();
|
||||
out += indent + linebreak;
|
||||
|
||||
RPGArmor armor = player.GetArmor();
|
||||
RPGArmor armor = player.getArmor();
|
||||
out += indent + "_____";
|
||||
out += indent + linebreak;
|
||||
out += indent + "Armor: " + armor.GetName();
|
||||
out += indent + "Armor: " + armor.getName();
|
||||
out += indent + linebreak;
|
||||
out += indent + " def: " + armor.GetDefense() ;
|
||||
out += indent + " def: " + armor.getDefense() ;
|
||||
out += indent + linebreak;
|
||||
|
||||
out += indent + linebreak;
|
||||
|
||||
@@ -33,12 +33,12 @@ public class BaseKeyValueFile
|
||||
}
|
||||
|
||||
// Reads in and calls the specifid function for each keyvalue pair we find
|
||||
protected void Parse(Consumer<? super Pair<String, String>> keyValueCallback)
|
||||
protected void parse(Consumer<? super Pair<String, String>> keyValueCallback)
|
||||
{
|
||||
File f = new File(filename);
|
||||
if(f.isFile() && f.canRead())
|
||||
{
|
||||
String content = FileUtils.ReadContent(f).trim();
|
||||
String content = FileUtils.readContent(f).trim();
|
||||
String[] lines = content.split("" + pairSeparator);
|
||||
|
||||
for(int i = 0; i < lines.length; ++i)
|
||||
@@ -60,7 +60,7 @@ public class BaseKeyValueFile
|
||||
}
|
||||
|
||||
// Writes out a set of keyvalue pairs
|
||||
protected void Write(List<Pair<String, String>> toWrite)
|
||||
protected void write(List<Pair<String, String>> toWrite)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -84,7 +84,7 @@ public class BaseKeyValueFile
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "Issue writing file " + filename + ": " + e.getMessage());
|
||||
GlobalLog.error(LogFilter.Core, "Issue writing file " + filename + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -30,9 +30,9 @@ public abstract class BaseLocFile
|
||||
protected TaggedPairStore stringStore;
|
||||
|
||||
// Logging
|
||||
private void Log(String str) { GlobalLog.Log(LogFilter.Strings, str); }
|
||||
private void Warn(String str) { GlobalLog.Warn(LogFilter.Strings, str); }
|
||||
private void Error(String str) { GlobalLog.Error(LogFilter.Strings, str); }
|
||||
private void log(String str) { GlobalLog.log(LogFilter.Strings, str); }
|
||||
private void warn(String str) { GlobalLog.warn(LogFilter.Strings, str); }
|
||||
private void error(String str) { GlobalLog.error(LogFilter.Strings, str); }
|
||||
|
||||
// File monitoring
|
||||
protected FileMonitor fileMonitor;
|
||||
@@ -45,19 +45,19 @@ public abstract class BaseLocFile
|
||||
}
|
||||
|
||||
// Checks the file specified for updates
|
||||
public void Update()
|
||||
public void update()
|
||||
{
|
||||
synchronized(stringStore)
|
||||
{
|
||||
fileMonitor.Update(this::OnFileChange);
|
||||
fileMonitor.update(this::onFileChange);
|
||||
}
|
||||
}
|
||||
|
||||
// When the file is changed
|
||||
protected void OnFileChange(MonitoredFile file)
|
||||
protected void onFileChange(MonitoredFile file)
|
||||
{
|
||||
Log("Loc file was modified at path " + file.path);
|
||||
UpdateLocFromDisk();
|
||||
log("Loc file was modified at path " + file.path);
|
||||
updateLocFromDisk();
|
||||
}
|
||||
|
||||
// Structure used for holding a pair of strings and any other info we need
|
||||
@@ -75,12 +75,12 @@ public abstract class BaseLocFile
|
||||
}
|
||||
|
||||
// Do processing on each path in the scraped directory here, assuming it's .java
|
||||
public void StripForContents(Path path, ArrayList<LocInfo> strings)
|
||||
public void stripForContents(Path path, ArrayList<LocInfo> strings)
|
||||
{
|
||||
String filename = path.getFileName().toString();
|
||||
if(filename.contains(".java"))
|
||||
{
|
||||
String contents = FileUtils.ReadContent(path);
|
||||
String contents = FileUtils.readContent(path);
|
||||
String[] split = contents.split(functionName);
|
||||
|
||||
// Identify all localizer function calls
|
||||
@@ -101,11 +101,11 @@ public abstract class BaseLocFile
|
||||
|
||||
strings.add(new LocInfo(filename.substring(0, filename.lastIndexOf('.')), toLocalize));
|
||||
|
||||
Log("Found lookup call in " + path + ": " + toLocalize);
|
||||
log("Found lookup call in " + path + ": " + toLocalize);
|
||||
}
|
||||
catch(IndexOutOfBoundsException e)
|
||||
{
|
||||
Warn("Found phrase but couldn't parse in file " + path);
|
||||
warn("Found phrase but couldn't parse in file " + path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,12 +116,12 @@ public abstract class BaseLocFile
|
||||
// Nothing for now, but in the future will return a parsed and localized version of
|
||||
// the string in question if one can be found. If the localized string is empty,
|
||||
// returns a the key instead which is the default phrase.
|
||||
public String GetKey(String input)
|
||||
public String getKey(String input)
|
||||
{
|
||||
if(stringStore == null)
|
||||
return input;
|
||||
|
||||
String value = stringStore.GetKey(input);
|
||||
String value = stringStore.getKey(input);
|
||||
if(value == null || value.trim().length() < 1)
|
||||
return input;
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class BaseLocFile
|
||||
}
|
||||
|
||||
// Reads a file to string, adapted from https://stackoverflow.com/a/326440/5383198
|
||||
private String ReadFileAsString(String path, Charset encoding)
|
||||
private String readFileAsString(String path, Charset encoding)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -138,7 +138,7 @@ public abstract class BaseLocFile
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Warn("No file found to read from!");
|
||||
warn("No file found to read from!");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -146,13 +146,13 @@ public abstract class BaseLocFile
|
||||
|
||||
// Update localization from the disk on file. Creates the file if it doesn't exist.
|
||||
// This file is internally formatted as an ini file.
|
||||
public void UpdateLocFromDisk()
|
||||
public void updateLocFromDisk()
|
||||
{
|
||||
Log("Attempting to read localization file: " + filename);
|
||||
log("Attempting to read localization file: " + filename);
|
||||
|
||||
try
|
||||
{
|
||||
String fileContents = ReadFileAsString(filename, Charset.defaultCharset());
|
||||
String fileContents = readFileAsString(filename, Charset.defaultCharset());
|
||||
|
||||
if(fileContents == null)
|
||||
{
|
||||
@@ -164,15 +164,15 @@ public abstract class BaseLocFile
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Error("IO exception during localization file read");
|
||||
error("IO exception during localization file read");
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrites out at the specified filename with existing stubs.
|
||||
// This preserves existing localized phrases.
|
||||
public void SaveLocToDisk()
|
||||
public void saveLocToDisk()
|
||||
{
|
||||
Log("Attempting to write updated localization file");
|
||||
log("Attempting to write updated localization file");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -182,30 +182,30 @@ public abstract class BaseLocFile
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Error("IO exception during localization file write");
|
||||
error("IO exception during localization file write");
|
||||
}
|
||||
}
|
||||
|
||||
private void TryStripSpecified(Path path, ArrayList<LocInfo> toFill)
|
||||
private void tryStripSpecified(Path path, ArrayList<LocInfo> toFill)
|
||||
{
|
||||
try
|
||||
{
|
||||
StripForContents(path, toFill);
|
||||
stripForContents(path, toFill);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Error("issue with file: " + path.toString());
|
||||
error("issue with file: " + path.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Scrape the project and generate all the possible localizeable phrases.
|
||||
// This stubs out phrases to be localized.
|
||||
public void ScrapeAll()
|
||||
public void scrapeAll()
|
||||
{
|
||||
ArrayList<LocInfo> localizeList = new ArrayList<LocInfo>();
|
||||
FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> TryStripSpecified(path, localizeList));
|
||||
FileUtils.acquireAllFiles(KittySourceDirectory).forEach((path) -> tryStripSpecified(path, localizeList));
|
||||
|
||||
for(LocInfo toStub : localizeList)
|
||||
stringStore.AddKeyValue(toStub.file, toStub.phrase, toStub.phrase);
|
||||
stringStore.addKeyValue(toStub.file, toStub.phrase, toStub.phrase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CharacterManager
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second CharacterManager singleton!");
|
||||
GlobalLog.error(LogFilter.Core, "Attempted to create a second CharacterManager singleton!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -66,8 +66,8 @@ public class CharacterManager
|
||||
}
|
||||
}
|
||||
|
||||
characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.Get()));
|
||||
uniqueID.Add(1);
|
||||
characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.get()));
|
||||
uniqueID.add(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -26,65 +26,65 @@ public abstract class Command
|
||||
this.contentRating = contentRating;
|
||||
}
|
||||
|
||||
private void Reject(KittyUser user, String reason)
|
||||
private void reject(KittyUser user, String reason)
|
||||
{
|
||||
GlobalLog.Warn(LogFilter.Command, this.getClass().getSimpleName() + " from " + user.name + " rejected due to command's " + reason);
|
||||
GlobalLog.warn(LogFilter.Command, this.getClass().getSimpleName() + " from " + user.name + " rejected due to command's " + reason);
|
||||
}
|
||||
|
||||
// Determine if we're exclusive enough for this command and
|
||||
// if the command is permitted by the guild we're in
|
||||
private boolean CanCall(KittyGuild guild, KittyChannel channel, KittyUser user)
|
||||
private boolean canCall(KittyGuild guild, KittyChannel channel, KittyUser user)
|
||||
{
|
||||
if(guild.contentRating.getValue() < contentRating.getValue())
|
||||
{
|
||||
Reject(user, "content rating");
|
||||
reject(user, "content rating");
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: ADD CHANNEL CHECK HERE
|
||||
|
||||
if(user.GetRole().getValue() >= roleLevel.getValue())
|
||||
if(user.getRole().getValue() >= roleLevel.getValue())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reject(user, "permissions");
|
||||
reject(user, "permissions");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called by the Command manager - this will run the command
|
||||
// if the issuing user has the permission to do so!
|
||||
protected final void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
protected final void invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(!CanCall(guild, channel, user))
|
||||
if(!canCall(guild, channel, user))
|
||||
return;
|
||||
|
||||
OnRun(guild, channel, user, input, res);
|
||||
onRun(guild, channel, user, input, res);
|
||||
}
|
||||
|
||||
public ArrayList<String> RegisteredNames()
|
||||
public ArrayList<String> registeredNames()
|
||||
{
|
||||
return registeredNames;
|
||||
}
|
||||
|
||||
public KittyRating Rating()
|
||||
public KittyRating rating()
|
||||
{
|
||||
return contentRating;
|
||||
}
|
||||
|
||||
public KittyRole RequiredRole()
|
||||
public KittyRole requiredRole()
|
||||
{
|
||||
return roleLevel;
|
||||
}
|
||||
|
||||
// OVERRIDE ME! (This is not required but advised!)
|
||||
// Returns if the command succeeded or not.
|
||||
public String HelpText()
|
||||
public String getHelpText()
|
||||
{
|
||||
return "No help text has been added yet for " + this.getClass().getSimpleName() + "!";
|
||||
}
|
||||
|
||||
// OVERRIDE ME! (This is required)
|
||||
// Returns if the command succeeded or not.
|
||||
public abstract void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res);
|
||||
public abstract void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res);
|
||||
}
|
||||
|
||||
@@ -23,27 +23,28 @@ public class CommandEnabler extends BaseKeyValueFile
|
||||
// Local variables
|
||||
private HashMap<String, Boolean> enabledMap; // Quick lookup
|
||||
private ArrayList<String> keyList; // Tracking ordering for later
|
||||
private final static String name = "commands.config";
|
||||
private final static String name = Config.AssetDirectory + "commands.config";
|
||||
|
||||
// Constructor
|
||||
public CommandEnabler()
|
||||
{
|
||||
super(name);
|
||||
|
||||
// Create/Init variables
|
||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
enabledMap = new HashMap<>();
|
||||
keyList = new ArrayList<>();
|
||||
|
||||
// Startup
|
||||
ReadIn();
|
||||
GetTrackedCommands();
|
||||
WriteOut();
|
||||
readIn();
|
||||
getTrackedCommands();
|
||||
writeOut();
|
||||
}
|
||||
|
||||
// Reads in the config file and parses it, keeping tabs on the order it read things
|
||||
private void ReadIn()
|
||||
private void readIn()
|
||||
{
|
||||
Parse((pair) ->{
|
||||
parse((pair) ->{
|
||||
String key = pair.First;
|
||||
String value = pair.Second;
|
||||
|
||||
@@ -58,9 +59,9 @@ public class CommandEnabler extends BaseKeyValueFile
|
||||
|
||||
// Look up the already scraped values from the localizer and store them if they
|
||||
// don't already exist in the lookup. Defaults to defaultEnabledState.
|
||||
private void GetTrackedCommands()
|
||||
private void getTrackedCommands()
|
||||
{
|
||||
ArrayList<String> unloc = LocCommands.GetUnlocalizedCommands();
|
||||
ArrayList<String> unloc = LocCommands.getUnlocalizedCommands();
|
||||
|
||||
for(int i = 0; i < unloc.size(); ++i)
|
||||
{
|
||||
@@ -68,14 +69,14 @@ public class CommandEnabler extends BaseKeyValueFile
|
||||
|
||||
if(enabledMap.putIfAbsent(command, defaultEnabledState) == null)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Strings, "Identified new toggleable raw command: " + command);
|
||||
GlobalLog.log(LogFilter.Strings, "Identified new toggleable raw command: " + command);
|
||||
keyList.add(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write out enabled/disabled file info.
|
||||
private void WriteOut()
|
||||
private void writeOut()
|
||||
{
|
||||
List<Pair<String, String>> list = new Vector<Pair<String, String>>();
|
||||
|
||||
@@ -92,11 +93,11 @@ public class CommandEnabler extends BaseKeyValueFile
|
||||
|
||||
Collections.sort(list, (c1, c2) -> { return c1.First.compareTo(c2.First); });
|
||||
|
||||
Write(list);
|
||||
write(list);
|
||||
}
|
||||
|
||||
// Looks up a key to see if it's enabled or not
|
||||
public boolean IsEnabled(String key)
|
||||
public boolean isEnabled(String key)
|
||||
{
|
||||
String toCheck = key.toLowerCase();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CommandManager
|
||||
|
||||
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
||||
// and the command associated with the localized commands.
|
||||
public void Register(Pair<String, String> pair, Command command)
|
||||
public void register(Pair<String, String> pair, Command command)
|
||||
{
|
||||
if(pair == null || pair.Second == null)
|
||||
return;
|
||||
@@ -39,7 +39,7 @@ public class CommandManager
|
||||
// If we haven't already split a multisplit command (or even assessed that),
|
||||
// then verify if we even need to register the commands at all. If it's
|
||||
// not enabled, don't register it.
|
||||
if(pair.First != null && !commandEnabler.IsEnabled(pair.First))
|
||||
if(pair.First != null && !commandEnabler.isEnabled(pair.First))
|
||||
return;
|
||||
|
||||
String key = pair.Second;
|
||||
@@ -48,7 +48,7 @@ public class CommandManager
|
||||
{
|
||||
|
||||
String[] keys = key.split(",");
|
||||
Register(keys, command);
|
||||
register(keys, command);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,25 +59,25 @@ public class CommandManager
|
||||
|
||||
if(old != null)
|
||||
{
|
||||
GlobalLog.Warn(LogFilter.Core, "Writing over a command with the key " + key);
|
||||
GlobalLog.warn(LogFilter.Core, "Writing over a command with the key " + key);
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalLog.Log(LogFilter.Core, "Command registered under key " + key);
|
||||
GlobalLog.log(LogFilter.Core, "Command registered under key " + key);
|
||||
}
|
||||
|
||||
// Registers a command under multiple names!
|
||||
public void Register(String[] keys, Command command)
|
||||
public void register(String[] keys, Command command)
|
||||
{
|
||||
for(int i = 0; i < keys.length; ++i)
|
||||
Register(new Pair<String, String>(null, keys[i].trim()), command);
|
||||
register(new Pair<String, String>(null, keys[i].trim()), command);
|
||||
}
|
||||
|
||||
// Calls the command but on a whole new thread!
|
||||
public boolean InvokeOnNewThread(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext)
|
||||
public boolean invokeOnNewThread(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext)
|
||||
{
|
||||
// This is here to prevent spinning up a thread if this wasn't even a command.
|
||||
if(input == null || !input.IsValid())
|
||||
if(input == null || !input.isValid())
|
||||
return false;
|
||||
|
||||
Command command = commands.get(input.key);
|
||||
@@ -91,44 +91,44 @@ public class CommandManager
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Warn(LogFilter.Command, "User " + user.name + " tried to invoke command that doesn't exist: " + input.key);
|
||||
GlobalLog.warn(LogFilter.Command, "User " + user.name + " tried to invoke command that doesn't exist: " + input.key);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Calls the command specified with the key, providing user information arguments, etc.
|
||||
void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext)
|
||||
void invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext)
|
||||
{
|
||||
if(input == null || !input.IsValid())
|
||||
if(input == null || !input.isValid())
|
||||
return;
|
||||
|
||||
Command command = commands.get(input.key);
|
||||
if(command != null)
|
||||
{
|
||||
++invokeCount;
|
||||
command.Invoke(guild, channel, user, input, responseContext);
|
||||
command.invoke(guild, channel, user, input, responseContext);
|
||||
}
|
||||
}
|
||||
|
||||
// Looks up command by name. If it exists, dumps help text, otherwise returns null.
|
||||
public String GetCommandHelpText(String key)
|
||||
public String getCommandHelpText(String key)
|
||||
{
|
||||
Command command = commands.get(key);
|
||||
|
||||
if(command != null)
|
||||
return "`" + key + "`: " + command.HelpText();
|
||||
return "`" + key + "`: " + command.getHelpText();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Returns the number of commands sent so far during this program run
|
||||
public long GetInvokeCount()
|
||||
public long getInvokeCount()
|
||||
{
|
||||
return invokeCount;
|
||||
}
|
||||
|
||||
// Returns all commands by name
|
||||
public ArrayList<Command> GetAllRegisteredCommands()
|
||||
public ArrayList<Command> getAllRegisteredCommands()
|
||||
{
|
||||
ArrayList<Command> cmds = new ArrayList<Command>();
|
||||
for(Entry<String, Command> entry : commands.entrySet())
|
||||
@@ -142,7 +142,7 @@ public class CommandManager
|
||||
{
|
||||
public HashMap<Thread.State, Integer> states = new HashMap<Thread.State, Integer>();
|
||||
}
|
||||
public ThreadData DumpThreadData()
|
||||
public ThreadData dumpThreadData()
|
||||
{
|
||||
ThreadData data = new ThreadData();
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ public class CommandThread extends Thread
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
InvokeCommand();
|
||||
invokeCommand();
|
||||
}
|
||||
|
||||
private void InvokeCommand()
|
||||
private void invokeCommand()
|
||||
{
|
||||
manager.Invoke(guild, channel, user, input, response);
|
||||
manager.invoke(guild, channel, user, input, response);
|
||||
}
|
||||
|
||||
// Handles the try catch requirement java has for sleeping
|
||||
@SuppressWarnings("unused")
|
||||
private void ThreadSleep(int ms)
|
||||
private void threadSleep(int ms)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -5,4 +5,5 @@ import java.awt.Color;
|
||||
public final class Config
|
||||
{
|
||||
public static final Color ColorDefault = new Color(7*16, 8*16, 9*16); // A slate-grey
|
||||
public static final String AssetDirectory = "./assets/";
|
||||
}
|
||||
|
||||
@@ -35,97 +35,97 @@ public class DatabaseDriverKeyValue
|
||||
|
||||
// Makes sure a table exists with the specified name.
|
||||
// The keyName specifies the key column label, and the valueName specifies the value column label.
|
||||
public void EnsureTableExists(String tableName, String keyName, String valueName)
|
||||
public void ensureTableExists(String tableName, String keyName, String valueName)
|
||||
{
|
||||
// Require a global table if it doesn't exist already
|
||||
driver.ExecuteStatement(JDBCStatementType.Create, "CREATE TABLE IF NOT EXISTS " + tableName + " (" + keyName + " text PRIMARY KEY, " + valueName + " text)", null);
|
||||
driver.executeStatement(JDBCStatementType.Create, "CREATE TABLE IF NOT EXISTS " + tableName + " (" + keyName + " text PRIMARY KEY, " + valueName + " text)", null);
|
||||
}
|
||||
|
||||
// Set up and create a table in the database
|
||||
public boolean Connect()
|
||||
public boolean connect()
|
||||
{
|
||||
driver = new JDBCDriverSQLite();
|
||||
if(driver.Connect() == false)
|
||||
if(driver.connect() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify tables we want to use exist
|
||||
EnsureTableExists(tableName, keyColumnName, valueColumnName); // General table. Do not remove.
|
||||
ensureTableExists(tableName, keyColumnName, valueColumnName); // General table. Do not remove.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// The key will be created if it doesn't exist and the value specified will be stored.
|
||||
public void CreateSetKey(String key, String value)
|
||||
public void createSetKey(String key, String value)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Database, "CreateSetKey: Key-" + key + " value-" + value);
|
||||
GlobalLog.log(LogFilter.Database, "CreateSetKey: Key-" + key + " value-" + value);
|
||||
|
||||
if(HasKey(key))
|
||||
if(hasKey(key))
|
||||
{
|
||||
UpdateKey(key, value);
|
||||
updateKey(key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateKey(key, value);
|
||||
createKey(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a key. The key will be created if it doesn't exist, and the default value returned.
|
||||
public String CreateGetKey(String key)
|
||||
public String createGetKey(String key)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Database, "CreateGetKey: " + key);
|
||||
GlobalLog.log(LogFilter.Database, "CreateGetKey: " + key);
|
||||
|
||||
if(HasKey(key))
|
||||
if(hasKey(key))
|
||||
{
|
||||
return GetKey(key);
|
||||
return getKey(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
String newValue = "";
|
||||
CreateKey(key, newValue);
|
||||
createKey(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Prototype formatting for key updating
|
||||
private void UpdateKey(String key, String value)
|
||||
private void updateKey(String key, String value)
|
||||
{
|
||||
String command = "UPDATE " + tableName + " SET " + valueColumnName + " = ? WHERE " + keyColumnName + " = ?";
|
||||
boolean status = driver.ExecuteStatement(JDBCStatementType.Update, command, new String[] { value, key });
|
||||
GlobalLog.Log(LogFilter.Database, "UpdateKey status: " + status);
|
||||
boolean status = driver.executeStatement(JDBCStatementType.Update, command, new String[] { value, key });
|
||||
GlobalLog.log(LogFilter.Database, "UpdateKey status: " + status);
|
||||
}
|
||||
|
||||
// Protoype updating for seeing if a key exists
|
||||
private boolean HasKey(String key)
|
||||
private boolean hasKey(String key)
|
||||
{
|
||||
String command = "SELECT COUNT(1) as count FROM " + tableName + " WHERE " + keyColumnName + " = ?";
|
||||
ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||
String out = ResultAsString(set, "count");
|
||||
ResultSet set = driver.executeReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||
String out = resultAsString(set, "count");
|
||||
return out.charAt(0) == '1';
|
||||
}
|
||||
|
||||
// Prototype for getting a key
|
||||
private String GetKey(String key)
|
||||
private String getKey(String key)
|
||||
{
|
||||
String command = "SELECT " + valueColumnName + " as searchedKey FROM " + tableName +" WHERE " + keyColumnName + " = ?";
|
||||
ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||
return ResultAsString(set, "searchedKey");
|
||||
ResultSet set = driver.executeReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||
return resultAsString(set, "searchedKey");
|
||||
}
|
||||
|
||||
// Prototype for creating a key
|
||||
private void CreateKey(String key, String value)
|
||||
private void createKey(String key, String value)
|
||||
{
|
||||
String command = "INSERT INTO " + tableName + " (GlobalKey, GlobalValue) VALUES (?, ?)";
|
||||
boolean status = driver.ExecuteStatement(JDBCStatementType.Insert, command, new String[] { key, value });
|
||||
GlobalLog.Log(LogFilter.Database, "CreateKey status: " + status);
|
||||
boolean status = driver.executeStatement(JDBCStatementType.Insert, command, new String[] { key, value });
|
||||
GlobalLog.log(LogFilter.Database, "CreateKey status: " + status);
|
||||
}
|
||||
|
||||
// Get all keys containing a substring
|
||||
public List<String> GetKeysWith(String keySubstring)
|
||||
public List<String> getKeysWith(String keySubstring)
|
||||
{
|
||||
String command = "SELECT * FROM " + tableName + " WHERE " + keyColumnName + " like ?";
|
||||
ResultSet result = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { "%" + keySubstring + "%" });
|
||||
ResultSet result = driver.executeReturningStatement(JDBCStatementType.Select, command, new String[] { "%" + keySubstring + "%" });
|
||||
|
||||
List<String> keys = new ArrayList<String>();
|
||||
|
||||
@@ -146,7 +146,7 @@ public class DatabaseDriverKeyValue
|
||||
}
|
||||
|
||||
// Transforms a result into a string if possible.
|
||||
private String ResultAsString(ResultSet rs, String key)
|
||||
private String resultAsString(ResultSet rs, String key)
|
||||
{
|
||||
if(rs == null)
|
||||
return "";
|
||||
@@ -165,7 +165,7 @@ public class DatabaseDriverKeyValue
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Database, e.toString());
|
||||
GlobalLog.error(LogFilter.Database, e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class DatabaseManager
|
||||
// Constructor to enforce singleton.
|
||||
public DatabaseManager()
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Database, "Creating database manager");
|
||||
GlobalLog.log(LogFilter.Database, "Creating database manager");
|
||||
|
||||
if(instance == null)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public class DatabaseManager
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Database, "Attempted to register a second DataBase manager!");
|
||||
GlobalLog.error(LogFilter.Database, "Attempted to register a second DataBase manager!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,15 +57,15 @@ public class DatabaseManager
|
||||
characterDataDriver = new DatabaseDriverKeyValue(characterTableName, characterKeyColumnName, characterValueColumnName);
|
||||
|
||||
// Connect data sets
|
||||
if(globalDataDriver.Connect() == false)
|
||||
if(globalDataDriver.connect() == false)
|
||||
{
|
||||
GlobalLog.Error("Global database failed to connect. Without this DB, this bot can not run.");
|
||||
GlobalLog.error("Global database failed to connect. Without this DB, this bot can not run.");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if(characterDataDriver.Connect() == false)
|
||||
if(characterDataDriver.connect() == false)
|
||||
{
|
||||
GlobalLog.Error("Character database failed to connect. Without this DB, this bot can not run.");
|
||||
GlobalLog.error("Character database failed to connect. Without this DB, this bot can not run.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
@@ -94,10 +94,10 @@ public class DatabaseManager
|
||||
{
|
||||
DatabaseTrackedObject dto = globalDataTrackedObjects.get(i);
|
||||
|
||||
if(dto.IsDirty())
|
||||
if(dto.isDirty())
|
||||
{
|
||||
globalSetRemoteValue(dto.identifier, dto.Serialize());
|
||||
dto.Resolve();
|
||||
globalSetRemoteValue(dto.identifier, dto.serialize());
|
||||
dto.resolve();
|
||||
++numUpdated;
|
||||
}
|
||||
}
|
||||
@@ -117,10 +117,10 @@ public class DatabaseManager
|
||||
{
|
||||
DatabaseTrackedObject dto = characterDataTrackedObjects.get(i);
|
||||
|
||||
if(dto.IsDirty())
|
||||
if(dto.isDirty())
|
||||
{
|
||||
characterSetRemoteValue(dto.identifier, dto.Serialize());
|
||||
dto.Resolve();
|
||||
characterSetRemoteValue(dto.identifier, dto.serialize());
|
||||
dto.resolve();
|
||||
++numUpdated;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class DatabaseManager
|
||||
|
||||
public List<String> scrapeGlobalForString(String substring)
|
||||
{
|
||||
return globalDataDriver.GetKeysWith(substring);
|
||||
return globalDataDriver.getKeysWith(substring);
|
||||
}
|
||||
|
||||
/////////////////
|
||||
@@ -142,7 +142,7 @@ public class DatabaseManager
|
||||
synchronized(globalDataTrackedObjects)
|
||||
{
|
||||
globalDataTrackedObjects.add(tracked);
|
||||
tracked.DeSerialzie(globalGetRemoteValue(tracked.identifier));
|
||||
tracked.deSerialzie(globalGetRemoteValue(tracked.identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class DatabaseManager
|
||||
{
|
||||
synchronized(globalDataDriver)
|
||||
{
|
||||
return globalDataDriver.CreateGetKey(key);
|
||||
return globalDataDriver.createGetKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class DatabaseManager
|
||||
{
|
||||
synchronized(globalDataDriver)
|
||||
{
|
||||
globalDataDriver.CreateSetKey(key, value);
|
||||
globalDataDriver.createSetKey(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class DatabaseManager
|
||||
synchronized(characterDataTrackedObjects)
|
||||
{
|
||||
characterDataTrackedObjects.add(tracked);
|
||||
tracked.DeSerialzie(characterGetRemoteValue(tracked.identifier));
|
||||
tracked.deSerialzie(characterGetRemoteValue(tracked.identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class DatabaseManager
|
||||
{
|
||||
synchronized(characterDataDriver)
|
||||
{
|
||||
return characterDataDriver.CreateGetKey(key);
|
||||
return characterDataDriver.createGetKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class DatabaseManager
|
||||
{
|
||||
synchronized(characterDataDriver)
|
||||
{
|
||||
characterDataDriver.CreateSetKey(key, value);
|
||||
characterDataDriver.createSetKey(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public abstract class DatabaseTrackedObject
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public final boolean IsDirty()
|
||||
public final boolean isDirty()
|
||||
{
|
||||
synchronized(isDirty)
|
||||
{
|
||||
@@ -21,7 +21,7 @@ public abstract class DatabaseTrackedObject
|
||||
}
|
||||
}
|
||||
|
||||
public final void MarkDirty()
|
||||
public final void markDirty()
|
||||
{
|
||||
synchronized(isDirty)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public abstract class DatabaseTrackedObject
|
||||
}
|
||||
}
|
||||
|
||||
public final void Resolve()
|
||||
public final void resolve()
|
||||
{
|
||||
synchronized(isDirty)
|
||||
{
|
||||
@@ -39,6 +39,6 @@ public abstract class DatabaseTrackedObject
|
||||
|
||||
// Consider an object factory instead of dedicated serialization methods
|
||||
// if this starts to become impractical. For now, it works.
|
||||
public abstract String Serialize();
|
||||
public abstract void DeSerialzie(String string);
|
||||
public abstract String serialize();
|
||||
public abstract void deSerialzie(String string);
|
||||
}
|
||||
|
||||
+13
-13
@@ -10,8 +10,8 @@ import dataStructures.Pair;
|
||||
// is performed with general strings in the application
|
||||
public class LocCommands extends BaseLocFile
|
||||
{
|
||||
public static final String fileName = "locCommands.config";
|
||||
public static final String function = "LocCommands.Stub";
|
||||
public static final String fileName = Config.AssetDirectory + "locCommands.config";
|
||||
public static final String function = "LocCommands.stub";
|
||||
|
||||
private static LocCommands instance;
|
||||
|
||||
@@ -19,40 +19,40 @@ public class LocCommands extends BaseLocFile
|
||||
{
|
||||
super(fileName, function);
|
||||
|
||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
|
||||
if(instance == null)
|
||||
{
|
||||
instance = this;
|
||||
|
||||
UpdateLocFromDisk();
|
||||
ScrapeAll();
|
||||
SaveLocToDisk();
|
||||
updateLocFromDisk();
|
||||
scrapeAll();
|
||||
saveLocToDisk();
|
||||
|
||||
fileMonitor = new FileMonitor(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
|
||||
GlobalLog.error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a pair, the raw key and the stub key
|
||||
public static Pair<String, String> Stub(String toStub)
|
||||
public static Pair<String, String> stub(String toStub)
|
||||
{
|
||||
return new Pair<String, String>(toStub, instance.GetKey(toStub));
|
||||
return new Pair<String, String>(toStub, instance.getKey(toStub));
|
||||
}
|
||||
|
||||
// Gets all of the un-translated defaults in the commands list.
|
||||
public static ArrayList<String> GetUnlocalizedCommands()
|
||||
public static ArrayList<String> getUnlocalizedCommands()
|
||||
{
|
||||
ArrayList<String> raw = new ArrayList<>();
|
||||
instance.stringStore.ForEach((pair) -> raw.add((String)((Pair<?, ?>)pair).First ));
|
||||
instance.stringStore.forEach((pair) -> raw.add((String)((Pair<?, ?>)pair).First ));
|
||||
return raw;
|
||||
}
|
||||
|
||||
public static void Upkeep()
|
||||
public static void upkeep()
|
||||
{
|
||||
instance.Update();
|
||||
instance.update();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -9,8 +9,8 @@ import utils.io.FileMonitor;
|
||||
// can then be localized.
|
||||
public class LocStrings extends BaseLocFile
|
||||
{
|
||||
public static final String fileName = "locStrings.config";
|
||||
public static final String function = "LocStrings.Stub";
|
||||
public static final String fileName = Config.AssetDirectory + "locStrings.config";
|
||||
public static final String function = "LocStrings.stub";
|
||||
|
||||
private static LocStrings instance;
|
||||
|
||||
@@ -18,37 +18,37 @@ public class LocStrings extends BaseLocFile
|
||||
{
|
||||
super(fileName, function);
|
||||
|
||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||
|
||||
if(instance == null)
|
||||
{
|
||||
instance = this;
|
||||
|
||||
UpdateLocFromDisk();
|
||||
ScrapeAll();
|
||||
SaveLocToDisk();
|
||||
updateLocFromDisk();
|
||||
scrapeAll();
|
||||
saveLocToDisk();
|
||||
|
||||
fileMonitor = new FileMonitor(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
|
||||
GlobalLog.error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
public static String Stub(String toStub)
|
||||
public static String stub(String toStub)
|
||||
{
|
||||
return Lookup(toStub);
|
||||
return lookup(toStub);
|
||||
}
|
||||
|
||||
// Won't be picked up when scraping
|
||||
public static String Lookup(String stubbedPreviously)
|
||||
public static String lookup(String stubbedPreviously)
|
||||
{
|
||||
return instance.GetKey(stubbedPreviously);
|
||||
return instance.getKey(stubbedPreviously);
|
||||
}
|
||||
|
||||
public static void Upkeep()
|
||||
public static void upkeep()
|
||||
{
|
||||
instance.Update();
|
||||
instance.update();
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class ObjectBuilderFactory
|
||||
|
||||
// Handles if we can or can't use specific commands, parsing a config file based on loc data to do so.
|
||||
private static CommandEnabler commandEnabler;
|
||||
|
||||
|
||||
// Lazy initialization multithreaded mutex stuff to prevent explosions.
|
||||
// TODO: Investigate using 'synchronized' instead potentially
|
||||
private static boolean hasInitialized;
|
||||
@@ -67,7 +67,7 @@ public class ObjectBuilderFactory
|
||||
private static JDA kitty;
|
||||
|
||||
// This is it, this is how the lazy init starts!
|
||||
private static void LazyInit()
|
||||
private static void lazyInit()
|
||||
{
|
||||
if(hasInitialized)
|
||||
return;
|
||||
@@ -99,7 +99,7 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
catch(InterruptedException ie)
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "Issue during object builder lazy initialization."
|
||||
GlobalLog.error(LogFilter.Core, "Issue during object builder lazy initialization."
|
||||
+ " The factory was not initialized, and kitty will not be able to continue functionally.");
|
||||
}
|
||||
}
|
||||
@@ -109,9 +109,9 @@ public class ObjectBuilderFactory
|
||||
////////////////////////
|
||||
|
||||
// Explicitly locks: guildCache
|
||||
public static KittyGuild ExtractGuild(GuildMessageReceivedEvent event)
|
||||
public static KittyGuild extractGuild(GuildMessageReceivedEvent event)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
// Look up the guild. This process can only happen in a single-threaded way
|
||||
// because of the nature of the cache. We wait until the last second to
|
||||
@@ -129,6 +129,7 @@ public class ObjectBuilderFactory
|
||||
emoteFix += ":" + emote.substring(emote.indexOf("(")+1, emote.length()-1) + ">";
|
||||
emotesString.add(emoteFix);
|
||||
}
|
||||
|
||||
// once we're lazily initialized, we can synchronize w/ the
|
||||
// guildCache object now instead of having to use a mutex.
|
||||
KittyGuild guild = null;
|
||||
@@ -152,9 +153,9 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
|
||||
// Explicitly locks: guildCache
|
||||
public static KittyRole ExtractRole(GuildMessageReceivedEvent event)
|
||||
public static KittyRole extractRole(GuildMessageReceivedEvent event)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
// Looks up the user role. If none is found we check to see if they own
|
||||
// the guild if not, they're assumed to be
|
||||
@@ -171,7 +172,7 @@ public class ObjectBuilderFactory
|
||||
{
|
||||
KittyUser cachedUser = userCache.get(uid);
|
||||
if(cachedUser != null)
|
||||
role = cachedUser.GetRole();
|
||||
role = cachedUser.getRole();
|
||||
}
|
||||
|
||||
return role;
|
||||
@@ -179,9 +180,9 @@ public class ObjectBuilderFactory
|
||||
|
||||
// Explicitly locks: guildCache
|
||||
// Extracts the content rating information it can from the provided event.
|
||||
public static KittyRating ExtractContentRating(GuildMessageReceivedEvent event)
|
||||
public static KittyRating extractContentRating(GuildMessageReceivedEvent event)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
// Look up content rating of the guild, returns a safe content rating.
|
||||
KittyRating contentRating = KittyRating.Safe;
|
||||
@@ -197,9 +198,9 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
|
||||
// Implicitly locks guild cache by calling ExtractGuild
|
||||
public static KittyChannel ExtractChannel(GuildMessageReceivedEvent event)
|
||||
public static KittyChannel extractChannel(GuildMessageReceivedEvent event)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
String channelID = event.getChannel().getId();
|
||||
String guildID = event.getGuild().getId();
|
||||
@@ -225,9 +226,9 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
|
||||
// Implicitly locks guild cache by calling ExtractRole and ExtractGuild
|
||||
public static KittyUser ExtractUser(GuildMessageReceivedEvent event)
|
||||
public static KittyUser extractUser(GuildMessageReceivedEvent event)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
String uid = event.getGuild().getId() + event.getAuthor().getId();
|
||||
KittyUser user = null;
|
||||
@@ -241,8 +242,8 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
else
|
||||
{
|
||||
KittyRole role = ExtractRole(event);
|
||||
KittyGuild guild = ExtractGuild(event);
|
||||
KittyRole role = extractRole(event);
|
||||
KittyGuild guild = extractGuild(event);
|
||||
|
||||
String name;
|
||||
if(event.getMember().getNickname() == null)
|
||||
@@ -266,20 +267,20 @@ public class ObjectBuilderFactory
|
||||
{
|
||||
mentioned = event.getMessage().getMentionedMembers().get(i);
|
||||
if(mentioned.getNickname() != null)
|
||||
ExtractUserByJDAUser(event.getGuild().getId(), mentioned.getNickname(),
|
||||
extractUserByJDAUser(event.getGuild().getId(), mentioned.getNickname(),
|
||||
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
|
||||
else
|
||||
ExtractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(),
|
||||
extractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(),
|
||||
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
// TODO: Cleanup
|
||||
public static KittyUser ExtractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID)
|
||||
// TODO: Clean up
|
||||
public static KittyUser extractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
String uid = guildID + userID;
|
||||
KittyUser user = null;
|
||||
@@ -290,6 +291,7 @@ public class ObjectBuilderFactory
|
||||
{
|
||||
if(name != null)
|
||||
cachedUser.name = name;
|
||||
|
||||
cachedUser.avatarID = avatarID;
|
||||
user = cachedUser;
|
||||
}
|
||||
@@ -323,30 +325,36 @@ public class ObjectBuilderFactory
|
||||
Member jdaMember = jdaGuild.getMemberById(userID);
|
||||
User jdaUser = jdaMember.getUser();
|
||||
|
||||
user = ExtractUserByJDAUser(guildID, jdaMember.getNickname(), jdaUser.getId(), jdaUser.getAvatarUrl(), jdaUser.getId());
|
||||
user = extractUserByJDAUser(guildID, jdaMember.getNickname(), jdaUser.getId(), jdaUser.getAvatarUrl(), jdaUser.getId());
|
||||
updateUser(user, jdaMember);
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
// Updates a user's name appropriately based on nickname if available
|
||||
public static void updateUser(KittyUser user, Member member)
|
||||
{
|
||||
if(member.getNickname() == null)
|
||||
{
|
||||
user.name = member.getUser().getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
user.name = member.getNickname();
|
||||
}
|
||||
|
||||
user.avatarID = member.getUser().getAvatarUrl();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Construction Methods //
|
||||
//////////////////////////
|
||||
|
||||
public static KittyCore ConstructKittyCore() throws LoginException, InterruptedException
|
||||
// Builds the core of the bot
|
||||
public static KittyCore constructKittyCore() throws LoginException, InterruptedException
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
|
||||
kitty.getPresence().setGame(Game.playing("with digital yarn"));
|
||||
@@ -359,85 +367,85 @@ public class ObjectBuilderFactory
|
||||
// and disabling, what we do is construct the commands with a localized pair that is checked against
|
||||
// the CommandEnabler object passed in. In theory, we could have multiple CommandManagers, tho we can
|
||||
// only have one CommandEnabler.
|
||||
public static CommandManager ConstructCommandManager(CommandEnabler commandEnabler)
|
||||
public static CommandManager constructCommandManager(CommandEnabler commandEnabler)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
CommandManager manager = new CommandManager(commandEnabler);
|
||||
|
||||
// Dev
|
||||
manager.Register(LocCommands.Stub("work"), new CommandDoWork(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("shutdown"), new CommandShutdown(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("stats"), new CommandStats(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("invite"), new CommandInvite(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("work"), new CommandDoWork(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("shutdown"), new CommandShutdown(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("stats"), new CommandStats(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("invite"), new CommandInvite(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe));
|
||||
|
||||
// Admin
|
||||
manager.Register(LocCommands.Stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("guildroleallowed"), new CommandGuildRoleAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("guildrolenotallowed"), new CommandGuildRoleNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("guildroleallowed"), new CommandGuildRoleAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("guildrolenotallowed"), new CommandGuildRoleNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
|
||||
// Mod
|
||||
manager.Register(LocCommands.Stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
|
||||
// General
|
||||
manager.Register(LocCommands.Stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("guildroleadd"), new CommandGuildRoleAdd(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("guildroleremove"), new CommandGuildRoleRemove(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("teey"), new CommandTeey(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("perish, thenperish"), new CommandPerish(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("yeet"), new CommandYeet(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("ping"), new CommandPing(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("boop"), new CommandBoop(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("roll"), new CommandRoll(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("beans"), new CommandBeansShow(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("role"), new CommandRole(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("bet"), new CommandBetBeans(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("map"), new CommandMap(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rpstart"), new CommandRPStart(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rpend"), new CommandRPEnd(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("tony, stark, dontfeelgood, dontfeelsogood"), new CommandStark(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("blur"), new CommandBlurry(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("eightball, 8ball"), new CommandEightBall(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("catch"), new CommandCatch(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("guildrolelist"), new CommandGuildRoleList(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("charactercreate"), new CommandCharacterCreate(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("searchcharacter"), new CommandCharacterSearch(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("charactereditbio"), new CommandCharacterEditBio(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("charactereditname"), new CommandCharacterEditName(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("charactereditURL"), new CommandCharacterEditURL(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("guildroleadd"), new CommandGuildRoleAdd(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("guildroleremove"), new CommandGuildRoleRemove(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("teey"), new CommandTeey(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("perish, thenperish"), new CommandPerish(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("yeet"), new CommandYeet(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("ping"), new CommandPing(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("boop"), new CommandBoop(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("roll"), new CommandRoll(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("beans"), new CommandBeansShow(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("role"), new CommandRole(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("bet"), new CommandBetBeans(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("map"), new CommandMap(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rpstart"), new CommandRPStart(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rpend"), new CommandRPEnd(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("tony, stark, dontfeelgood, dontfeelsogood"), new CommandStark(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("blur"), new CommandBlurry(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("eightball, 8ball"), new CommandEightBall(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("catch"), new CommandCatch(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("guildrolelist"), new CommandGuildRoleList(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("charactercreate"), new CommandCharacterCreate(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("searchcharacter"), new CommandCharacterSearch(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("charactereditbio"), new CommandCharacterEditBio(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("charactereditname"), new CommandCharacterEditName(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("charactereditURL"), new CommandCharacterEditURL(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
|
||||
manager.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
// Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does.
|
||||
public static CommandEnabler ConstructCommandEnabler()
|
||||
public static CommandEnabler constructCommandEnabler()
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
if(commandEnabler == null)
|
||||
commandEnabler = new CommandEnabler();
|
||||
@@ -449,9 +457,9 @@ public class ObjectBuilderFactory
|
||||
// in different ways, and so we construct it outside of the constructor for
|
||||
// the factory since it doesn't have to be present / can be elsewhere.
|
||||
// Effectively we cache the database here.
|
||||
public static DatabaseManager ConstructDatabaseManager()
|
||||
public static DatabaseManager constructDatabaseManager()
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
if(database == null)
|
||||
database = new DatabaseManager();
|
||||
@@ -459,9 +467,9 @@ public class ObjectBuilderFactory
|
||||
return database;
|
||||
}
|
||||
|
||||
public static Stats ConstructStats(CommandManager manager)
|
||||
public static Stats constructStats(CommandManager manager)
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
if(stats == null)
|
||||
stats = new Stats(manager);
|
||||
@@ -469,9 +477,9 @@ public class ObjectBuilderFactory
|
||||
return stats;
|
||||
}
|
||||
|
||||
public static RPManager ConstructRPManager()
|
||||
public static RPManager constructRPManager()
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
if(rpManager == null)
|
||||
rpManager = new RPManager();
|
||||
@@ -479,22 +487,23 @@ public class ObjectBuilderFactory
|
||||
return rpManager;
|
||||
}
|
||||
|
||||
public static PluginManager ConstructPluginManager()
|
||||
public static PluginManager constructPluginManager()
|
||||
{
|
||||
LazyInit();
|
||||
lazyInit();
|
||||
|
||||
if(pluginManager == null)
|
||||
pluginManager = new PluginManager("./plugins/");
|
||||
pluginManager = new PluginManager(Config.AssetDirectory + "plugins/");
|
||||
|
||||
return pluginManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
// Utility Methods //
|
||||
/////////////////////
|
||||
|
||||
// Returns number of cached guilds (does not equal total users in the database, only what's in memory)
|
||||
public static Integer GetGuildCount()
|
||||
public static Integer getGuildCount()
|
||||
{ synchronized(guildCache)
|
||||
{
|
||||
return guildCache.size();
|
||||
@@ -502,7 +511,7 @@ public class ObjectBuilderFactory
|
||||
}
|
||||
|
||||
// Returns number of cached users (does not equal total users in the database, only what's in memory)
|
||||
public static Integer GetUserCount()
|
||||
public static Integer getUserCount()
|
||||
{ synchronized(userCache)
|
||||
{
|
||||
return userCache.size();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class RPManager
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second RP Manager!");
|
||||
GlobalLog.error(LogFilter.Core, "Attempted to create a second RP Manager!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class RPManager
|
||||
|
||||
public void addLine(KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
if(logs.containsKey(Long.parseLong(channel.uniqueID)) && !input.IsValid())
|
||||
if(logs.containsKey(Long.parseLong(channel.uniqueID)) && !input.isValid())
|
||||
logs.get(Long.parseLong(channel.uniqueID)).addLine(user, input.message);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RPManager
|
||||
return log;
|
||||
}
|
||||
|
||||
public static void Upkeep(KittyCore kitty)
|
||||
public static void upkeep(KittyCore kitty)
|
||||
{
|
||||
Response res = new Response(null, kitty);
|
||||
String reminder = "";
|
||||
@@ -71,7 +71,7 @@ public class RPManager
|
||||
{
|
||||
reminder += " <@" + users.get(i) + ">";
|
||||
}
|
||||
res.CallToChannel(reminder, entry.getValue().getChannel().uniqueID);
|
||||
res.sendToChannel(reminder, entry.getValue().getChannel().uniqueID);
|
||||
reminder = "";
|
||||
|
||||
entry.getValue().resetTimer();
|
||||
|
||||
+20
-20
@@ -31,7 +31,7 @@ public class Stats
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second Stats singleton!");
|
||||
GlobalLog.error(LogFilter.Core, "Attempted to create a second Stats singleton!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ public class Stats
|
||||
osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
||||
}
|
||||
|
||||
public void NoteMessageEvent()
|
||||
public void noteMessageEvent()
|
||||
{
|
||||
++messagesSeen;
|
||||
}
|
||||
|
||||
public void IndicateShutdown()
|
||||
public void indicateShutdown()
|
||||
{
|
||||
synchronized(instance)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class Stats
|
||||
}
|
||||
}
|
||||
|
||||
public boolean GetIsShuttingDown()
|
||||
public boolean getIsShuttingDown()
|
||||
{
|
||||
synchronized(instance)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ public class Stats
|
||||
/////////////////////////////////////////
|
||||
|
||||
// Formatted as HH:MM:SS
|
||||
public String GetFormattedUptime()
|
||||
public String getFormattedUptime()
|
||||
{
|
||||
long dif = System.currentTimeMillis() - initTimeMS;
|
||||
|
||||
@@ -80,48 +80,48 @@ public class Stats
|
||||
}
|
||||
|
||||
// Get number of commands that kitty has run!
|
||||
public long GetCommandsProcessed()
|
||||
public long getCommandsProcessed()
|
||||
{
|
||||
return commandManager.GetInvokeCount();
|
||||
return commandManager.getInvokeCount();
|
||||
}
|
||||
|
||||
public long GetMessagesSeen()
|
||||
public long getMessagesSeen()
|
||||
{
|
||||
return messagesSeen;
|
||||
}
|
||||
|
||||
public double GetSystemCPULoad()
|
||||
public double getSystemCPULoad()
|
||||
{
|
||||
return osBean.getSystemLoadAverage();
|
||||
}
|
||||
|
||||
public long GetCPUAvailable()
|
||||
public long getCPUAvailable()
|
||||
{
|
||||
return osBean.getAvailableProcessors();
|
||||
}
|
||||
|
||||
public ThreadData GetThreadData()
|
||||
public ThreadData getThreadData()
|
||||
{
|
||||
return commandManager.DumpThreadData();
|
||||
return commandManager.dumpThreadData();
|
||||
}
|
||||
|
||||
public int GetGuildCount()
|
||||
public int getGuildCount()
|
||||
{
|
||||
return ObjectBuilderFactory.GetGuildCount();
|
||||
return ObjectBuilderFactory.getGuildCount();
|
||||
}
|
||||
|
||||
public int GetUserCount()
|
||||
public int getUserCount()
|
||||
{
|
||||
return ObjectBuilderFactory.GetUserCount();
|
||||
return ObjectBuilderFactory.getUserCount();
|
||||
}
|
||||
|
||||
public ArrayList<Command> GetAllCommands()
|
||||
public ArrayList<Command> getAllCommands()
|
||||
{
|
||||
return commandManager.GetAllRegisteredCommands();
|
||||
return commandManager.getAllRegisteredCommands();
|
||||
}
|
||||
|
||||
public String GetHelpText(String commandName)
|
||||
public String getHelpText(String commandName)
|
||||
{
|
||||
return commandManager.GetCommandHelpText(commandName);
|
||||
return commandManager.getCommandHelpText(commandName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ public abstract class BenchmarkCommand
|
||||
{ }
|
||||
|
||||
// OVERRIDE ME
|
||||
public abstract BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input);
|
||||
public abstract BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input);
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ public class BenchmarkFormattable
|
||||
this.resString = null;
|
||||
}
|
||||
|
||||
public void Call(Response res)
|
||||
public void call(Response res)
|
||||
{
|
||||
if(resEmbed == null)
|
||||
res.Call(resString);
|
||||
res.send(resString);
|
||||
else
|
||||
res.CallEmbed(resEmbed);
|
||||
res.send(resEmbed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,43 +16,43 @@ public class BenchmarkFramework
|
||||
this.benchmarkManager = new BenchmarkManager();
|
||||
this.benchmarkCommand = new HashMap<String, BenchmarkCommand>();
|
||||
|
||||
RegisterCommand("find", new BenchmarkCommandFind());
|
||||
RegisterCommand("compare", new BenchmarkCommandCompare());
|
||||
RegisterCommand("info", new BenchmarkCommandInfo());
|
||||
registerCommand("find", new BenchmarkCommandFind());
|
||||
registerCommand("compare", new BenchmarkCommandCompare());
|
||||
registerCommand("info", new BenchmarkCommandInfo());
|
||||
}
|
||||
|
||||
// Runs a command if possible.
|
||||
public BenchmarkFormattable Run(String args)
|
||||
public BenchmarkFormattable run(String args)
|
||||
{
|
||||
BenchmarkInput input = new BenchmarkInput(args);
|
||||
return ExecuteCommand(input.key, input);
|
||||
return executeCommand(input.key, input);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public void update()
|
||||
{
|
||||
synchronized(benchmarkManager)
|
||||
{
|
||||
benchmarkManager.Update();
|
||||
benchmarkManager.update();
|
||||
}
|
||||
}
|
||||
|
||||
// Registers a command
|
||||
private void RegisterCommand(String commandName, BenchmarkCommand command)
|
||||
private void registerCommand(String commandName, BenchmarkCommand command)
|
||||
{
|
||||
commandName = commandName.toLowerCase();
|
||||
if(benchmarkCommand.put(commandName, command) != null)
|
||||
BenchmarkLog.Log("Multiple registration of a command with name '" + commandName + "'!");
|
||||
BenchmarkLog.log("Multiple registration of a command with name '" + commandName + "'!");
|
||||
|
||||
BenchmarkLog.Log("Registered " + commandName);
|
||||
BenchmarkLog.log("Registered " + commandName);
|
||||
}
|
||||
|
||||
// Executes a command with the specified name, and provides it with some extra input data.
|
||||
private BenchmarkFormattable ExecuteCommand(String name, BenchmarkInput input)
|
||||
private BenchmarkFormattable executeCommand(String name, BenchmarkInput input)
|
||||
{
|
||||
BenchmarkCommand command = benchmarkCommand.get(name.toLowerCase());
|
||||
|
||||
if(command != null && benchmarkManager != null)
|
||||
return command.OnRun(benchmarkManager, input);
|
||||
return command.onRun(benchmarkManager, input);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BenchmarkInput
|
||||
return;
|
||||
|
||||
raw = raw.trim();
|
||||
int whitespacePos = StringUtils.FindFirstWhitespace(raw);
|
||||
int whitespacePos = StringUtils.findFirstWhitespace(raw);
|
||||
|
||||
if(whitespacePos == -1)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import utils.GlobalLog;
|
||||
//Logging shim
|
||||
public class BenchmarkLog
|
||||
{
|
||||
public static void Log(String str) { GlobalLog.Log("[Benchmark] " + str); }
|
||||
public static void Warn(String str) { GlobalLog.Warn("[Benchmark] " + str); }
|
||||
public static void Error(String str) { GlobalLog.Error(" [Benchmark] " + str); }
|
||||
public static void log(String str) { GlobalLog.log("[Benchmark] " + str); }
|
||||
public static void warn(String str) { GlobalLog.warn("[Benchmark] " + str); }
|
||||
public static void error(String str) { GlobalLog.error(" [Benchmark] " + str); }
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import core.Config;
|
||||
import dataStructures.Pair;
|
||||
import utils.io.DirectoryMonitor;
|
||||
import utils.io.FileUtils;
|
||||
@@ -16,7 +17,7 @@ import utils.io.MonitoredFile;
|
||||
public class BenchmarkManager
|
||||
{
|
||||
// Variables
|
||||
public final String directory = "assets/userbench/";
|
||||
public final String directory = Config.AssetDirectory + "userbench/";
|
||||
public final String extension = ".csv";
|
||||
public final String lineDelimiter = "\n";
|
||||
|
||||
@@ -33,13 +34,13 @@ public class BenchmarkManager
|
||||
directoryMonitor = new DirectoryMonitor(directory);
|
||||
needsUpdate = false;
|
||||
|
||||
RebuildLookup();
|
||||
rebuildLookup();
|
||||
|
||||
BenchmarkLog.Log("Took " + (Instant.now().toEpochMilli() - start) + " ms to load " + raw.size() + " entries from " + directoryMonitor.GetCurrentFiles().size() + " file" + (raw.size() > 1 ? "s" : ""));
|
||||
BenchmarkLog.log("Took " + (Instant.now().toEpochMilli() - start) + " ms to load " + raw.size() + " entries from " + directoryMonitor.getCurrentFiles().size() + " file" + (raw.size() > 1 ? "s" : ""));
|
||||
}
|
||||
|
||||
// Rebuilds the files being monitored
|
||||
public void RebuildLookup()
|
||||
public void rebuildLookup()
|
||||
{
|
||||
long start = Instant.now().toEpochMilli();
|
||||
|
||||
@@ -50,14 +51,14 @@ public class BenchmarkManager
|
||||
|
||||
synchronized(directoryMonitor)
|
||||
{
|
||||
files = directoryMonitor.GetCurrentFiles();
|
||||
files = directoryMonitor.getCurrentFiles();
|
||||
}
|
||||
|
||||
if(files != null)
|
||||
{
|
||||
for(MonitoredFile mf : files)
|
||||
{
|
||||
String contents = FileUtils.ReadContent(mf.path);
|
||||
String contents = FileUtils.readContent(mf.path);
|
||||
String[] lines = contents.split(lineDelimiter);
|
||||
|
||||
for(int i = 1; i < lines.length; ++i)
|
||||
@@ -66,17 +67,17 @@ public class BenchmarkManager
|
||||
}
|
||||
else
|
||||
{
|
||||
BenchmarkLog.Warn("No " + extension + " files where found in " + directory);
|
||||
BenchmarkLog.warn("No " + extension + " files where found in " + directory);
|
||||
}
|
||||
}
|
||||
|
||||
long end = Instant.now().toEpochMilli();
|
||||
BenchmarkLog.Log("Rebuilt data in " + (end - start) + "ms");
|
||||
BenchmarkLog.log("Rebuilt data in " + (end - start) + "ms");
|
||||
}
|
||||
|
||||
// Re-evaluates and re-orders the input list based on the Levenshtein distance of the
|
||||
// original search and the contents of the provided list of benchmark entries.
|
||||
public List<BenchmarkEntry> EvaluateLevenshteinDistance(List<BenchmarkEntry> entries, String search)
|
||||
public List<BenchmarkEntry> evaluateLevenshteinDistance(List<BenchmarkEntry> entries, String search)
|
||||
{
|
||||
// Populate cost list with heuristic results
|
||||
List<Pair<BenchmarkEntry, Integer>> cost = new ArrayList<Pair<BenchmarkEntry, Integer>>();
|
||||
@@ -86,7 +87,7 @@ public class BenchmarkManager
|
||||
BenchmarkEntry entry = entries.get(i);
|
||||
String entryString = entry.brand + " " + entry.model;
|
||||
|
||||
int heuristic = LevenshteinHeuristic(entryString, search, bestSoFar);
|
||||
int heuristic = levenshteinHeuristic(entryString, search, bestSoFar);
|
||||
if(heuristic < bestSoFar)
|
||||
bestSoFar = heuristic;
|
||||
|
||||
@@ -120,7 +121,7 @@ public class BenchmarkManager
|
||||
// Returns cost based on distance of characters from string. This is a kinda sloppy way
|
||||
// to do it, but because I keep tabs on the best result so far, it could be much worse.
|
||||
// Still chucks a lot - a non-recursive result w/ memoization would be best but this will do.
|
||||
private int LevenshteinHeuristic(String str1, String str2, int bestSoFar)
|
||||
private int levenshteinHeuristic(String str1, String str2, int bestSoFar)
|
||||
{
|
||||
int cost;
|
||||
|
||||
@@ -139,15 +140,15 @@ public class BenchmarkManager
|
||||
if(distance > bestSoFar)
|
||||
return distance;
|
||||
|
||||
int s1 = LevenshteinHeuristic(str1.substring(1), str2, bestSoFar) + 1;
|
||||
int s2 = LevenshteinHeuristic(str1, str2.substring(1), bestSoFar) + 1;
|
||||
int s3 = LevenshteinHeuristic(str1.substring(1), str2.substring(1), bestSoFar) + cost;
|
||||
int s1 = levenshteinHeuristic(str1.substring(1), str2, bestSoFar) + 1;
|
||||
int s2 = levenshteinHeuristic(str1, str2.substring(1), bestSoFar) + 1;
|
||||
int s3 = levenshteinHeuristic(str1.substring(1), str2.substring(1), bestSoFar) + cost;
|
||||
|
||||
return min(new int[] {s1, s2, s3 });
|
||||
}
|
||||
|
||||
// Search for a substring in the model name
|
||||
public List<BenchmarkEntry> FindModel(String modelSubstr)
|
||||
public List<BenchmarkEntry> findModel(String modelSubstr)
|
||||
{
|
||||
long start = Instant.now().toEpochMilli();
|
||||
List<BenchmarkEntry> matching = new ArrayList<BenchmarkEntry>();
|
||||
@@ -161,27 +162,27 @@ public class BenchmarkManager
|
||||
matching.add(e);
|
||||
}
|
||||
|
||||
BenchmarkLog.Log("Searched for '" + searchSubstr + "' for "+ (Instant.now().toEpochMilli() - start) + "ms and found " + matching.size() + " entries.");
|
||||
BenchmarkLog.log("Searched for '" + searchSubstr + "' for "+ (Instant.now().toEpochMilli() - start) + "ms and found " + matching.size() + " entries.");
|
||||
return matching;
|
||||
}
|
||||
|
||||
// Keeps tabs on any changes of the files.
|
||||
public void Update()
|
||||
public void update()
|
||||
{
|
||||
needsUpdate = false;
|
||||
directoryMonitor.Update(this::OnRescan, this::OnRescan, this::OnRescan);
|
||||
directoryMonitor.update(this::onRescan, this::onRescan, this::onRescan);
|
||||
|
||||
if(needsUpdate)
|
||||
RebuildLookup();
|
||||
rebuildLookup();
|
||||
}
|
||||
|
||||
// When a file is changed, handle it.
|
||||
private void OnRescan(MonitoredFile file)
|
||||
private void onRescan(MonitoredFile file)
|
||||
{
|
||||
// For now, all we need is to note that something was adjusted.
|
||||
if(file.path.toString().contains(extension))
|
||||
{
|
||||
BenchmarkLog.Log("File status changed: " + file.path);
|
||||
BenchmarkLog.log("File status changed: " + file.path);
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,17 +44,17 @@ public class Plugin
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
PluginLog.Error(e.getMessage());
|
||||
PluginLog.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> Run(String args, PluginUser user)
|
||||
public List<String> run(String args, PluginUser user)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<String> outputs = new Vector<String>();
|
||||
|
||||
LuaValue res = func_plugin.call(LuaValue.valueOf(args), user.AsLua());
|
||||
LuaValue res = func_plugin.call(LuaValue.valueOf(args), user.asLua());
|
||||
|
||||
if(!res.isnil())
|
||||
{
|
||||
@@ -87,7 +87,7 @@ public class Plugin
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
PluginLog.Error("Failed to run plugin from file " + filepath);
|
||||
PluginLog.error("Failed to run plugin from file " + filepath);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -5,7 +5,7 @@ import utils.LogFilter;
|
||||
|
||||
public class PluginLog
|
||||
{
|
||||
public static void Log(String s) { GlobalLog.Log(LogFilter.Plugin, s); }
|
||||
public static void Warn(String s) { GlobalLog.Warn(LogFilter.Plugin, s); }
|
||||
public static void Error(String s) { GlobalLog.Error(LogFilter.Plugin, s); }
|
||||
public static void log(String s) { GlobalLog.log(LogFilter.Plugin, s); }
|
||||
public static void warn(String s) { GlobalLog.warn(LogFilter.Plugin, s); }
|
||||
public static void error(String s) { GlobalLog.error(LogFilter.Plugin, s); }
|
||||
}
|
||||
|
||||
@@ -12,14 +12,11 @@ import dataStructures.KittyUser;
|
||||
// Reads in, handles, and manipulates plugins. Plugins are loaded in the order they appear in the folder.
|
||||
public class PluginManager
|
||||
{
|
||||
// Variables
|
||||
public final String pluginFolder;
|
||||
public ArrayList<Plugin> plugins;
|
||||
|
||||
public void AddPlugin(Path path)
|
||||
{
|
||||
plugins.add(new Plugin(path));
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public PluginManager(String folder)
|
||||
{
|
||||
this.pluginFolder = folder;
|
||||
@@ -29,30 +26,35 @@ public class PluginManager
|
||||
{
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(this.pluginFolder)))
|
||||
{
|
||||
paths.filter(Files::isRegularFile).forEach((path)->{ AddPlugin(path); });
|
||||
paths.filter(Files::isRegularFile).forEach((path)->{ addPlugin(path); });
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
PluginLog.Error(e.getMessage());
|
||||
PluginLog.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlugin(Path path)
|
||||
{
|
||||
plugins.add(new Plugin(path));
|
||||
}
|
||||
|
||||
// Runs all plugins, returning when it gets a non-nill result. If there
|
||||
// are mutliple strings returned in the list, it is because the plugin
|
||||
// that was run returned multiple strings. Since plugins don't stack, it
|
||||
// will never indicate that multiple
|
||||
// Otherwise, returns null.
|
||||
public List<String> RunAll(String input, KittyUser user)
|
||||
public List<String> runAll(String input, KittyUser user)
|
||||
{
|
||||
for(int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
Plugin plugin = plugins.get(i);
|
||||
List<String> out = plugin.Run(input, new PluginUser(user));
|
||||
List<String> out = plugin.run(input, new PluginUser(user));
|
||||
|
||||
if(out != null)
|
||||
{
|
||||
PluginLog.Log("Executed plugin at " + plugin.filepath);
|
||||
PluginLog.log("Executed plugin at " + plugin.filepath);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -60,9 +62,10 @@ public class PluginManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public void PrintAll()
|
||||
// Dumps the contents of all plugins for debug
|
||||
public void printAll()
|
||||
{
|
||||
for(int i = 0; i < plugins.size(); ++i)
|
||||
PluginLog.Log(plugins.get(i).contents.toString());
|
||||
PluginLog.log(plugins.get(i).contents.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||
|
||||
public class PluginStructure
|
||||
{
|
||||
public LuaValue AsLua()
|
||||
public LuaValue asLua()
|
||||
{
|
||||
return CoerceJavaToLua.coerce(this);
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ public class RPGArmor extends RPGItem
|
||||
defense = 1;
|
||||
}
|
||||
|
||||
public long GetDefense() { return defense; }
|
||||
public long getDefense() { return defense; }
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user