Merge branch 'develop'
This commit is contained in:
@@ -14,5 +14,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/twitter4j-core-4.0.7-javadoc.jar"/>
|
<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/twitter4j-core-4.0.7.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/luaj-jse-3.0.1.jar"/>
|
<classpathentry kind="lib" path="lib/luaj-jse-3.0.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/fuzzywuzzy-1.2.0.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ buildhelp=1
|
|||||||
c++, g++, cplus, cpp=1
|
c++, g++, cplus, cpp=1
|
||||||
catch=1
|
catch=1
|
||||||
charactercreate=1
|
charactercreate=1
|
||||||
|
charactereditbio=1
|
||||||
|
charactereditname=1
|
||||||
|
characterediturl=1
|
||||||
choose=1
|
choose=1
|
||||||
|
color, colour=1
|
||||||
crouton=1
|
crouton=1
|
||||||
dbflush=1
|
dbflush=1
|
||||||
dbstats=1
|
dbstats=1
|
||||||
@@ -42,6 +46,7 @@ roll=1
|
|||||||
rpend=1
|
rpend=1
|
||||||
rpg=1
|
rpg=1
|
||||||
rpstart=1
|
rpstart=1
|
||||||
|
searchcharacter=1
|
||||||
showpoll=1
|
showpoll=1
|
||||||
shutdown=1
|
shutdown=1
|
||||||
stats=1
|
stats=1
|
||||||
|
|||||||
Binary file not shown.
@@ -7,10 +7,12 @@ benchmark, bench=
|
|||||||
rating=
|
rating=
|
||||||
poll=
|
poll=
|
||||||
rafflespin=
|
rafflespin=
|
||||||
|
charactereditURL=
|
||||||
bet=
|
bet=
|
||||||
guildrolelist=
|
guildrolelist=
|
||||||
stats=
|
stats=
|
||||||
catch=
|
catch=
|
||||||
|
color, colour=
|
||||||
guildroleadd=
|
guildroleadd=
|
||||||
results=
|
results=
|
||||||
wolfram=
|
wolfram=
|
||||||
@@ -30,6 +32,7 @@ tony, stark, dontfeelgood, dontfeelsogood=
|
|||||||
role=
|
role=
|
||||||
raffleend=
|
raffleend=
|
||||||
ping=
|
ping=
|
||||||
|
charactereditbio=
|
||||||
roll=
|
roll=
|
||||||
blur=
|
blur=
|
||||||
choose=
|
choose=
|
||||||
@@ -37,6 +40,7 @@ rpstart=
|
|||||||
guildrolenotallowed=
|
guildrolenotallowed=
|
||||||
perish, thenperish=
|
perish, thenperish=
|
||||||
teey=
|
teey=
|
||||||
|
searchcharacter=
|
||||||
dbstats=
|
dbstats=
|
||||||
rafflestart=
|
rafflestart=
|
||||||
beans=
|
beans=
|
||||||
@@ -49,6 +53,7 @@ rpg=
|
|||||||
tweet=
|
tweet=
|
||||||
charactercreate=
|
charactercreate=
|
||||||
help=
|
help=
|
||||||
|
charactereditname=
|
||||||
fetch=
|
fetch=
|
||||||
crouton=
|
crouton=
|
||||||
invite=
|
invite=
|
||||||
|
|||||||
+37
-5
@@ -89,6 +89,17 @@ RaffleEndSuccess=
|
|||||||
RaffleEndInfo=
|
RaffleEndInfo=
|
||||||
RaffleEndFailure=I don't think there's one going!
|
RaffleEndFailure=I don't think there's one going!
|
||||||
|
|
||||||
|
[CommandCharacterSearch]
|
||||||
|
CharacterSearchNoCharacterFound=Couldn't find a character with that name or ID!
|
||||||
|
CharacterSearchMultipleCharacterHeader=I found a couple characters with that name, use `charactersearch UniqueID` with their Unique ID to find them!
|
||||||
|
CharacterSearchMultipleCharacter=%s is owned by %s. Unique ID is `%s`
|
||||||
|
CharacterSearchOneCharacter=I found one character with that name! \n Owner: %s | Name: %s | Bio: %s | Ref: <%s> | Unique ID: `%s`
|
||||||
|
CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID`
|
||||||
|
|
||||||
|
[CommandColor]
|
||||||
|
ColorNotSearchable=Your color couldn't be parsed! Make sure it's in hex format. Try this! `!color 3F5D54`
|
||||||
|
ColorInfo=Looks up the provided hex color and outputs it as hex, rgb, hsl, hsv, xyz, and cmyk. Also attempts to name the color, and provies a sample of it! Usage example: `!color #365345` (the # can be omitted)
|
||||||
|
|
||||||
[CommandDoWork]
|
[CommandDoWork]
|
||||||
DoWorkFinished=I finished with my work! :D
|
DoWorkFinished=I finished with my work! :D
|
||||||
DoWorkInfo=Occupies a core for a few seconds
|
DoWorkInfo=Occupies a core for a few seconds
|
||||||
@@ -123,6 +134,13 @@ PollShowChoices=And the choices are:\n
|
|||||||
[CommandHelpBuilder]
|
[CommandHelpBuilder]
|
||||||
HelpBuilderInfo=Emit help for all commands as formatted HTML
|
HelpBuilderInfo=Emit help for all commands as formatted HTML
|
||||||
|
|
||||||
|
[CommandCharacterEditURL]
|
||||||
|
CharacterEditURLInfo=
|
||||||
|
CharacterEditURLNotValid=
|
||||||
|
CharacterEditURLSuccess=
|
||||||
|
CharacterEditURLNotAuth=
|
||||||
|
CharacterEditURLIDNotValid=
|
||||||
|
|
||||||
[CommandRPG]
|
[CommandRPG]
|
||||||
RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg <rpg command>
|
RPGInfo=Admin+ command only right now - experimental text RPG! Format is !rpg <rpg command>
|
||||||
RPGInvalid=Invalid RPG Command!
|
RPGInvalid=Invalid RPG Command!
|
||||||
@@ -153,7 +171,7 @@ WolframInfo=Will query wolframalpha with your question and give a full image out
|
|||||||
WolframNoArgs=You need to provide some arguments!
|
WolframNoArgs=You need to provide some arguments!
|
||||||
|
|
||||||
[CommandMap]
|
[CommandMap]
|
||||||
MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed>-w<width>-h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\nDefault seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)
|
MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed> -w<width> -h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\n**Defaults**\nDefault Seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)\n\n**Key**\nLand: ˶\nMountain: ▲\nBeach: =\nMarsh: ¥\nLava: #
|
||||||
MapSeed=Seed
|
MapSeed=Seed
|
||||||
MapInvalid=Invalid arguments provided!
|
MapInvalid=Invalid arguments provided!
|
||||||
MapVersion=Using mapgen v0.1
|
MapVersion=Using mapgen v0.1
|
||||||
@@ -175,6 +193,13 @@ RaffleStartInfo=
|
|||||||
HelpInfo=Lets you look up specific commands, or get a link to a list of all commands.
|
HelpInfo=Lets you look up specific commands, or get a link to a list of all commands.
|
||||||
HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet`
|
HelpDisplay=You can get help with a specific command by typing `!help command`!\nGeneral Commands: `boop, roll, choose, help, info, vote, results, showpoll, wolfram, cplus, java, beans, role, bet, yeet`
|
||||||
|
|
||||||
|
[CommandCharacterEditBio]
|
||||||
|
CharacterEditBioSuccess=
|
||||||
|
CharacterEditBioIDNotValid=
|
||||||
|
CharacterEditBioNotAuth=
|
||||||
|
CharacterEditBioInfo=
|
||||||
|
CharacterEditBioNotValid=
|
||||||
|
|
||||||
[CommandTweet]
|
[CommandTweet]
|
||||||
TweetInfo=Kitty will tweet to her personal twitter account
|
TweetInfo=Kitty will tweet to her personal twitter account
|
||||||
TweetError=Tweet command failed!
|
TweetError=Tweet command failed!
|
||||||
@@ -185,6 +210,13 @@ GuildRoleAddFailure=Failed to add %s to %s
|
|||||||
GuildRoleAddNotAllowed=You are not allowed to add %s!
|
GuildRoleAddNotAllowed=You are not allowed to add %s!
|
||||||
GuildRoleAddInfo=Add a role to yourself!
|
GuildRoleAddInfo=Add a role to yourself!
|
||||||
|
|
||||||
|
[CommandCharacterEditName]
|
||||||
|
CharacterEditNameInfo=
|
||||||
|
CharacterEditNameNotValid=
|
||||||
|
CharacterEditNameIDNotValid=
|
||||||
|
CharacterEditNameSuccess=
|
||||||
|
CharacterEditNameNotAuth=
|
||||||
|
|
||||||
[CommandColiru]
|
[CommandColiru]
|
||||||
ColiruError=Please provide some c++ code to attempt to compile!
|
ColiruError=Please provide some c++ code to attempt to compile!
|
||||||
ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++.
|
ColiruInfo=Will try to compile any c++ code you put in! Supports up to C++14 standard, uses g++.
|
||||||
@@ -199,10 +231,10 @@ YeetInfo=Yeet yourself or yeet a friend with @!
|
|||||||
CroutonInfo=Crouton
|
CroutonInfo=Crouton
|
||||||
|
|
||||||
[CommandCharacterCreate]
|
[CommandCharacterCreate]
|
||||||
CharacterCreateDuplicate=
|
CharacterCreateDuplicate=You can't create a character with the same name!
|
||||||
CharacterCreateInfo=
|
CharacterCreateInfo=Create a character for kitty to hold onto for you! `createcharacter name, shortbio, refURL`
|
||||||
CharacterCreateSuccess=
|
CharacterCreateSuccess=You successfully created a character!
|
||||||
CharacterCreateNullInfo=
|
CharacterCreateNullInfo=There's not enough info!
|
||||||
|
|
||||||
[CommandTeey]
|
[CommandTeey]
|
||||||
TeeyInfo=Teey yourself back into existance, or teey a friend with @!
|
TeeyInfo=Teey yourself back into existance, or teey a friend with @!
|
||||||
|
|||||||
@@ -9,21 +9,21 @@ public class CommandBeansShow extends Command
|
|||||||
public CommandBeansShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandBeansShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BeansShowInfo"); };
|
public String getHelpText() { return LocStrings.stub("BeansShowInfo"); };
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.mentions == null)
|
||||||
res.Call(String.format(LocStrings.Stub("BeansShowDisplay"), user.GetBeans()));
|
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String mentionedBeans = "";
|
String mentionedBeans = "";
|
||||||
for(KittyUser mentioned:input.mentions)
|
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
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BenchmarkInfo"); }
|
public String getHelpText() { return LocStrings.stub("BenchmarkInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.args == null || input.args.length() == 0)
|
||||||
{
|
{
|
||||||
String output = HelpText();
|
String output = getHelpText();
|
||||||
res.Call(output);
|
res.send(output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BenchmarkFormattable commandOutput = null;
|
BenchmarkFormattable commandOutput = null;
|
||||||
synchronized(framework)
|
synchronized(framework)
|
||||||
{
|
{
|
||||||
commandOutput = framework.Run(input.args.trim());
|
commandOutput = framework.run(input.args.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(commandOutput == null)
|
if(commandOutput == null)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("BenchmarkInvalid"));
|
res.send(LocStrings.stub("BenchmarkInvalid"));
|
||||||
return;
|
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); }
|
public CommandBetBeans(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BetBeansInfo"); }
|
public String getHelpText() { return LocStrings.stub("BetBeansInfo"); }
|
||||||
|
|
||||||
@Override
|
@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 = "";
|
String call = "";
|
||||||
int bet = 0;
|
int bet = 0;
|
||||||
@@ -24,41 +24,41 @@ public class CommandBetBeans extends Command
|
|||||||
bet = Integer.parseInt(input.args);
|
bet = Integer.parseInt(input.args);
|
||||||
if(bet < 50)
|
if(bet < 50)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("BetBeansLowBet"));
|
res.send(LocStrings.stub("BetBeansLowBet"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("BetBeansNotValid"));
|
res.send(LocStrings.stub("BetBeansNotValid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user.GetBeans() < bet)
|
if(user.getBeans() < bet)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("BetBeansNotEnough"));
|
res.send(LocStrings.stub("BetBeansNotEnough"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.ChangeBeans(-bet);
|
user.changeBeans(-bet);
|
||||||
int [] slots = getSlots();
|
int [] slots = getSlots();
|
||||||
call += slotString(slots);
|
call += slotString(slots);
|
||||||
slots = sort(slots);
|
slots = sort(slots);
|
||||||
|
|
||||||
win = getWinning(slots);
|
win = getWinning(slots);
|
||||||
|
|
||||||
res.Call(call);
|
res.send(call);
|
||||||
|
|
||||||
if(win == 0)
|
if(win == 0)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("BetBeansLose"));
|
res.send(LocStrings.stub("BetBeansLose"));
|
||||||
guild.beans.Add(bet);
|
guild.beans.add(bet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.ChangeBeans(bet*win);
|
user.changeBeans(bet*win);
|
||||||
guild.beans.Subtract(bet*win);
|
guild.beans.subtract(bet*win);
|
||||||
res.Call(String.format(LocStrings.Stub("BetBeansWin"), "" + (bet*win)));
|
res.send(String.format(LocStrings.stub("BetBeansWin"), "" + (bet*win)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getWinning(int [] slots)
|
private int getWinning(int [] slots)
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ public class CommandBetHistory extends Command
|
|||||||
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BetHistoryInfo"); }
|
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
||||||
|
|
||||||
@Override
|
@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); }
|
public CommandBlurry(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BlurryInfo"); };
|
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@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 name = null;
|
||||||
String filename = null;
|
String filename = null;
|
||||||
@@ -39,7 +39,7 @@ public class CommandBlurry extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@@ -48,12 +48,12 @@ public class CommandBlurry extends Command
|
|||||||
if(input.mentions != null)
|
if(input.mentions != null)
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(filename == null)
|
if(filename == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
ApplySnap(ImageIO.read(preProcessed), name);
|
applySnap(ImageIO.read(preProcessed), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -61,13 +61,13 @@ public class CommandBlurry extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
postProcessed = new File(name);
|
postProcessed = new File(name);
|
||||||
res.CallFile(postProcessed, "png");
|
res.sendFile(postProcessed, "png");
|
||||||
|
|
||||||
ImageUtils.BlockingFileDelete(preProcessed);
|
ImageUtils.blockingFileDelete(preProcessed);
|
||||||
ImageUtils.BlockingFileDelete(postProcessed);
|
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);
|
BufferedImage blurred = ImageUtils.copyImage(image);
|
||||||
// Iterate over each column left to right and touch up each pixel
|
// 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 BoopTracker() { super("booptracker"); }
|
||||||
|
|
||||||
public void ApplyBoop()
|
public void applyBoop()
|
||||||
{
|
{
|
||||||
++boops;
|
++boops;
|
||||||
MarkDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int HowMany()
|
public int howMany()
|
||||||
{
|
{
|
||||||
return boops;
|
return boops;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String Serialize() { return "" + boops; }
|
public String serialize() { return "" + boops; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void DeSerialzie(String string)
|
public void deSerialzie(String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -42,9 +42,9 @@ public class CommandBoop extends Command
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
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;
|
boops = 0;
|
||||||
MarkDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,37 +60,37 @@ public class CommandBoop extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("BoopInfo"); }
|
public String getHelpText() { return LocStrings.stub("BoopInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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)
|
if(input.mentions == null)
|
||||||
{
|
{
|
||||||
boopTracker.ApplyBoop();
|
boopTracker.applyBoop();
|
||||||
res.Call(String.format(LocStrings.Stub("BoopStandard"), user.name, boopTracker.HowMany()));
|
res.send(String.format(LocStrings.stub("BoopStandard"), user.name, boopTracker.howMany()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(input.mentions.length == 1)
|
if(input.mentions.length == 1)
|
||||||
{
|
{
|
||||||
boopTracker.ApplyBoop();
|
boopTracker.applyBoop();
|
||||||
res.Call(String.format(LocStrings.Stub("BoopPerson"), user.name, input.mentions[0].name));
|
res.send(String.format(LocStrings.stub("BoopPerson"), user.name, input.mentions[0].name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String booped = "";
|
String booped = "";
|
||||||
for(int i = 0; i < input.mentions.length; i++)
|
for(int i = 0; i < input.mentions.length; i++)
|
||||||
{
|
{
|
||||||
boopTracker.ApplyBoop();
|
boopTracker.applyBoop();
|
||||||
if(i < input.mentions.length-1)
|
if(i < input.mentions.length-1)
|
||||||
booped += input.mentions[i].name + ", ";
|
booped += input.mentions[i].name + ", ";
|
||||||
else
|
else
|
||||||
booped += "and " + input.mentions[i].name;
|
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;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("CatchInfo"); }
|
public String getHelpText() { return LocStrings.stub("CatchInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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 name = null;
|
||||||
File catchFile = null;
|
File catchFile = null;
|
||||||
@@ -48,13 +48,13 @@ public class CommandCatch extends Command
|
|||||||
else
|
else
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
String catchFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
String catchFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(catchFilename == null)
|
if(catchFilename == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
catcheeFile = new File(catchFilename);
|
catcheeFile = new File(catchFilename);
|
||||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/catch/frames/", "catch ", 92, 18);
|
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)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -62,10 +62,10 @@ public class CommandCatch extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
catchFile = new File (name);
|
catchFile = new File (name);
|
||||||
res.CallFile(catchFile, "gif");
|
res.sendFile(catchFile, "gif");
|
||||||
|
|
||||||
// Thread cleanup...
|
// Thread cleanup...
|
||||||
ImageUtils.BlockingFileDelete(catchFile);
|
ImageUtils.blockingFileDelete(catchFile);
|
||||||
ImageUtils.BlockingFileDelete(catcheeFile);
|
ImageUtils.blockingFileDelete(catcheeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,26 +9,26 @@ public class CommandChangeIndicator extends Command
|
|||||||
public CommandChangeIndicator(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandChangeIndicator(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("ChangeIndicatorInfo"); }
|
public String getHelpText() { return LocStrings.stub("ChangeIndicatorInfo"); }
|
||||||
|
|
||||||
@Override
|
@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();
|
String arg = input.args.trim();
|
||||||
if(arg.length() == 0)
|
if(arg.length() == 0)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("ChangeIndicatorError"));
|
res.send(LocStrings.stub("ChangeIndicatorError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String indicator = arg.substring(0, 1);
|
String indicator = arg.substring(0, 1);
|
||||||
if(indicator.charAt(0) == '\n' || indicator.charAt(0) == '\t' || indicator.charAt(0) == '\r')
|
if(indicator.charAt(0) == '\n' || indicator.charAt(0) == '\t' || indicator.charAt(0) == '\r')
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Lookup("ChangeIndicatorError"));
|
res.send(LocStrings.lookup("ChangeIndicatorError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.SetCommandIndicator(indicator);
|
guild.setCommandIndicator(indicator);
|
||||||
res.Call(String.format(LocStrings.Stub("ChangeIndicatorChanged"), guild.GetCommandIndicator()));
|
res.send(String.format(LocStrings.stub("ChangeIndicatorChanged"), guild.getCommandIndicator()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,26 +13,25 @@ import dataStructures.UserInput;
|
|||||||
|
|
||||||
public class CommandCharacterCreate extends Command
|
public class CommandCharacterCreate extends Command
|
||||||
{
|
{
|
||||||
public CommandCharacterCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandCharacterCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("CharacterCreateInfo"); }
|
public String getHelpText() { return LocStrings.stub("CharacterCreateInfo"); }
|
||||||
|
|
||||||
@Override
|
@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(",");
|
String [] info = input.args.split(",");
|
||||||
if(info.length < 3)
|
if(info.length < 3)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("CharacterCreateNullInfo"));
|
res.send(LocStrings.stub("CharacterCreateNullInfo"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(CharacterManager.instance.addCharacter(user, info[0], info[1], info[2]))
|
if(CharacterManager.instance.addCharacter(user, info[0], info[1], info[2]))
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("CharacterCreateSuccess"));
|
res.send(LocStrings.stub("CharacterCreateSuccess"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.Call(LocStrings.Stub("CharacterCreateDuplicate"));
|
res.send(LocStrings.stub("CharacterCreateDuplicate"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package commands;
|
||||||
|
|
||||||
|
import core.CharacterManager;
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandCharacterEditBio extends Command
|
||||||
|
{
|
||||||
|
public CommandCharacterEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("CharacterEditBioInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
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.send(LocStrings.stub("CharacterEditBioSuccess"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.send(LocStrings.stub("CharacterEditBioNotAuth"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package commands;
|
||||||
|
|
||||||
|
import core.CharacterManager;
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandCharacterEditName extends Command
|
||||||
|
{
|
||||||
|
public CommandCharacterEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("CharacterEditNameInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
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.send(LocStrings.stub("CharacterEditNameSuccess"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.send(LocStrings.stub("CharacterEditNameNotAuth"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package commands;
|
||||||
|
|
||||||
|
import core.CharacterManager;
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandCharacterEditURL extends Command
|
||||||
|
{
|
||||||
|
public CommandCharacterEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("CharacterEditURLInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
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.send(LocStrings.stub("CharacterEditURLSuccess"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.send(LocStrings.stub("CharacterEditURLNotAuth"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import core.CharacterManager;
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandCharacterSearch extends Command
|
||||||
|
{
|
||||||
|
public CommandCharacterSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("CharacterSearchInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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.send(LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(characters.size() > 1)
|
||||||
|
{
|
||||||
|
res.send(LocStrings.stub("CharacterSearchMultipleCharacterHeader"));
|
||||||
|
for(KittyCharacter character:characters)
|
||||||
|
{
|
||||||
|
res.send(String.format(LocStrings.stub("CharacterSearchMultipleCharacter"), character.getName(), character.getOwner().name, character.getUID()));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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,18 +14,25 @@ public class CommandChoose extends Command
|
|||||||
public CommandChoose(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandChoose(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("ChooseInfo"); }
|
public String getHelpText() { return LocStrings.stub("ChooseInfo"); }
|
||||||
|
|
||||||
@Override
|
@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 [] choices = input.args.split(",");
|
if(input.args.trim().length() == 0)
|
||||||
if(choices.length == 1)
|
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("ChooseOne"));
|
res.send(Stats.instance.getHelpText(input.key));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Call(String.format(LocStrings.Stub("ChooseChoice"), (choices[(int) (Math.random()*choices.length)]).toString()));
|
String [] choices = input.args.split(",");
|
||||||
|
|
||||||
|
if(choices.length == 1)
|
||||||
|
{
|
||||||
|
res.send(LocStrings.stub("ChooseOne"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);}
|
public CommandColiru(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("ColiruInfo"); }
|
public String getHelpText() { return LocStrings.stub("ColiruInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.args.trim().length() < 1)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("ColiruError"));
|
res.send(LocStrings.stub("ColiruError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Call(compiler.compileCPlus(input.args));
|
res.send(compiler.compileCPlusPlus(input.args));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package commands;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyEmbed;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
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 getHelpText() { return LocStrings.stub("ColorInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
// First, try and parse out the color to make sure we can even get it.
|
||||||
|
ColorData colorData = theColorAPI.lookupHex(input.args.trim());
|
||||||
|
|
||||||
|
// 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.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 + ".");
|
||||||
|
|
||||||
|
// 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); }
|
public CommandCrouton(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("CroutonInfo"); };
|
public String getHelpText() { return LocStrings.stub("CroutonInfo"); };
|
||||||
|
|
||||||
@Override
|
@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();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.authorImage = "https://crouton.net/crouton.png";
|
embed.authorImage = "https://crouton.net/crouton.png";
|
||||||
@@ -34,7 +34,7 @@ public class CommandCrouton extends Command
|
|||||||
|
|
||||||
embed.imageURL = "https://crouton.net/crouton.png";
|
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); }
|
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("DBFlushInfo"); }
|
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
||||||
|
|
||||||
@Override
|
@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();
|
int numUpdated = DatabaseManager.instance.upkeep();
|
||||||
|
|
||||||
@@ -30,6 +30,6 @@ public class CommandDBFlush extends Command
|
|||||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||||
embed.color = Config.ColorDefault;
|
embed.color = Config.ColorDefault;
|
||||||
|
|
||||||
res.CallEmbed(embed);
|
res.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ public class CommandDBStats extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("DBStatsInfo"); }
|
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
||||||
|
|
||||||
@Override
|
@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();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.title = "Database Info";
|
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.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
||||||
embed.color = Config.ColorDefault;
|
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); }
|
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("DoWorkInfo"); }
|
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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")
|
@SuppressWarnings("unused")
|
||||||
long thispieceofshit = 0;
|
long thispieceofshit = 0;
|
||||||
@@ -28,6 +28,6 @@ public class CommandDoWork extends Command
|
|||||||
thispieceofshit += Math.log((double)i);
|
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 =
|
String [] answers =
|
||||||
{
|
{
|
||||||
LocStrings.Stub("EightBallYes1")
|
LocStrings.stub("EightBallYes1")
|
||||||
, LocStrings.Stub("EightBallYes2")
|
, LocStrings.stub("EightBallYes2")
|
||||||
, LocStrings.Stub("EightBallYes3")
|
, LocStrings.stub("EightBallYes3")
|
||||||
, LocStrings.Stub("EightBallYes4")
|
, LocStrings.stub("EightBallYes4")
|
||||||
, LocStrings.Stub("EightBallYes5")
|
, LocStrings.stub("EightBallYes5")
|
||||||
, LocStrings.Stub("EightBallYes6")
|
, LocStrings.stub("EightBallYes6")
|
||||||
, LocStrings.Stub("EightBallYes7")
|
, LocStrings.stub("EightBallYes7")
|
||||||
, LocStrings.Stub("EightBallYes8")
|
, LocStrings.stub("EightBallYes8")
|
||||||
, LocStrings.Stub("EightBallYes9")
|
, LocStrings.stub("EightBallYes9")
|
||||||
, LocStrings.Stub("EightBallYes10")
|
, LocStrings.stub("EightBallYes10")
|
||||||
|
|
||||||
, LocStrings.Stub("EightBallMaybe1")
|
, LocStrings.stub("EightBallMaybe1")
|
||||||
, LocStrings.Stub("EightBallMaybe2")
|
, LocStrings.stub("EightBallMaybe2")
|
||||||
, LocStrings.Stub("EightBallMaybe3")
|
, LocStrings.stub("EightBallMaybe3")
|
||||||
, LocStrings.Stub("EightBallMaybe4")
|
, LocStrings.stub("EightBallMaybe4")
|
||||||
, LocStrings.Stub("EightBallMaybe5")
|
, LocStrings.stub("EightBallMaybe5")
|
||||||
|
|
||||||
, LocStrings.Stub("EightBallNo1")
|
, LocStrings.stub("EightBallNo1")
|
||||||
, LocStrings.Stub("EightBallNo2")
|
, LocStrings.stub("EightBallNo2")
|
||||||
, LocStrings.Stub("EightBallNo3")
|
, LocStrings.stub("EightBallNo3")
|
||||||
, LocStrings.Stub("EightBallNo4")
|
, LocStrings.stub("EightBallNo4")
|
||||||
, LocStrings.Stub("EightBallNo5")
|
, LocStrings.stub("EightBallNo5")
|
||||||
};
|
};
|
||||||
|
|
||||||
public CommandEightBall(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandEightBall(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("EightBallInfo"); }
|
public String getHelpText() { return LocStrings.stub("EightBallInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
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); }
|
public CommandFetch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("FetchInfo"); }
|
public String getHelpText() { return LocStrings.stub("FetchInfo"); }
|
||||||
|
|
||||||
@Override
|
@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];
|
String emote = input.args.split(" ")[0];
|
||||||
if(emote.startsWith("<") && emote.endsWith(">"))
|
if(emote.startsWith("<") && emote.endsWith(">"))
|
||||||
@@ -27,30 +27,30 @@ public class CommandFetch extends Command
|
|||||||
switch(num)
|
switch(num)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
res.Call(String.format(LocStrings.Stub("FetchBringBack"), emote));
|
res.send(String.format(LocStrings.stub("FetchBringBack"), emote));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
res.Call(String.format(LocStrings.Stub("FetchRunAway")));
|
res.send(String.format(LocStrings.stub("FetchRunAway")));
|
||||||
break;
|
break;
|
||||||
case 3:
|
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;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
res.Call(String.format(LocStrings.Stub("FetchEat"), emote));
|
res.send(String.format(LocStrings.stub("FetchEat"), emote));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
res.Call(String.format(LocStrings.Stub("FetchCatchRun"), emote));
|
res.send(String.format(LocStrings.stub("FetchCatchRun"), emote));
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
res.Call(String.format(LocStrings.Stub("FetchStare"), user.name));
|
res.send(String.format(LocStrings.stub("FetchStare"), user.name));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res.Call("" + num);
|
res.send("" + num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("FetchError")));
|
res.send(String.format(LocStrings.stub("FetchError")));
|
||||||
System.out.println(emote);
|
System.out.println(emote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ public class CommandGiveBeans extends Command
|
|||||||
public CommandGiveBeans (KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandGiveBeans (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("GiveBeansInfo"); }
|
public String getHelpText() { return LocStrings.stub("GiveBeansInfo"); }
|
||||||
|
|
||||||
@Override
|
@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
|
// First, make sure someone is mentioned
|
||||||
if(input.mentions == null)
|
if(input.mentions == null)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("GiveBeansNoneMentioned"));
|
res.send(LocStrings.stub("GiveBeansNoneMentioned"));
|
||||||
return;
|
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 there wasn't a number we could find, well, nothing we can do.
|
||||||
if(beans == null)
|
if(beans == null)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("GiveBeansInvalid"));
|
res.send(LocStrings.stub("GiveBeansInvalid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through all the mentions and make sure every user is given beans!
|
// Go through all the mentions and make sure every user is given beans!
|
||||||
for(int i = 0; i < input.mentions.length; i++)
|
for(int i = 0; i < input.mentions.length; i++)
|
||||||
{
|
{
|
||||||
input.mentions[i].ChangeBeans(beans);
|
input.mentions[i].changeBeans(beans);
|
||||||
res.Call(String.format(LocStrings.Stub("GiveBeansSuccess"), input.mentions[i].name, "" + 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); }
|
public CommandGuildRoleAdd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("GuildRoleAddInfo"); };
|
public String getHelpText() { return LocStrings.stub("GuildRoleAddInfo"); };
|
||||||
|
|
||||||
@Override
|
@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];
|
String role = input.args.split(" ")[0];
|
||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
if(guild.control.addRole(user.discordID, 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
|
else
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("GuildRoleAddFailure"), role, user.name));
|
res.send(String.format(LocStrings.stub("GuildRoleAddFailure"), role, user.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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); }
|
public CommandGuildRoleAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("GuildRoleAllowedInfo"); }
|
public String getHelpText() { return LocStrings.stub("GuildRoleAllowedInfo"); }
|
||||||
|
|
||||||
@Override
|
@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 [] roles = input.args.split(",");
|
||||||
String role;
|
String role;
|
||||||
@@ -27,12 +27,12 @@ public class CommandGuildRoleAllowed extends Command
|
|||||||
role = roles[i].trim();
|
role = roles[i].trim();
|
||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("GuildRoleAllowedDuplicate"));
|
res.send(LocStrings.stub("GuildRoleAllowedDuplicate"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
guild.roleList.add(role);
|
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);}
|
public CommandGuildRoleList(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||||
|
|
||||||
@Override
|
@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 = "";
|
String roles = "";
|
||||||
if(guild.roleList.isEmpty())
|
if(guild.roleList.isEmpty())
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("GuildRoleListEmpty")));
|
res.send(String.format(LocStrings.stub("GuildRoleListEmpty")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < guild.roleList.size(); i++)
|
for(int i = 0; i < guild.roleList.size(); i++)
|
||||||
@@ -26,6 +26,6 @@ public class CommandGuildRoleList extends Command
|
|||||||
roles += " and ";
|
roles += " and ";
|
||||||
roles += guild.roleList.get(i);
|
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); }
|
public CommandGuildRoleNotAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("GuildRoleNotAllowedInfo"); }
|
public String getHelpText() { return LocStrings.stub("GuildRoleNotAllowedInfo"); }
|
||||||
|
|
||||||
@Override
|
@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 [] roles = input.args.split(",");
|
||||||
String role;
|
String role;
|
||||||
@@ -28,11 +28,11 @@ public class CommandGuildRoleNotAllowed extends Command
|
|||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
guild.roleList.remove(role);
|
guild.roleList.remove(role);
|
||||||
res.Call(LocStrings.Stub("GuildRoleNotAllowedSuccess"));
|
res.send(LocStrings.stub("GuildRoleNotAllowedSuccess"));
|
||||||
}
|
}
|
||||||
else
|
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); }
|
public CommandGuildRoleRemove(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("GuildRoleRemoveInfo"); };
|
public String getHelpText() { return LocStrings.stub("GuildRoleRemoveInfo"); };
|
||||||
|
|
||||||
@Override
|
@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];
|
String role = input.args.split(" ")[0];
|
||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
if(guild.control.removeRole(user.discordID, 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
|
else
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("GuildRoleRemoveFailure"), role, user.name));
|
res.send(String.format(LocStrings.stub("GuildRoleRemoveFailure"), role, user.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("GuildRoleRemoveNotAllowed"), role));
|
res.send(String.format(LocStrings.stub("GuildRoleRemoveNotAllowed"), role));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,23 +15,19 @@ public class CommandHelp extends Command
|
|||||||
public CommandHelp(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandHelp(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("HelpInfo"); }
|
public String getHelpText() { return LocStrings.stub("HelpInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(help == null)
|
||||||
{
|
{
|
||||||
help = LocStrings.Stub("HelpDisplay");
|
help = LocStrings.stub("HelpDisplay");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
help = "`" + input.args + "`: " + help;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Call(help);
|
res.send(help);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,10 @@ public class CommandHelpBuilder extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("HelpBuilderInfo"); }
|
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
||||||
|
|
||||||
@Override
|
@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
|
// Holds command groups
|
||||||
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
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>());
|
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
||||||
|
|
||||||
// Sort commands out
|
// Sort commands out
|
||||||
ArrayList<Command> commands = Stats.instance.GetAllCommands();
|
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
||||||
for(int i = 0; i < commands.size(); ++i)
|
for(int i = 0; i < commands.size(); ++i)
|
||||||
{
|
{
|
||||||
Command current = commands.get(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
|
// Format outstring and send it back for now
|
||||||
String out = "";
|
String out = "";
|
||||||
out += PopulateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||||
out += PopulateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||||
out += PopulateSection(KittyRole.General, commandsByRole, false) + "\n";
|
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||||
|
|
||||||
// Write out file
|
// Write out file
|
||||||
String filename = "buildhelp_out.txt";
|
String filename = "buildhelp_out.txt";
|
||||||
@@ -63,17 +63,17 @@ public class CommandHelpBuilder extends Command {
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e)
|
||||||
{
|
{
|
||||||
GlobalLog.Error(e.toString());
|
GlobalLog.error(e.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
res.CallFile(file, "txt");
|
res.sendFile(file, "txt");
|
||||||
ImageUtils.BlockingFileDelete(file);
|
ImageUtils.blockingFileDelete(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates the section for a specific role, optionally adding spacing after for another section
|
// 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
|
// Formatting variables
|
||||||
final String headerStart = "<h2>";
|
final String headerStart = "<h2>";
|
||||||
@@ -112,7 +112,7 @@ public class CommandHelpBuilder extends Command {
|
|||||||
commandsSoFar.add(command);
|
commandsSoFar.add(command);
|
||||||
|
|
||||||
// Write out all the keys and the help text
|
// 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)
|
for(int j = 0; j < keys.size(); ++j)
|
||||||
{
|
{
|
||||||
if(j != 0)
|
if(j != 0)
|
||||||
@@ -121,7 +121,7 @@ public class CommandHelpBuilder extends Command {
|
|||||||
accumulated += leadStart + keys.get(j) + leadEnd;
|
accumulated += leadStart + keys.get(j) + leadEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulated += leadFollow + commands.get(i).HelpText() + lineDelimiter;;
|
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulated += sectionEnd;
|
accumulated += sectionEnd;
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ public class CommandInfo extends Command
|
|||||||
public CommandInfo(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandInfo(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("InfoInfo"); }
|
public String getHelpText() { return LocStrings.stub("InfoInfo"); }
|
||||||
|
|
||||||
@Override
|
@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); }
|
public CommandInvite(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("InviteInfo"); }
|
public String getHelpText() { return LocStrings.stub("InviteInfo"); }
|
||||||
|
|
||||||
@Override
|
@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");
|
+"&scope=bot&permissions=8");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,17 +12,17 @@ public class CommandJDoodle extends Command
|
|||||||
public CommandJDoodle(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandJDoodle(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("JDoodleInfo"); }
|
public String getHelpText() { return LocStrings.stub("JDoodleInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.args.trim().length() < 1)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("JDoodleError"));
|
res.send(LocStrings.stub("JDoodleError"));
|
||||||
return;
|
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); }
|
public CommandLeaderboard(KittyRole roleLevel, KittyRating contentRating) { super(roleLevel, contentRating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("LeaderboardInfo"); }
|
public String getHelpText() { return LocStrings.stub("LeaderboardInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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.
|
// 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
|
// Get all users associated with a guild and get their bean count
|
||||||
String guildID = guild.uniqueID;
|
String guildID = guild.uniqueID;
|
||||||
@@ -74,13 +74,13 @@ public class CommandLeaderboard extends Command
|
|||||||
return (int)difference;
|
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
|
// Configure output
|
||||||
final int listSize = 10;
|
final int listSize = 10;
|
||||||
KittyEmbed embed = new KittyEmbed();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.color = Config.ColorDefault;
|
embed.color = Config.ColorDefault;
|
||||||
embed.title = LocStrings.Stub("LeaderboardTitle");
|
embed.title = LocStrings.stub("LeaderboardTitle");
|
||||||
embed.descriptionText = "";
|
embed.descriptionText = "";
|
||||||
|
|
||||||
for(int i = 0; i < listSize && i < users.size(); ++i)
|
for(int i = 0; i < listSize && i < users.size(); ++i)
|
||||||
@@ -94,6 +94,6 @@ public class CommandLeaderboard extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write out embed result
|
// 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); }
|
public CommandMap(KittyRole roleLevel, KittyRating contentRating) { super(roleLevel, contentRating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return String.format(LocStrings.Stub("MapInfo"), "" + MaxWidth, "" + MaxHeight); }
|
public String getHelpText() { return String.format(LocStrings.stub("MapInfo"), "" + MaxWidth, "" + MaxHeight); }
|
||||||
|
|
||||||
@Override
|
@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
|
// Variables
|
||||||
int width = 35;
|
int width = 35;
|
||||||
@@ -43,24 +43,24 @@ public class CommandMap extends Command
|
|||||||
{
|
{
|
||||||
OptionParser parser = new OptionParser(input.args);
|
OptionParser parser = new OptionParser(input.args);
|
||||||
|
|
||||||
String seedStr = parser.GetOption("-s", true);
|
String seedStr = parser.getOption("-s", true);
|
||||||
if(seedStr != null)
|
if(seedStr != null)
|
||||||
{
|
{
|
||||||
seed = Long.parseLong(seedStr);
|
seed = Long.parseLong(seedStr);
|
||||||
hasSeed = true;
|
hasSeed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String widthStr = parser.GetOption("-w", true);
|
String widthStr = parser.getOption("-w", true);
|
||||||
if(widthStr != null)
|
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)
|
if(heightStr != null)
|
||||||
height = ValidateSize(Integer.parseInt(heightStr), MaxHeight);
|
height = validateSize(Integer.parseInt(heightStr), MaxHeight);
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e)
|
catch(NumberFormatException e)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("MapInvalid"));
|
res.send(LocStrings.stub("MapInvalid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,22 +76,22 @@ public class CommandMap extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Response header creation
|
// Response header creation
|
||||||
header += LocStrings.Stub("MapVersion") + "\n";
|
header += LocStrings.stub("MapVersion") + "\n";
|
||||||
header += LocStrings.Stub("MapSeed") + ": `" + seed + "`, ";
|
header += LocStrings.stub("MapSeed") + ": `" + seed + "`, ";
|
||||||
header += LocStrings.Stub("MapWidth") + "`"+ width +"`, ";
|
header += LocStrings.stub("MapWidth") + "`"+ width +"`, ";
|
||||||
header += LocStrings.Stub("MapHeight") + ": `"+ height + "`\n";
|
header += LocStrings.stub("MapHeight") + ": `"+ height + "`\n";
|
||||||
|
|
||||||
// Response body creation
|
// Response body creation
|
||||||
body += "```\n";
|
body += "```\n";
|
||||||
body += GenerateMap(width, height, randGenerator);
|
body += generateMap(width, height, randGenerator);
|
||||||
body += "\n```";
|
body += "\n```";
|
||||||
|
|
||||||
// Send back the map
|
// Send back the map
|
||||||
res.Call(header + body);
|
res.send(header + body);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifies and appropriately caps input as necessary
|
// Verifies and appropriately caps input as necessary
|
||||||
int ValidateSize(int input, int max)
|
int validateSize(int input, int max)
|
||||||
{
|
{
|
||||||
if(input < 0)
|
if(input < 0)
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
@@ -104,7 +104,7 @@ public class CommandMap extends Command
|
|||||||
|
|
||||||
|
|
||||||
// Does the map generation
|
// 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];
|
String landscape[][] = new String[width][height];
|
||||||
int r1 = rand(gen);
|
int r1 = rand(gen);
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ public class CommandPerish extends Command
|
|||||||
public CommandPerish(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandPerish(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PerishInfo"); };
|
public String getHelpText() { return LocStrings.stub("PerishInfo"); };
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@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 name = null;
|
||||||
String filename = null;
|
String filename = null;
|
||||||
@@ -45,7 +45,7 @@ public class CommandPerish extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@@ -54,12 +54,12 @@ public class CommandPerish extends Command
|
|||||||
if(input.mentions != null)
|
if(input.mentions != null)
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(filename == null)
|
if(filename == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
ApplyTintEffect(ImageIO.read(preProcessed), name);
|
applyTintEffect(ImageIO.read(preProcessed), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -67,13 +67,13 @@ public class CommandPerish extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
postProcessed = new File(name);
|
postProcessed = new File(name);
|
||||||
res.CallFile(postProcessed, "png");
|
res.sendFile(postProcessed, "png");
|
||||||
|
|
||||||
ImageUtils.BlockingFileDelete(preProcessed);
|
ImageUtils.blockingFileDelete(preProcessed);
|
||||||
ImageUtils.BlockingFileDelete(postProcessed);
|
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
|
// Iterate over each column left to right and touch up each pixel
|
||||||
for(int x = 0; x < image.getWidth(); ++x)
|
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); }
|
public CommandPing(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PingInfo"); }
|
public String getHelpText() { return LocStrings.stub("PingInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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); }
|
public CommandPollManage(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PollManageInfo"); }
|
public String getHelpText() { return LocStrings.stub("PollManageInfo"); }
|
||||||
|
|
||||||
@Override
|
@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())
|
switch(input.args.split(" ")[0].toLowerCase())
|
||||||
{
|
{
|
||||||
case "start":
|
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;
|
break;
|
||||||
|
|
||||||
case "choice":
|
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;
|
break;
|
||||||
|
|
||||||
case "stop":
|
case "stop":
|
||||||
res.Call(guild.endPoll());
|
res.send(guild.endPoll());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ public class CommandPollResults extends Command
|
|||||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PollResultsInfo"); }
|
public String getHelpText() { return LocStrings.stub("PollResultsInfo"); }
|
||||||
|
|
||||||
@Override
|
@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 = "";
|
String results = "";
|
||||||
int totalVotes = 0;
|
int totalVotes = 0;
|
||||||
@@ -28,9 +28,9 @@ public class CommandPollResults extends Command
|
|||||||
|
|
||||||
for(int i = 0; i < votes.size(); i++)
|
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); }
|
public CommandPollShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PollShowInfo"); }
|
public String getHelpText() { return LocStrings.stub("PollShowInfo"); }
|
||||||
|
|
||||||
@Override
|
@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.polling)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("PollShowNoPoll"));
|
res.send(LocStrings.stub("PollShowNoPoll"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String poll = String.format(LocStrings.Stub("PollShowPoll"), guild.poll);
|
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||||
poll += LocStrings.Stub("PollShowChoices");
|
poll += LocStrings.stub("PollShowChoices");
|
||||||
for(int i = 0; i < guild.choices.size(); i++)
|
for(int i = 0; i < guild.choices.size(); i++)
|
||||||
{
|
{
|
||||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
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); }
|
public CommandPollVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("PollVoteInfo"); }
|
public String getHelpText() { return LocStrings.stub("PollVoteInfo"); }
|
||||||
|
|
||||||
@Override
|
@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.polling)
|
||||||
{
|
{
|
||||||
if(guild.hasVoted.contains(user.uniqueID))
|
if(guild.hasVoted.contains(user.uniqueID))
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("PollVoteAlreadyVoted"));
|
res.send(LocStrings.stub("PollVoteAlreadyVoted"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@@ -25,23 +25,23 @@ public class CommandPollVote extends Command
|
|||||||
int voteNum = Integer.parseInt(input.args)-1;
|
int voteNum = Integer.parseInt(input.args)-1;
|
||||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("PollVoteNotValidVote"), voteNum));
|
res.send(String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KittyPoll polled = guild.choices.get(voteNum);
|
KittyPoll polled = guild.choices.get(voteNum);
|
||||||
polled.votes++;
|
polled.votes++;
|
||||||
guild.hasVoted.add(user.uniqueID);
|
guild.hasVoted.add(user.uniqueID);
|
||||||
res.Call(LocStrings.Stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
res.send(LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("PollVoteNotValidNumber"));
|
res.send(LocStrings.stub("PollVoteNotValidNumber"));
|
||||||
return;
|
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); }
|
public CommandRPEnd (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RPEndInfo"); }
|
public String getHelpText() { return LocStrings.stub("RPEndInfo"); }
|
||||||
|
|
||||||
@Override
|
@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;
|
File sending = null;
|
||||||
|
|
||||||
@@ -32,12 +32,12 @@ public class CommandRPEnd extends Command
|
|||||||
|
|
||||||
if(sending != null)
|
if(sending != null)
|
||||||
{
|
{
|
||||||
res.CallFile(sending, "txt");
|
res.sendFile(sending, "txt");
|
||||||
res.Call(LocStrings.Stub("RPEndFileOut"));
|
res.send(LocStrings.stub("RPEndFileOut"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("RPEndError"));
|
res.send(LocStrings.stub("RPEndError"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,31 +23,31 @@ public class CommandRPG extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RPGInfo"); };
|
public String getHelpText() { return LocStrings.stub("RPGInfo"); };
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.args == null || input.args.length() == 0)
|
||||||
{
|
{
|
||||||
String output = HelpText();
|
String output = getHelpText();
|
||||||
res.Call(output);
|
res.send(output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = null;
|
String result = null;
|
||||||
synchronized(framework)
|
synchronized(framework)
|
||||||
{
|
{
|
||||||
result = framework.Run(user.uniqueID, input.args.trim());
|
result = framework.run(user.uniqueID, input.args.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result == null)
|
if(result == null)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("RPGInvalid"));
|
res.send(LocStrings.stub("RPGInvalid"));
|
||||||
return;
|
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); }
|
public CommandRPStart (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RPStartInfo"); }
|
public String getHelpText() { return LocStrings.stub("RPStartInfo"); }
|
||||||
|
|
||||||
@Override
|
@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>();
|
ArrayList <KittyUser> users = new ArrayList<KittyUser>();
|
||||||
users.add(user);
|
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); }
|
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RaffleEndInfo"); }
|
public String getHelpText() { return LocStrings.stub("RaffleEndInfo"); }
|
||||||
|
|
||||||
@Override
|
@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())
|
if(guild.endRaffle())
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("RaffleEndSuccess"));
|
res.send(LocStrings.stub("RaffleEndSuccess"));
|
||||||
}
|
}
|
||||||
else
|
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); }
|
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RaffleJoinInfo"); }
|
public String getHelpText() { return LocStrings.stub("RaffleJoinInfo"); }
|
||||||
|
|
||||||
@Override
|
@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))
|
if(guild.joinRaffle(user))
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("RaffleJoinSuccess"));
|
res.send(LocStrings.stub("RaffleJoinSuccess"));
|
||||||
}
|
}
|
||||||
else
|
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); }
|
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RaffleSpinInfo"); }
|
public String getHelpText() { return LocStrings.stub("RaffleSpinInfo"); }
|
||||||
|
|
||||||
@Override
|
@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
|
try
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
res.send(String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
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); }
|
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RaffleStartInfo"); }
|
public String getHelpText() { return LocStrings.stub("RaffleStartInfo"); }
|
||||||
|
|
||||||
public int beanCost;
|
public int beanCost;
|
||||||
|
|
||||||
@Override
|
@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
|
try
|
||||||
{
|
{
|
||||||
@@ -30,13 +30,14 @@ public class CommandRaffleStart extends Command
|
|||||||
{
|
{
|
||||||
beanCost = 100;
|
beanCost = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(guild.startRaffle(beanCost))
|
if(guild.startRaffle(beanCost))
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("RaffleStartSuccess"), beanCost));
|
res.send(String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||||
}
|
}
|
||||||
else
|
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); }
|
public CommandRating(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RatingInfo"); }
|
public String getHelpText() { return LocStrings.stub("RatingInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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;
|
String newRating = null;
|
||||||
switch(input.args.toLowerCase().trim())
|
switch(input.args.toLowerCase().trim())
|
||||||
@@ -55,11 +55,11 @@ public class CommandRating extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(newRating != null)
|
if(newRating != null)
|
||||||
res.Call(LocStrings.Stub("RatingChanged") + " " + newRating);
|
res.send(LocStrings.stub("RatingChanged") + " " + newRating);
|
||||||
else
|
else
|
||||||
res.Call(LocStrings.Stub("RatingInvalid") + " `" + input.args + "`");
|
res.send(LocStrings.stub("RatingInvalid") + " `" + input.args + "`");
|
||||||
|
|
||||||
if(newRating.equals("Filtered"))
|
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); }
|
public CommandRole (KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RoleInfo"); }
|
public String getHelpText() { return LocStrings.stub("RoleInfo"); }
|
||||||
|
|
||||||
@Override
|
@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())
|
if(input.args.isEmpty())
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("RoleStandardResponse") + " " + user.GetRole().name() + "!");
|
res.send(LocStrings.stub("RoleStandardResponse") + " " + user.getRole().name() + "!");
|
||||||
return;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,16 +46,16 @@ public class CommandRole extends Command
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
res.Call(LocStrings.Stub("RoleNeededRole"));
|
res.send(LocStrings.stub("RoleNeededRole"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String users = "";
|
String users = "";
|
||||||
for(int i = 0; i < input.mentions.length; i++)
|
for(int i = 0; i < input.mentions.length; i++)
|
||||||
{
|
{
|
||||||
input.mentions[i].ChangeRole(newRole);
|
input.mentions[i].changeRole(newRole);
|
||||||
users += input.mentions[i].name + " ";
|
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); }
|
public CommandRoll(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("RollInfo"); }
|
public String getHelpText() { return LocStrings.stub("RollInfo"); }
|
||||||
|
|
||||||
@Override
|
@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
|
try
|
||||||
{
|
{
|
||||||
res.Call(rollDice(input.args));
|
res.send(rollDice(input.args));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
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); }
|
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("ShutdownInfo"); }
|
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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.
|
// Flag the shutdown immediately.
|
||||||
Stats.instance.IndicateShutdown();
|
Stats.instance.indicateShutdown();
|
||||||
|
|
||||||
boolean isSafe = false;
|
boolean isSafe = false;
|
||||||
switch(input.args.toLowerCase().trim())
|
switch(input.args.toLowerCase().trim())
|
||||||
@@ -41,21 +41,19 @@ public class CommandShutdown extends Command
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isSafe)
|
if(isSafe)
|
||||||
{
|
{
|
||||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
// 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();
|
DatabaseManager.instance.upkeep();
|
||||||
GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe"));
|
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||||
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.CallImmediate(LocStrings.Stub("ShutdownUnsafe"));// "``");
|
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
||||||
GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe"));
|
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ public class CommandStark extends Command
|
|||||||
public CommandStark(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandStark(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("StarkInfo"); };
|
public String getHelpText() { return LocStrings.stub("StarkInfo"); };
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@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 name = null;
|
||||||
String filename = null;
|
String filename = null;
|
||||||
@@ -39,7 +39,7 @@ public class CommandStark extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
filename = ImageUtils.DownloadFromURL(input.args.split(" ")[0], ".png");
|
filename = ImageUtils.downloadFromURL(input.args.split(" ")[0], ".png");
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@@ -48,12 +48,12 @@ public class CommandStark extends Command
|
|||||||
if(input.mentions != null)
|
if(input.mentions != null)
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
filename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
filename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(filename == null)
|
if(filename == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
ApplySnap(ImageIO.read(preProcessed), name);
|
applySnap(ImageIO.read(preProcessed), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -61,13 +61,13 @@ public class CommandStark extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
postProcessed = new File(name);
|
postProcessed = new File(name);
|
||||||
res.CallFile(postProcessed, "png");
|
res.sendFile(postProcessed, "png");
|
||||||
|
|
||||||
ImageUtils.BlockingFileDelete(preProcessed);
|
ImageUtils.blockingFileDelete(preProcessed);
|
||||||
ImageUtils.BlockingFileDelete(postProcessed);
|
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);
|
BufferedImage snap = ImageUtils.copyImage(image);
|
||||||
// Iterate over each column left to right and touch up each pixel
|
// Iterate over each column left to right and touch up each pixel
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package commands;
|
|||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import core.CommandManager.ThreadData;
|
import core.CommandManager.ThreadData;
|
||||||
|
import core.Config;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyEmbed;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
@@ -17,33 +19,38 @@ public class CommandStats extends Command
|
|||||||
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("StatsInfo"); }
|
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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;
|
Stats stats = Stats.instance;
|
||||||
|
String out = "";
|
||||||
|
long seen = stats.getMessagesSeen();
|
||||||
|
long processed = stats.getCommandsProcessed();
|
||||||
|
|
||||||
long seen = stats.GetMessagesSeen();
|
// General
|
||||||
long processed = stats.GetCommandsProcessed();
|
out += "General";
|
||||||
|
out += "```\n";
|
||||||
out += "----- [General] -----\n";
|
|
||||||
out += " Messages observed: " + seen + "\n";
|
out += " Messages observed: " + seen + "\n";
|
||||||
out += "Commands processed: " + processed + "\n";
|
out += "Commands processed: " + processed + "\n";
|
||||||
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
||||||
out += " KittyBot uptime: " + stats.GetFormattedUptime() + "\n";
|
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
||||||
out += "\n";
|
out += "```\n";
|
||||||
out += "----- [Health] -----\n";
|
|
||||||
out += " SMT cores: " + stats.GetCPUAvailable() + "\n";
|
|
||||||
|
|
||||||
// If CPU load works on this OS, list it.
|
// Health
|
||||||
double CPULoad = stats.GetSystemCPULoad();
|
out += "Health";
|
||||||
if(CPULoad > -0.9) // -1.0 is the error state
|
out += "```\n";
|
||||||
out += "System CPU Load: " + (CPULoad * 100) + "%\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 terminated = data.states.get(Thread.State.TERMINATED);
|
||||||
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
||||||
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
||||||
@@ -58,14 +65,25 @@ public class CommandStats extends Command
|
|||||||
+ " term-" + (terminated == null ? 0 : terminated)
|
+ " term-" + (terminated == null ? 0 : terminated)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
|
||||||
Integer guildCount = stats.GetGuildCount();
|
out += "```\n";
|
||||||
Integer userCount = stats.GetUserCount();
|
|
||||||
|
|
||||||
out += "\n----- [Cache] -----\n"
|
|
||||||
|
// Cache
|
||||||
|
Integer guildCount = stats.getGuildCount();
|
||||||
|
Integer userCount = stats.getUserCount();
|
||||||
|
|
||||||
|
out += "Cache";
|
||||||
|
out += "```\n"
|
||||||
+ "Cached Guilds: " + guildCount + "\n"
|
+ "Cached Guilds: " + guildCount + "\n"
|
||||||
+ " Cached Users: " + userCount;
|
+ " Cached Users: " + userCount;
|
||||||
|
|
||||||
out += "\n```";
|
out += "\n```";
|
||||||
|
|
||||||
res.Call(out);
|
KittyEmbed embed = new KittyEmbed();
|
||||||
|
embed.title = "Bot Stats";
|
||||||
|
embed.descriptionText = out;
|
||||||
|
embed.color = Config.ColorDefault;
|
||||||
|
|
||||||
|
res.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ public class CommandTeey extends Command
|
|||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("TeeyInfo"); }
|
public String getHelpText() { return LocStrings.stub("TeeyInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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 name = null;
|
||||||
File teeyFile = null;
|
File teeyFile = null;
|
||||||
@@ -48,13 +48,13 @@ public class CommandTeey extends Command
|
|||||||
else
|
else
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
String yeeteeFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(yeeteeFilename == null)
|
if(yeeteeFilename == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
teeyeeFile = new File(yeeteeFilename);
|
teeyeeFile = new File(yeeteeFilename);
|
||||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/teey/frames/", "teey ", 24, 18);
|
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/teey/frames/", "teey ", 24, 18);
|
||||||
builder.Overlay(ImageIO.read(teeyeeFile), name);
|
builder.overlay(ImageIO.read(teeyeeFile), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -62,10 +62,10 @@ public class CommandTeey extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
teeyFile = new File (name);
|
teeyFile = new File (name);
|
||||||
res.CallFile(teeyFile, "gif");
|
res.sendFile(teeyFile, "gif");
|
||||||
|
|
||||||
// Thread cleanup...
|
// Thread cleanup...
|
||||||
ImageUtils.BlockingFileDelete(teeyFile);
|
ImageUtils.blockingFileDelete(teeyFile);
|
||||||
ImageUtils.BlockingFileDelete(teeyeeFile);
|
ImageUtils.blockingFileDelete(teeyeeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ public class CommandTradeBeans extends Command
|
|||||||
public CommandTradeBeans(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandTradeBeans(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("TradeBeansInfo"); }
|
public String getHelpText() { return LocStrings.stub("TradeBeansInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.mentions == null)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("TradeBeansNoTargetError"));
|
res.send(LocStrings.stub("TradeBeansNoTargetError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,25 +32,25 @@ public class CommandTradeBeans extends Command
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("TradeBeansIntParseError"));
|
res.send(LocStrings.stub("TradeBeansIntParseError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user.GetBeans() < beans)
|
if(user.getBeans() < beans)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("TradeBeansNotEnoughError"));
|
res.send(LocStrings.stub("TradeBeansNotEnoughError"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(beans < 0)
|
if(beans < 0)
|
||||||
{
|
{
|
||||||
res.Call(String.format(LocStrings.Stub("TradeBeansStealingBeans"), user.name));
|
res.send(String.format(LocStrings.stub("TradeBeansStealingBeans"), user.name));
|
||||||
user.ChangeBeans(-10);
|
user.changeBeans(-10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.mentions[0].ChangeBeans(beans);
|
input.mentions[0].changeBeans(beans);
|
||||||
user.ChangeBeans(-beans);
|
user.changeBeans(-beans);
|
||||||
res.Call(String.format(LocStrings.Stub("TradeBeansSuccess"), user.name, input.mentions[0].name, 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); }
|
public CommandTweet(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("TweetInfo"); }
|
public String getHelpText() { return LocStrings.stub("TweetInfo"); }
|
||||||
|
|
||||||
@Override
|
@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
|
//TODO: Figure out how to pass pictures correctly
|
||||||
try {
|
try {
|
||||||
res.Call(tweet.tweet(input.args));
|
res.send(tweet.tweet(input.args));
|
||||||
} catch (Exception e) {
|
} 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);}
|
public CommandWolfram(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("WolframInfo"); }
|
public String getHelpText() { return LocStrings.stub("WolframInfo"); }
|
||||||
|
|
||||||
@Override
|
@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)
|
if(input.args == null || input.args.trim().length() == 0)
|
||||||
res.Call(LocStrings.Stub("WolframNoArgs"));
|
res.send(LocStrings.stub("WolframNoArgs"));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File pic = new File(searcher.getWolfram(input.args));
|
File pic = new File(searcher.getWolfram(input.args));
|
||||||
res.CallFile(pic, "png");
|
res.sendFile(pic, "png");
|
||||||
ImageUtils.BlockingFileDelete(pic);
|
ImageUtils.blockingFileDelete(pic);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
res.Call(LocStrings.Stub("WolframError"));
|
res.send(LocStrings.stub("WolframError"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,11 +23,11 @@ public class CommandYeet extends Command
|
|||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String HelpText() { return LocStrings.Stub("YeetInfo"); }
|
public String getHelpText() { return LocStrings.stub("YeetInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@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 name = null;
|
||||||
File yeetFile = null;
|
File yeetFile = null;
|
||||||
@@ -48,13 +48,13 @@ public class CommandYeet extends Command
|
|||||||
else
|
else
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
String yeeteeFilename = ImageUtils.DownloadFromURL(person.avatarID, ".png");
|
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(yeeteeFilename == null)
|
if(yeeteeFilename == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
yeeteeFile = new File(yeeteeFilename);
|
yeeteeFile = new File(yeeteeFilename);
|
||||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/yeet/frames/", "yeet ", 24, 18);
|
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/yeet/frames/", "yeet ", 24, 18);
|
||||||
builder.Overlay(ImageIO.read(yeeteeFile), name);
|
builder.overlay(ImageIO.read(yeeteeFile), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -62,10 +62,10 @@ public class CommandYeet extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
yeetFile = new File (name);
|
yeetFile = new File (name);
|
||||||
res.CallFile(yeetFile, "gif");
|
res.sendFile(yeetFile, "gif");
|
||||||
|
|
||||||
// Thread cleanup...
|
// Thread cleanup...
|
||||||
ImageUtils.BlockingFileDelete(yeetFile);
|
ImageUtils.blockingFileDelete(yeetFile);
|
||||||
ImageUtils.BlockingFileDelete(yeeteeFile);
|
ImageUtils.blockingFileDelete(yeeteeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import core.benchmark.BenchmarkManager;
|
|||||||
|
|
||||||
public class BenchmarkCommandCompare extends BenchmarkCommand
|
public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||||
{
|
{
|
||||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||||
{
|
{
|
||||||
final String lineDelimiter = "\n";
|
final String lineDelimiter = "\n";
|
||||||
String output = "";
|
String output = "";
|
||||||
@@ -24,7 +24,7 @@ public class BenchmarkCommandCompare extends BenchmarkCommand
|
|||||||
if(i != 0)
|
if(i != 0)
|
||||||
output += lineDelimiter;
|
output += lineDelimiter;
|
||||||
|
|
||||||
List<BenchmarkEntry> entries = manager.FindModel(inputSplit[i]);
|
List<BenchmarkEntry> entries = manager.findModel(inputSplit[i]);
|
||||||
|
|
||||||
if(entries.size() < 1)
|
if(entries.size() < 1)
|
||||||
output += "Couldn't find any models containing `" + inputSplit[i] + "`!";
|
output += "Couldn't find any models containing `" + inputSplit[i] + "`!";
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ public class BenchmarkCommandFind extends BenchmarkCommand
|
|||||||
private final String lineDelimiter = "\n";
|
private final String lineDelimiter = "\n";
|
||||||
private final int listMax = 30;
|
private final int listMax = 30;
|
||||||
|
|
||||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||||
{
|
{
|
||||||
String output = "";
|
String output = "";
|
||||||
String searchString = input.value.trim();
|
String searchString = input.value.trim();
|
||||||
|
|
||||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
List<BenchmarkEntry> entries = manager.findModel(searchString);
|
||||||
|
|
||||||
if(entries.size() > 0)
|
if(entries.size() > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,16 +74,16 @@ public class BenchmarkCommandInfo extends BenchmarkCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
public BenchmarkFormattable onRun(BenchmarkManager manager, BenchmarkInput input)
|
||||||
{
|
{
|
||||||
String searchString = input.value.trim();
|
String searchString = input.value.trim();
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
List<BenchmarkEntry> entries = manager.findModel(searchString);
|
||||||
|
|
||||||
if(entries.size() < 1)
|
if(entries.size() < 1)
|
||||||
return new BenchmarkFormattable("Couldn't find any models containing `" + searchString + "`!");
|
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);
|
BenchmarkEntry entry = sortedEntries.get(0);
|
||||||
KittyEmbed embed = FormatInfoEmbed(entry);
|
KittyEmbed embed = FormatInfoEmbed(entry);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import core.rpg.RPGState;
|
|||||||
public class RPGCommandBattleFight extends RPGCommand
|
public class RPGCommandBattleFight extends RPGCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String OnRun(RPGState state, RPGInput input)
|
public String onRun(RPGState state, RPGInput input)
|
||||||
{
|
{
|
||||||
if(state.battleContext == null)
|
if(state.battleContext == null)
|
||||||
return "```There's nothing to fight!```";
|
return "```There's nothing to fight!```";
|
||||||
@@ -19,7 +19,7 @@ public class RPGCommandBattleFight extends RPGCommand
|
|||||||
reward = "+150xp";
|
reward = "+150xp";
|
||||||
|
|
||||||
state.battleContext = null;
|
state.battleContext = null;
|
||||||
state.player.ApplyEXP(150);
|
state.player.applyEXP(150);
|
||||||
|
|
||||||
if(out != null && reward != null)
|
if(out != null && reward != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ import core.rpg.RPGState;
|
|||||||
public class RPGCommandBattleRun extends RPGCommand
|
public class RPGCommandBattleRun extends RPGCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String OnRun(RPGState state, RPGInput input)
|
public String onRun(RPGState state, RPGInput input)
|
||||||
{
|
{
|
||||||
if(state.battleContext == null)
|
if(state.battleContext == null)
|
||||||
return "```There's nothing to run from!```";
|
return "```There's nothing to run from!```";
|
||||||
|
|
||||||
long lostGold = (long)(state.player.GetGold() * .1);
|
long lostGold = (long)(state.player.getGold() * .1);
|
||||||
String out = null;
|
String out = null;
|
||||||
|
|
||||||
state.player.SpendGold(lostGold);
|
state.player.spendGold(lostGold);
|
||||||
state.battleContext = null;
|
state.battleContext = null;
|
||||||
|
|
||||||
out = "You duck behind a tree and manage to escape from encounter just barely!";
|
out = "You duck behind a tree and manage to escape from encounter just barely!";
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class RPGCommandExplore extends RPGCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String OnRun(RPGState state, RPGInput input)
|
public String onRun(RPGState state, RPGInput input)
|
||||||
{
|
{
|
||||||
Chance chance = new Chance(100);
|
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!";
|
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";
|
reward = "+" + gp + "gp";
|
||||||
state.player.GiveGold(gp);
|
state.player.giveGold(gp);
|
||||||
}
|
}
|
||||||
else if(chance.Next(20))
|
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.";
|
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";
|
reward = "+" + xp + "xp, +" + healing + "hp";
|
||||||
state.player.ApplyHealing(healing);
|
state.player.applyHealing(healing);
|
||||||
state.player.ApplyEXP(xp);
|
state.player.applyEXP(xp);
|
||||||
}
|
}
|
||||||
else if(chance.Next(20))
|
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.";
|
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";
|
reward = "+" + xp + "xp, -" + damage + "hp";
|
||||||
state.player.ApplyEXP(xp);
|
state.player.applyEXP(xp);
|
||||||
state.player.ApplyDamage(damage);
|
state.player.applyDamage(damage);
|
||||||
}
|
}
|
||||||
else
|
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.";
|
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";
|
reward = "+" + hp + "hp";
|
||||||
state.player.ApplyHealing(hp);
|
state.player.applyHealing(hp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(out != null && reward != null)
|
if(out != null && reward != null)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class RPGCommandInfo extends RPGCommand
|
|||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String OnRun(RPGState state, RPGInput input)
|
public String onRun(RPGState state, RPGInput input)
|
||||||
{
|
{
|
||||||
String out = null;
|
String out = null;
|
||||||
switch(input.value.trim().toLowerCase())
|
switch(input.value.trim().toLowerCase())
|
||||||
@@ -27,7 +27,7 @@ public class RPGCommandInfo extends RPGCommand
|
|||||||
case "hand":
|
case "hand":
|
||||||
case "att":
|
case "att":
|
||||||
case "attack":
|
case "attack":
|
||||||
out = WeaponStats(state.player.GetWeapon());
|
out = WeaponStats(state.player.getWeapon());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "armour":
|
case "armour":
|
||||||
@@ -44,7 +44,7 @@ public class RPGCommandInfo extends RPGCommand
|
|||||||
case "dress":
|
case "dress":
|
||||||
case "wear":
|
case "wear":
|
||||||
case "outfit":
|
case "outfit":
|
||||||
out = ArmorStats(state.player.GetArmor());
|
out = ArmorStats(state.player.getArmor());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ public class RPGCommandInfo extends RPGCommand
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
out += "[" + weapon.GetName() + "]";
|
out += "[" + weapon.getName() + "]";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += " att: " + weapon.GetAttack();
|
out += " att: " + weapon.getAttack();
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += "value: " + weapon.GetValue() + "gp";
|
out += "value: " + weapon.getValue() + "gp";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += weapon.GetDescription();
|
out += weapon.getDescription();
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -78,14 +78,14 @@ public class RPGCommandInfo extends RPGCommand
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
out += "[" + armor.GetName() + "]";
|
out += "[" + armor.getName() + "]";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += " def: " + armor.GetDefense();
|
out += " def: " + armor.getDefense();
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += "value: " + armor.GetValue() + "gp";
|
out += "value: " + armor.getValue() + "gp";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += "\n";
|
out += "\n";
|
||||||
out += armor.GetDescription();
|
out += armor.getDescription();
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,18 +11,18 @@ import core.rpg.RPGWeapon;
|
|||||||
public class RPGCommandStats extends RPGCommand
|
public class RPGCommandStats extends RPGCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String OnRun(RPGState state, RPGInput input)
|
public String onRun(RPGState state, RPGInput input)
|
||||||
{
|
{
|
||||||
RPGPlayer player = state.player;
|
RPGPlayer player = state.player;
|
||||||
long exp = player.GetEXP();
|
long exp = player.getEXP();
|
||||||
long level = RPGExpTable.LevelFromEXP(player.GetEXP());
|
long level = RPGExpTable.levelFromEXP(player.getEXP());
|
||||||
long ceil = RPGExpTable.EXPCeil(level);
|
long ceil = RPGExpTable.expCeil(level);
|
||||||
|
|
||||||
String indent = "";
|
String indent = "";
|
||||||
String linebreak = "\n";
|
String linebreak = "\n";
|
||||||
|
|
||||||
String out = "";
|
String out = "";
|
||||||
out += indent + "[" + player.GetName() + ", lv. " + level + "]";
|
out += indent + "[" + player.getName() + ", lv. " + level + "]";
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
out += indent + "_______________";
|
out += indent + "_______________";
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
@@ -31,26 +31,26 @@ public class RPGCommandStats extends RPGCommand
|
|||||||
out += indent + " (until next: " + (ceil - exp) + ")";
|
out += indent + " (until next: " + (ceil - exp) + ")";
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
|
|
||||||
out += indent + " Gold: " + player.GetGold();
|
out += indent + " Gold: " + player.getGold();
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
|
|
||||||
out += indent + "Health: " + player.GetHealthCurrent() + "/" + player.GetHealthMax();
|
out += indent + "Health: " + player.getHealthCurrent() + "/" + player.getHealthMax();
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
|
|
||||||
RPGWeapon weapon = player.GetWeapon();
|
RPGWeapon weapon = player.getWeapon();
|
||||||
out += indent + "_____";
|
out += indent + "_____";
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
out += indent + "Weapon: " + weapon.GetName();
|
out += indent + "Weapon: " + weapon.getName();
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
out += indent + " att: " + weapon.GetAttack();
|
out += indent + " att: " + weapon.getAttack();
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
|
|
||||||
RPGArmor armor = player.GetArmor();
|
RPGArmor armor = player.getArmor();
|
||||||
out += indent + "_____";
|
out += indent + "_____";
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
out += indent + "Armor: " + armor.GetName();
|
out += indent + "Armor: " + armor.getName();
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
out += indent + " def: " + armor.GetDefense() ;
|
out += indent + " def: " + armor.getDefense() ;
|
||||||
out += indent + linebreak;
|
out += indent + linebreak;
|
||||||
|
|
||||||
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
|
// 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);
|
File f = new File(filename);
|
||||||
if(f.isFile() && f.canRead())
|
if(f.isFile() && f.canRead())
|
||||||
{
|
{
|
||||||
String content = FileUtils.ReadContent(f).trim();
|
String content = FileUtils.readContent(f).trim();
|
||||||
String[] lines = content.split("" + pairSeparator);
|
String[] lines = content.split("" + pairSeparator);
|
||||||
|
|
||||||
for(int i = 0; i < lines.length; ++i)
|
for(int i = 0; i < lines.length; ++i)
|
||||||
@@ -60,7 +60,7 @@ public class BaseKeyValueFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Writes out a set of keyvalue pairs
|
// Writes out a set of keyvalue pairs
|
||||||
protected void Write(List<Pair<String, String>> toWrite)
|
protected void write(List<Pair<String, String>> toWrite)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ public class BaseKeyValueFile
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
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;
|
protected TaggedPairStore stringStore;
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
private void Log(String str) { GlobalLog.Log(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 warn(String str) { GlobalLog.warn(LogFilter.Strings, str); }
|
||||||
private void Error(String str) { GlobalLog.Error(LogFilter.Strings, str); }
|
private void error(String str) { GlobalLog.error(LogFilter.Strings, str); }
|
||||||
|
|
||||||
// File monitoring
|
// File monitoring
|
||||||
protected FileMonitor fileMonitor;
|
protected FileMonitor fileMonitor;
|
||||||
@@ -45,19 +45,19 @@ public abstract class BaseLocFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks the file specified for updates
|
// Checks the file specified for updates
|
||||||
public void Update()
|
public void update()
|
||||||
{
|
{
|
||||||
synchronized(stringStore)
|
synchronized(stringStore)
|
||||||
{
|
{
|
||||||
fileMonitor.Update(this::OnFileChange);
|
fileMonitor.update(this::onFileChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the file is changed
|
// When the file is changed
|
||||||
protected void OnFileChange(MonitoredFile file)
|
protected void onFileChange(MonitoredFile file)
|
||||||
{
|
{
|
||||||
Log("Loc file was modified at path " + file.path);
|
log("Loc file was modified at path " + file.path);
|
||||||
UpdateLocFromDisk();
|
updateLocFromDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Structure used for holding a pair of strings and any other info we need
|
// 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
|
// 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();
|
String filename = path.getFileName().toString();
|
||||||
if(filename.contains(".java"))
|
if(filename.contains(".java"))
|
||||||
{
|
{
|
||||||
String contents = FileUtils.ReadContent(path);
|
String contents = FileUtils.readContent(path);
|
||||||
String[] split = contents.split(functionName);
|
String[] split = contents.split(functionName);
|
||||||
|
|
||||||
// Identify all localizer function calls
|
// Identify all localizer function calls
|
||||||
@@ -101,11 +101,11 @@ public abstract class BaseLocFile
|
|||||||
|
|
||||||
strings.add(new LocInfo(filename.substring(0, filename.lastIndexOf('.')), toLocalize));
|
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)
|
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
|
// 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,
|
// 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.
|
// returns a the key instead which is the default phrase.
|
||||||
public String GetKey(String input)
|
public String getKey(String input)
|
||||||
{
|
{
|
||||||
if(stringStore == null)
|
if(stringStore == null)
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
String value = stringStore.GetKey(input);
|
String value = stringStore.getKey(input);
|
||||||
if(value == null || value.trim().length() < 1)
|
if(value == null || value.trim().length() < 1)
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ public abstract class BaseLocFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reads a file to string, adapted from https://stackoverflow.com/a/326440/5383198
|
// 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
|
try
|
||||||
{
|
{
|
||||||
@@ -138,7 +138,7 @@ public abstract class BaseLocFile
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
Warn("No file found to read from!");
|
warn("No file found to read from!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
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.
|
// Update localization from the disk on file. Creates the file if it doesn't exist.
|
||||||
// This file is internally formatted as an ini file.
|
// 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
|
try
|
||||||
{
|
{
|
||||||
String fileContents = ReadFileAsString(filename, Charset.defaultCharset());
|
String fileContents = readFileAsString(filename, Charset.defaultCharset());
|
||||||
|
|
||||||
if(fileContents == null)
|
if(fileContents == null)
|
||||||
{
|
{
|
||||||
@@ -164,15 +164,15 @@ public abstract class BaseLocFile
|
|||||||
}
|
}
|
||||||
catch(IOException e)
|
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.
|
// Rewrites out at the specified filename with existing stubs.
|
||||||
// This preserves existing localized phrases.
|
// 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
|
try
|
||||||
{
|
{
|
||||||
@@ -182,30 +182,30 @@ public abstract class BaseLocFile
|
|||||||
}
|
}
|
||||||
catch(IOException e)
|
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
|
try
|
||||||
{
|
{
|
||||||
StripForContents(path, toFill);
|
stripForContents(path, toFill);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
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.
|
// Scrape the project and generate all the possible localizeable phrases.
|
||||||
// This stubs out phrases to be localized.
|
// This stubs out phrases to be localized.
|
||||||
public void ScrapeAll()
|
public void scrapeAll()
|
||||||
{
|
{
|
||||||
ArrayList<LocInfo> localizeList = new ArrayList<LocInfo>();
|
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)
|
for(LocInfo toStub : localizeList)
|
||||||
stringStore.AddKeyValue(toStub.file, toStub.phrase, toStub.phrase);
|
stringStore.addKeyValue(toStub.file, toStub.phrase, toStub.phrase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package core;
|
package core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import dataStructures.KittyCharacter;
|
import dataStructures.KittyCharacter;
|
||||||
|
import dataStructures.KittyTrackedLong;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import me.xdrop.fuzzywuzzy.FuzzySearch;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
import utils.LogFilter;
|
import utils.LogFilter;
|
||||||
|
|
||||||
public class CharacterManager
|
public class CharacterManager
|
||||||
{
|
{
|
||||||
public static CharacterManager instance;
|
public static CharacterManager instance;
|
||||||
|
KittyTrackedLong uniqueID = new KittyTrackedLong("CharacterIDCounter", "");
|
||||||
|
|
||||||
private Vector <KittyCharacter> characters = new Vector<KittyCharacter>();
|
private Vector <KittyCharacter> characters = new Vector<KittyCharacter>();
|
||||||
public CharacterManager()
|
public CharacterManager()
|
||||||
@@ -20,11 +24,38 @@ public class CharacterManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second CharacterManager singleton!");
|
GlobalLog.error(LogFilter.Core, "Attempted to create a second CharacterManager singleton!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<KittyCharacter> searchCharacter(String query)
|
||||||
|
{
|
||||||
|
ArrayList<KittyCharacter> chars = new ArrayList<KittyCharacter>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long UID = Long.parseLong(query);
|
||||||
|
for(KittyCharacter character:characters)
|
||||||
|
{
|
||||||
|
if(character.getUID() == UID)
|
||||||
|
{
|
||||||
|
chars.add(character);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(Exception e)
|
||||||
|
{
|
||||||
|
for(KittyCharacter character:characters)
|
||||||
|
{
|
||||||
|
if(FuzzySearch.ratio(query.toLowerCase(), character.getName().toLowerCase()) > 60)
|
||||||
|
{
|
||||||
|
chars.add(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chars;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addCharacter(KittyUser user, String name, String bio, String refImage)
|
public boolean addCharacter(KittyUser user, String name, String bio, String refImage)
|
||||||
{
|
{
|
||||||
for(KittyCharacter character:characters)
|
for(KittyCharacter character:characters)
|
||||||
@@ -35,45 +66,29 @@ public class CharacterManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
characters.add(new KittyCharacter(user, name, bio, refImage));
|
characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.get()));
|
||||||
|
uniqueID.add(1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeCharacter(KittyUser user, String name)
|
public void removeCharacter(KittyCharacter character, String name)
|
||||||
{
|
|
||||||
for(KittyCharacter character:characters)
|
|
||||||
{
|
|
||||||
if(character.getName().equals(name) && character.getOwner().discordID.equals(user.discordID))
|
|
||||||
{
|
{
|
||||||
characters.remove(character);
|
characters.remove(character);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean editRefImage(KittyUser user, String name, String refImage)
|
public void editRefImage(KittyCharacter character, String refImage)
|
||||||
{
|
{
|
||||||
for(KittyCharacter character:characters)
|
character.editRefImage(refImage);
|
||||||
{
|
|
||||||
if(character.getName().equals(name) && character.getOwner().discordID.equals(user.discordID))
|
|
||||||
{
|
|
||||||
return character.editRefImage(user, refImage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean editBio(KittyUser user, String name, String bio)
|
public void editBio(KittyCharacter character, String bio)
|
||||||
{
|
{
|
||||||
for(KittyCharacter character:characters)
|
character.editBio(bio);
|
||||||
{
|
|
||||||
if(character.getName().equals(name) && character.getOwner().discordID.equals(user.discordID))
|
|
||||||
{
|
|
||||||
return character.editBio(user, bio);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
public void editName(KittyCharacter character, String name)
|
||||||
|
{
|
||||||
|
character.editName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -26,65 +26,65 @@ public abstract class Command
|
|||||||
this.contentRating = contentRating;
|
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
|
// Determine if we're exclusive enough for this command and
|
||||||
// if the command is permitted by the guild we're in
|
// 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())
|
if(guild.contentRating.getValue() < contentRating.getValue())
|
||||||
{
|
{
|
||||||
Reject(user, "content rating");
|
reject(user, "content rating");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: ADD CHANNEL CHECK HERE
|
//TODO: ADD CHANNEL CHECK HERE
|
||||||
|
|
||||||
if(user.GetRole().getValue() >= roleLevel.getValue())
|
if(user.getRole().getValue() >= roleLevel.getValue())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reject(user, "permissions");
|
reject(user, "permissions");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by the Command manager - this will run the command
|
// Called by the Command manager - this will run the command
|
||||||
// if the issuing user has the permission to do so!
|
// 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;
|
return;
|
||||||
|
|
||||||
OnRun(guild, channel, user, input, res);
|
onRun(guild, channel, user, input, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> RegisteredNames()
|
public ArrayList<String> registeredNames()
|
||||||
{
|
{
|
||||||
return registeredNames;
|
return registeredNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KittyRating Rating()
|
public KittyRating rating()
|
||||||
{
|
{
|
||||||
return contentRating;
|
return contentRating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KittyRole RequiredRole()
|
public KittyRole requiredRole()
|
||||||
{
|
{
|
||||||
return roleLevel;
|
return roleLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OVERRIDE ME! (This is not required but advised!)
|
// OVERRIDE ME! (This is not required but advised!)
|
||||||
// Returns if the command succeeded or not.
|
// 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() + "!";
|
return "No help text has been added yet for " + this.getClass().getSimpleName() + "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// OVERRIDE ME! (This is required)
|
// OVERRIDE ME! (This is required)
|
||||||
// Returns if the command succeeded or not.
|
// 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,20 +30,20 @@ public class CommandEnabler extends BaseKeyValueFile
|
|||||||
super(name);
|
super(name);
|
||||||
|
|
||||||
// Create/Init variables
|
// Create/Init variables
|
||||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||||
enabledMap = new HashMap<>();
|
enabledMap = new HashMap<>();
|
||||||
keyList = new ArrayList<>();
|
keyList = new ArrayList<>();
|
||||||
|
|
||||||
// Startup
|
// Startup
|
||||||
ReadIn();
|
readIn();
|
||||||
GetTrackedCommands();
|
getTrackedCommands();
|
||||||
WriteOut();
|
writeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads in the config file and parses it, keeping tabs on the order it read things
|
// 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 key = pair.First;
|
||||||
String value = pair.Second;
|
String value = pair.Second;
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ public class CommandEnabler extends BaseKeyValueFile
|
|||||||
|
|
||||||
// Look up the already scraped values from the localizer and store them if they
|
// Look up the already scraped values from the localizer and store them if they
|
||||||
// don't already exist in the lookup. Defaults to defaultEnabledState.
|
// 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)
|
for(int i = 0; i < unloc.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -68,14 +68,14 @@ public class CommandEnabler extends BaseKeyValueFile
|
|||||||
|
|
||||||
if(enabledMap.putIfAbsent(command, defaultEnabledState) == null)
|
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);
|
keyList.add(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write out enabled/disabled file info.
|
// Write out enabled/disabled file info.
|
||||||
private void WriteOut()
|
private void writeOut()
|
||||||
{
|
{
|
||||||
List<Pair<String, String>> list = new Vector<Pair<String, String>>();
|
List<Pair<String, String>> list = new Vector<Pair<String, String>>();
|
||||||
|
|
||||||
@@ -92,11 +92,11 @@ public class CommandEnabler extends BaseKeyValueFile
|
|||||||
|
|
||||||
Collections.sort(list, (c1, c2) -> { return c1.First.compareTo(c2.First); });
|
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
|
// 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();
|
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)
|
// 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.
|
// 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)
|
if(pair == null || pair.Second == null)
|
||||||
return;
|
return;
|
||||||
@@ -39,7 +39,7 @@ public class CommandManager
|
|||||||
// If we haven't already split a multisplit command (or even assessed that),
|
// 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
|
// then verify if we even need to register the commands at all. If it's
|
||||||
// not enabled, don't register it.
|
// not enabled, don't register it.
|
||||||
if(pair.First != null && !commandEnabler.IsEnabled(pair.First))
|
if(pair.First != null && !commandEnabler.isEnabled(pair.First))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String key = pair.Second;
|
String key = pair.Second;
|
||||||
@@ -48,7 +48,7 @@ public class CommandManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
String[] keys = key.split(",");
|
String[] keys = key.split(",");
|
||||||
Register(keys, command);
|
register(keys, command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,25 +59,25 @@ public class CommandManager
|
|||||||
|
|
||||||
if(old != null)
|
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;
|
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!
|
// 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)
|
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!
|
// 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.
|
// 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;
|
return false;
|
||||||
|
|
||||||
Command command = commands.get(input.key);
|
Command command = commands.get(input.key);
|
||||||
@@ -91,44 +91,44 @@ public class CommandManager
|
|||||||
}
|
}
|
||||||
else
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calls the command specified with the key, providing user information arguments, etc.
|
// 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;
|
return;
|
||||||
|
|
||||||
Command command = commands.get(input.key);
|
Command command = commands.get(input.key);
|
||||||
if(command != null)
|
if(command != null)
|
||||||
{
|
{
|
||||||
++invokeCount;
|
++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.
|
// Looks up command by name. If it exists, dumps help text, otherwise returns null.
|
||||||
public String GetCommandHelpText(String lookup)
|
public String getCommandHelpText(String key)
|
||||||
{
|
{
|
||||||
Command command = commands.get(lookup);
|
Command command = commands.get(key);
|
||||||
|
|
||||||
if(command != null)
|
if(command != null)
|
||||||
return command.HelpText();
|
return "`" + key + "`: " + command.getHelpText();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of commands sent so far during this program run
|
// Returns the number of commands sent so far during this program run
|
||||||
public long GetInvokeCount()
|
public long getInvokeCount()
|
||||||
{
|
{
|
||||||
return invokeCount;
|
return invokeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns all commands by name
|
// Returns all commands by name
|
||||||
public ArrayList<Command> GetAllRegisteredCommands()
|
public ArrayList<Command> getAllRegisteredCommands()
|
||||||
{
|
{
|
||||||
ArrayList<Command> cmds = new ArrayList<Command>();
|
ArrayList<Command> cmds = new ArrayList<Command>();
|
||||||
for(Entry<String, Command> entry : commands.entrySet())
|
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 HashMap<Thread.State, Integer> states = new HashMap<Thread.State, Integer>();
|
||||||
}
|
}
|
||||||
public ThreadData DumpThreadData()
|
public ThreadData dumpThreadData()
|
||||||
{
|
{
|
||||||
ThreadData data = new ThreadData();
|
ThreadData data = new ThreadData();
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ public class CommandThread extends Thread
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
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
|
// Handles the try catch requirement java has for sleeping
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private void ThreadSleep(int ms)
|
private void threadSleep(int ms)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,97 +35,97 @@ public class DatabaseDriverKeyValue
|
|||||||
|
|
||||||
// Makes sure a table exists with the specified name.
|
// Makes sure a table exists with the specified name.
|
||||||
// The keyName specifies the key column label, and the valueName specifies the value column label.
|
// 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
|
// 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
|
// Set up and create a table in the database
|
||||||
public boolean Connect()
|
public boolean connect()
|
||||||
{
|
{
|
||||||
driver = new JDBCDriverSQLite();
|
driver = new JDBCDriverSQLite();
|
||||||
if(driver.Connect() == false)
|
if(driver.connect() == false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify tables we want to use exist
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The key will be created if it doesn't exist and the value specified will be stored.
|
// 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
|
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.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
String newValue = "";
|
String newValue = "";
|
||||||
CreateKey(key, newValue);
|
createKey(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prototype formatting for key updating
|
// 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 + " = ?";
|
String command = "UPDATE " + tableName + " SET " + valueColumnName + " = ? WHERE " + keyColumnName + " = ?";
|
||||||
boolean status = driver.ExecuteStatement(JDBCStatementType.Update, command, new String[] { value, key });
|
boolean status = driver.executeStatement(JDBCStatementType.Update, command, new String[] { value, key });
|
||||||
GlobalLog.Log(LogFilter.Database, "UpdateKey status: " + status);
|
GlobalLog.log(LogFilter.Database, "UpdateKey status: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protoype updating for seeing if a key exists
|
// 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 + " = ?";
|
String command = "SELECT COUNT(1) as count FROM " + tableName + " WHERE " + keyColumnName + " = ?";
|
||||||
ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
ResultSet set = driver.executeReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||||
String out = ResultAsString(set, "count");
|
String out = resultAsString(set, "count");
|
||||||
return out.charAt(0) == '1';
|
return out.charAt(0) == '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prototype for getting a key
|
// 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 + " = ?";
|
String command = "SELECT " + valueColumnName + " as searchedKey FROM " + tableName +" WHERE " + keyColumnName + " = ?";
|
||||||
ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
ResultSet set = driver.executeReturningStatement(JDBCStatementType.Select, command, new String[] { key });
|
||||||
return ResultAsString(set, "searchedKey");
|
return resultAsString(set, "searchedKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prototype for creating a key
|
// 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 (?, ?)";
|
String command = "INSERT INTO " + tableName + " (GlobalKey, GlobalValue) VALUES (?, ?)";
|
||||||
boolean status = driver.ExecuteStatement(JDBCStatementType.Insert, command, new String[] { key, value });
|
boolean status = driver.executeStatement(JDBCStatementType.Insert, command, new String[] { key, value });
|
||||||
GlobalLog.Log(LogFilter.Database, "CreateKey status: " + status);
|
GlobalLog.log(LogFilter.Database, "CreateKey status: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all keys containing a substring
|
// 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 ?";
|
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>();
|
List<String> keys = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ public class DatabaseDriverKeyValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transforms a result into a string if possible.
|
// 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)
|
if(rs == null)
|
||||||
return "";
|
return "";
|
||||||
@@ -165,7 +165,7 @@ public class DatabaseDriverKeyValue
|
|||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
GlobalLog.Error(LogFilter.Database, e.toString());
|
GlobalLog.error(LogFilter.Database, e.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class DatabaseManager
|
|||||||
// Constructor to enforce singleton.
|
// Constructor to enforce singleton.
|
||||||
public DatabaseManager()
|
public DatabaseManager()
|
||||||
{
|
{
|
||||||
GlobalLog.Log(LogFilter.Database, "Creating database manager");
|
GlobalLog.log(LogFilter.Database, "Creating database manager");
|
||||||
|
|
||||||
if(instance == null)
|
if(instance == null)
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalLog.Error(LogFilter.Database, "Attempted to register a second DataBase manager!");
|
GlobalLog.error(LogFilter.Database, "Attempted to register a second DataBase manager!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,15 +57,15 @@ public class DatabaseManager
|
|||||||
characterDataDriver = new DatabaseDriverKeyValue(characterTableName, characterKeyColumnName, characterValueColumnName);
|
characterDataDriver = new DatabaseDriverKeyValue(characterTableName, characterKeyColumnName, characterValueColumnName);
|
||||||
|
|
||||||
// Connect data sets
|
// 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);
|
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);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,10 +94,10 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
DatabaseTrackedObject dto = globalDataTrackedObjects.get(i);
|
DatabaseTrackedObject dto = globalDataTrackedObjects.get(i);
|
||||||
|
|
||||||
if(dto.IsDirty())
|
if(dto.isDirty())
|
||||||
{
|
{
|
||||||
globalSetRemoteValue(dto.identifier, dto.Serialize());
|
globalSetRemoteValue(dto.identifier, dto.serialize());
|
||||||
dto.Resolve();
|
dto.resolve();
|
||||||
++numUpdated;
|
++numUpdated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,10 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
DatabaseTrackedObject dto = characterDataTrackedObjects.get(i);
|
DatabaseTrackedObject dto = characterDataTrackedObjects.get(i);
|
||||||
|
|
||||||
if(dto.IsDirty())
|
if(dto.isDirty())
|
||||||
{
|
{
|
||||||
characterSetRemoteValue(dto.identifier, dto.Serialize());
|
characterSetRemoteValue(dto.identifier, dto.serialize());
|
||||||
dto.Resolve();
|
dto.resolve();
|
||||||
++numUpdated;
|
++numUpdated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ public class DatabaseManager
|
|||||||
|
|
||||||
public List<String> scrapeGlobalForString(String substring)
|
public List<String> scrapeGlobalForString(String substring)
|
||||||
{
|
{
|
||||||
return globalDataDriver.GetKeysWith(substring);
|
return globalDataDriver.getKeysWith(substring);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
@@ -142,7 +142,7 @@ public class DatabaseManager
|
|||||||
synchronized(globalDataTrackedObjects)
|
synchronized(globalDataTrackedObjects)
|
||||||
{
|
{
|
||||||
globalDataTrackedObjects.add(tracked);
|
globalDataTrackedObjects.add(tracked);
|
||||||
tracked.DeSerialzie(globalGetRemoteValue(tracked.identifier));
|
tracked.deSerialzie(globalGetRemoteValue(tracked.identifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
synchronized(globalDataDriver)
|
synchronized(globalDataDriver)
|
||||||
{
|
{
|
||||||
return globalDataDriver.CreateGetKey(key);
|
return globalDataDriver.createGetKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
synchronized(globalDataDriver)
|
synchronized(globalDataDriver)
|
||||||
{
|
{
|
||||||
globalDataDriver.CreateSetKey(key, value);
|
globalDataDriver.createSetKey(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public class DatabaseManager
|
|||||||
synchronized(characterDataTrackedObjects)
|
synchronized(characterDataTrackedObjects)
|
||||||
{
|
{
|
||||||
characterDataTrackedObjects.add(tracked);
|
characterDataTrackedObjects.add(tracked);
|
||||||
tracked.DeSerialzie(characterGetRemoteValue(tracked.identifier));
|
tracked.deSerialzie(characterGetRemoteValue(tracked.identifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
synchronized(characterDataDriver)
|
synchronized(characterDataDriver)
|
||||||
{
|
{
|
||||||
return characterDataDriver.CreateGetKey(key);
|
return characterDataDriver.createGetKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ public class DatabaseManager
|
|||||||
{
|
{
|
||||||
synchronized(characterDataDriver)
|
synchronized(characterDataDriver)
|
||||||
{
|
{
|
||||||
characterDataDriver.CreateSetKey(key, value);
|
characterDataDriver.createSetKey(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public abstract class DatabaseTrackedObject
|
|||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean IsDirty()
|
public final boolean isDirty()
|
||||||
{
|
{
|
||||||
synchronized(isDirty)
|
synchronized(isDirty)
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ public abstract class DatabaseTrackedObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void MarkDirty()
|
public final void markDirty()
|
||||||
{
|
{
|
||||||
synchronized(isDirty)
|
synchronized(isDirty)
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,7 @@ public abstract class DatabaseTrackedObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void Resolve()
|
public final void resolve()
|
||||||
{
|
{
|
||||||
synchronized(isDirty)
|
synchronized(isDirty)
|
||||||
{
|
{
|
||||||
@@ -39,6 +39,6 @@ public abstract class DatabaseTrackedObject
|
|||||||
|
|
||||||
// Consider an object factory instead of dedicated serialization methods
|
// Consider an object factory instead of dedicated serialization methods
|
||||||
// if this starts to become impractical. For now, it works.
|
// if this starts to become impractical. For now, it works.
|
||||||
public abstract String Serialize();
|
public abstract String serialize();
|
||||||
public abstract void DeSerialzie(String string);
|
public abstract void deSerialzie(String string);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -11,7 +11,7 @@ import dataStructures.Pair;
|
|||||||
public class LocCommands extends BaseLocFile
|
public class LocCommands extends BaseLocFile
|
||||||
{
|
{
|
||||||
public static final String fileName = "locCommands.config";
|
public static final String fileName = "locCommands.config";
|
||||||
public static final String function = "LocCommands.Stub";
|
public static final String function = "LocCommands.stub";
|
||||||
|
|
||||||
private static LocCommands instance;
|
private static LocCommands instance;
|
||||||
|
|
||||||
@@ -19,40 +19,40 @@ public class LocCommands extends BaseLocFile
|
|||||||
{
|
{
|
||||||
super(fileName, function);
|
super(fileName, function);
|
||||||
|
|
||||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||||
|
|
||||||
if(instance == null)
|
if(instance == null)
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
UpdateLocFromDisk();
|
updateLocFromDisk();
|
||||||
ScrapeAll();
|
scrapeAll();
|
||||||
SaveLocToDisk();
|
saveLocToDisk();
|
||||||
|
|
||||||
fileMonitor = new FileMonitor(filename);
|
fileMonitor = new FileMonitor(filename);
|
||||||
}
|
}
|
||||||
else
|
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
|
// 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.
|
// 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<>();
|
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;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Upkeep()
|
public static void upkeep()
|
||||||
{
|
{
|
||||||
instance.Update();
|
instance.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -10,7 +10,7 @@ import utils.io.FileMonitor;
|
|||||||
public class LocStrings extends BaseLocFile
|
public class LocStrings extends BaseLocFile
|
||||||
{
|
{
|
||||||
public static final String fileName = "locStrings.config";
|
public static final String fileName = "locStrings.config";
|
||||||
public static final String function = "LocStrings.Stub";
|
public static final String function = "LocStrings.stub";
|
||||||
|
|
||||||
private static LocStrings instance;
|
private static LocStrings instance;
|
||||||
|
|
||||||
@@ -18,37 +18,37 @@ public class LocStrings extends BaseLocFile
|
|||||||
{
|
{
|
||||||
super(fileName, function);
|
super(fileName, function);
|
||||||
|
|
||||||
GlobalLog.Log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||||
|
|
||||||
if(instance == null)
|
if(instance == null)
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
UpdateLocFromDisk();
|
updateLocFromDisk();
|
||||||
ScrapeAll();
|
scrapeAll();
|
||||||
SaveLocToDisk();
|
saveLocToDisk();
|
||||||
|
|
||||||
fileMonitor = new FileMonitor(filename);
|
fileMonitor = new FileMonitor(filename);
|
||||||
}
|
}
|
||||||
else
|
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
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ public class ObjectBuilderFactory
|
|||||||
private static JDA kitty;
|
private static JDA kitty;
|
||||||
|
|
||||||
// This is it, this is how the lazy init starts!
|
// This is it, this is how the lazy init starts!
|
||||||
private static void LazyInit()
|
private static void lazyInit()
|
||||||
{
|
{
|
||||||
if(hasInitialized)
|
if(hasInitialized)
|
||||||
return;
|
return;
|
||||||
@@ -99,7 +99,7 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
catch(InterruptedException ie)
|
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.");
|
+ " The factory was not initialized, and kitty will not be able to continue functionally.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,9 +109,9 @@ public class ObjectBuilderFactory
|
|||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
// Explicitly locks: guildCache
|
// 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
|
// 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
|
// 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) + ">";
|
emoteFix += ":" + emote.substring(emote.indexOf("(")+1, emote.length()-1) + ">";
|
||||||
emotesString.add(emoteFix);
|
emotesString.add(emoteFix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// once we're lazily initialized, we can synchronize w/ the
|
// once we're lazily initialized, we can synchronize w/ the
|
||||||
// guildCache object now instead of having to use a mutex.
|
// guildCache object now instead of having to use a mutex.
|
||||||
KittyGuild guild = null;
|
KittyGuild guild = null;
|
||||||
@@ -152,9 +153,9 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly locks: guildCache
|
// 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
|
// 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
|
// the guild if not, they're assumed to be
|
||||||
@@ -171,7 +172,7 @@ public class ObjectBuilderFactory
|
|||||||
{
|
{
|
||||||
KittyUser cachedUser = userCache.get(uid);
|
KittyUser cachedUser = userCache.get(uid);
|
||||||
if(cachedUser != null)
|
if(cachedUser != null)
|
||||||
role = cachedUser.GetRole();
|
role = cachedUser.getRole();
|
||||||
}
|
}
|
||||||
|
|
||||||
return role;
|
return role;
|
||||||
@@ -179,9 +180,9 @@ public class ObjectBuilderFactory
|
|||||||
|
|
||||||
// Explicitly locks: guildCache
|
// Explicitly locks: guildCache
|
||||||
// Extracts the content rating information it can from the provided event.
|
// 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.
|
// Look up content rating of the guild, returns a safe content rating.
|
||||||
KittyRating contentRating = KittyRating.Safe;
|
KittyRating contentRating = KittyRating.Safe;
|
||||||
@@ -197,9 +198,9 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implicitly locks guild cache by calling ExtractGuild
|
// 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 channelID = event.getChannel().getId();
|
||||||
String guildID = event.getGuild().getId();
|
String guildID = event.getGuild().getId();
|
||||||
@@ -225,9 +226,9 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implicitly locks guild cache by calling ExtractRole and ExtractGuild
|
// 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();
|
String uid = event.getGuild().getId() + event.getAuthor().getId();
|
||||||
KittyUser user = null;
|
KittyUser user = null;
|
||||||
@@ -241,8 +242,8 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KittyRole role = ExtractRole(event);
|
KittyRole role = extractRole(event);
|
||||||
KittyGuild guild = ExtractGuild(event);
|
KittyGuild guild = extractGuild(event);
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
if(event.getMember().getNickname() == null)
|
if(event.getMember().getNickname() == null)
|
||||||
@@ -266,20 +267,20 @@ public class ObjectBuilderFactory
|
|||||||
{
|
{
|
||||||
mentioned = event.getMessage().getMentionedMembers().get(i);
|
mentioned = event.getMessage().getMentionedMembers().get(i);
|
||||||
if(mentioned.getNickname() != null)
|
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());
|
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
|
||||||
else
|
else
|
||||||
ExtractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(),
|
extractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(),
|
||||||
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
|
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Cleanup
|
// TODO: Clean up
|
||||||
public static KittyUser ExtractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID)
|
public static KittyUser extractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID)
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
String uid = guildID + userID;
|
String uid = guildID + userID;
|
||||||
KittyUser user = null;
|
KittyUser user = null;
|
||||||
@@ -290,6 +291,7 @@ public class ObjectBuilderFactory
|
|||||||
{
|
{
|
||||||
if(name != null)
|
if(name != null)
|
||||||
cachedUser.name = name;
|
cachedUser.name = name;
|
||||||
|
|
||||||
cachedUser.avatarID = avatarID;
|
cachedUser.avatarID = avatarID;
|
||||||
user = cachedUser;
|
user = cachedUser;
|
||||||
}
|
}
|
||||||
@@ -323,30 +325,36 @@ public class ObjectBuilderFactory
|
|||||||
Member jdaMember = jdaGuild.getMemberById(userID);
|
Member jdaMember = jdaGuild.getMemberById(userID);
|
||||||
User jdaUser = jdaMember.getUser();
|
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);
|
updateUser(user, jdaMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Updates a user's name appropriately based on nickname if available
|
||||||
public static void updateUser(KittyUser user, Member member)
|
public static void updateUser(KittyUser user, Member member)
|
||||||
{
|
{
|
||||||
if(member.getNickname() == null)
|
if(member.getNickname() == null)
|
||||||
|
{
|
||||||
user.name = member.getUser().getName();
|
user.name = member.getUser().getName();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
user.name = member.getNickname();
|
user.name = member.getNickname();
|
||||||
|
}
|
||||||
|
|
||||||
user.avatarID = member.getUser().getAvatarUrl();
|
user.avatarID = member.getUser().getAvatarUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Construction Methods //
|
// Construction Methods //
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
// Builds the core of the bot
|
||||||
public static KittyCore ConstructKittyCore() throws LoginException, InterruptedException
|
public static KittyCore constructKittyCore() throws LoginException, InterruptedException
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
|
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
|
||||||
kitty.getPresence().setGame(Game.playing("with digital yarn"));
|
kitty.getPresence().setGame(Game.playing("with digital yarn"));
|
||||||
@@ -359,80 +367,85 @@ public class ObjectBuilderFactory
|
|||||||
// and disabling, what we do is construct the commands with a localized pair that is checked against
|
// 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
|
// the CommandEnabler object passed in. In theory, we could have multiple CommandManagers, tho we can
|
||||||
// only have one CommandEnabler.
|
// only have one CommandEnabler.
|
||||||
public static CommandManager ConstructCommandManager(CommandEnabler commandEnabler)
|
public static CommandManager constructCommandManager(CommandEnabler commandEnabler)
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
CommandManager manager = new CommandManager(commandEnabler);
|
CommandManager manager = new CommandManager(commandEnabler);
|
||||||
|
|
||||||
// Dev
|
// Dev
|
||||||
manager.Register(LocCommands.Stub("work"), new CommandDoWork(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("shutdown"), new CommandShutdown(KittyRole.Dev, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("stats"), new CommandStats(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("invite"), new CommandInvite(KittyRole.Dev, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("buildHelp"), new CommandHelpBuilder(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("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("dbflush"), new CommandDBFlush(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("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe));
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
manager.Register(LocCommands.Stub("rating"), new CommandRating(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("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("guildroleallowed"), new CommandGuildRoleAllowed(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("guildrolenotallowed"), new CommandGuildRoleNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||||
|
|
||||||
// Mod
|
// Mod
|
||||||
manager.Register(LocCommands.Stub("poll"), new CommandPollManage(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("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("rpg"), new CommandRPG(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("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("rafflespin"), new CommandRaffleSpin(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("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
|
||||||
// General
|
// General
|
||||||
manager.Register(LocCommands.Stub("fetch"), new CommandFetch(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("guildroleadd"), new CommandGuildRoleAdd(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("guildroleremove"), new CommandGuildRoleRemove(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("teey"), new CommandTeey(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("perish, thenperish"), new CommandPerish(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("yeet"), new CommandYeet(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("ping"), new CommandPing(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("boop"), new CommandBoop(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("roll"), new CommandRoll(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("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("help"), new CommandHelp(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("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("vote"), new CommandPollVote(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("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("showpoll"), new CommandPollShow(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("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("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("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("beans"), new CommandBeansShow(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("role"), new CommandRole(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("bet"), new CommandBetBeans(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("map"), new CommandMap(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("rpstart"), new CommandRPStart(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("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("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("blur"), new CommandBlurry(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("eightball, 8ball"), new CommandEightBall(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("catch"), new CommandCatch(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("guildrolelist"), new CommandGuildRoleList(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("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("crouton"), new CommandCrouton(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("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("rafflejoin"), new CommandRaffleJoin(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("charactercreate"), new CommandCharacterCreate(KittyRole.General, KittyRating.Safe));
|
||||||
manager.Register(LocCommands.Stub("leaderboard"), new CommandLeaderboard(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;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does.
|
// 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)
|
if(commandEnabler == null)
|
||||||
commandEnabler = new CommandEnabler();
|
commandEnabler = new CommandEnabler();
|
||||||
@@ -444,9 +457,9 @@ public class ObjectBuilderFactory
|
|||||||
// in different ways, and so we construct it outside of the constructor for
|
// 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.
|
// the factory since it doesn't have to be present / can be elsewhere.
|
||||||
// Effectively we cache the database here.
|
// Effectively we cache the database here.
|
||||||
public static DatabaseManager ConstructDatabaseManager()
|
public static DatabaseManager constructDatabaseManager()
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
if(database == null)
|
if(database == null)
|
||||||
database = new DatabaseManager();
|
database = new DatabaseManager();
|
||||||
@@ -454,9 +467,9 @@ public class ObjectBuilderFactory
|
|||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stats ConstructStats(CommandManager manager)
|
public static Stats constructStats(CommandManager manager)
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
if(stats == null)
|
if(stats == null)
|
||||||
stats = new Stats(manager);
|
stats = new Stats(manager);
|
||||||
@@ -464,9 +477,9 @@ public class ObjectBuilderFactory
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RPManager ConstructRPManager()
|
public static RPManager constructRPManager()
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
if(rpManager == null)
|
if(rpManager == null)
|
||||||
rpManager = new RPManager();
|
rpManager = new RPManager();
|
||||||
@@ -474,9 +487,9 @@ public class ObjectBuilderFactory
|
|||||||
return rpManager;
|
return rpManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PluginManager ConstructPluginManager()
|
public static PluginManager constructPluginManager()
|
||||||
{
|
{
|
||||||
LazyInit();
|
lazyInit();
|
||||||
|
|
||||||
if(pluginManager == null)
|
if(pluginManager == null)
|
||||||
pluginManager = new PluginManager("./plugins/");
|
pluginManager = new PluginManager("./plugins/");
|
||||||
@@ -484,12 +497,13 @@ public class ObjectBuilderFactory
|
|||||||
return pluginManager;
|
return pluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Utility Methods //
|
// Utility Methods //
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
|
||||||
// Returns number of cached guilds (does not equal total users in the database, only what's in memory)
|
// 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)
|
{ synchronized(guildCache)
|
||||||
{
|
{
|
||||||
return guildCache.size();
|
return guildCache.size();
|
||||||
@@ -497,7 +511,7 @@ public class ObjectBuilderFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns number of cached users (does not equal total users in the database, only what's in memory)
|
// 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)
|
{ synchronized(userCache)
|
||||||
{
|
{
|
||||||
return userCache.size();
|
return userCache.size();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class RPManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second RP Manager!");
|
GlobalLog.error(LogFilter.Core, "Attempted to create a second RP Manager!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ public class RPManager
|
|||||||
|
|
||||||
public void addLine(KittyChannel channel, KittyUser user, UserInput input)
|
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);
|
logs.get(Long.parseLong(channel.uniqueID)).addLine(user, input.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class RPManager
|
|||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Upkeep(KittyCore kitty)
|
public static void upkeep(KittyCore kitty)
|
||||||
{
|
{
|
||||||
Response res = new Response(null, kitty);
|
Response res = new Response(null, kitty);
|
||||||
String reminder = "";
|
String reminder = "";
|
||||||
@@ -71,7 +71,7 @@ public class RPManager
|
|||||||
{
|
{
|
||||||
reminder += " <@" + users.get(i) + ">";
|
reminder += " <@" + users.get(i) + ">";
|
||||||
}
|
}
|
||||||
res.CallToChannel(reminder, entry.getValue().getChannel().uniqueID);
|
res.sendToChannel(reminder, entry.getValue().getChannel().uniqueID);
|
||||||
reminder = "";
|
reminder = "";
|
||||||
|
|
||||||
entry.getValue().resetTimer();
|
entry.getValue().resetTimer();
|
||||||
|
|||||||
+20
-20
@@ -31,7 +31,7 @@ public class Stats
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalLog.Error(LogFilter.Core, "Attempted to create a second Stats singleton!");
|
GlobalLog.error(LogFilter.Core, "Attempted to create a second Stats singleton!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,12 +43,12 @@ public class Stats
|
|||||||
osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NoteMessageEvent()
|
public void noteMessageEvent()
|
||||||
{
|
{
|
||||||
++messagesSeen;
|
++messagesSeen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IndicateShutdown()
|
public void indicateShutdown()
|
||||||
{
|
{
|
||||||
synchronized(instance)
|
synchronized(instance)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ public class Stats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean GetIsShuttingDown()
|
public boolean getIsShuttingDown()
|
||||||
{
|
{
|
||||||
synchronized(instance)
|
synchronized(instance)
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ public class Stats
|
|||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
|
||||||
// Formatted as HH:MM:SS
|
// Formatted as HH:MM:SS
|
||||||
public String GetFormattedUptime()
|
public String getFormattedUptime()
|
||||||
{
|
{
|
||||||
long dif = System.currentTimeMillis() - initTimeMS;
|
long dif = System.currentTimeMillis() - initTimeMS;
|
||||||
|
|
||||||
@@ -80,48 +80,48 @@ public class Stats
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get number of commands that kitty has run!
|
// 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;
|
return messagesSeen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetSystemCPULoad()
|
public double getSystemCPULoad()
|
||||||
{
|
{
|
||||||
return osBean.getSystemLoadAverage();
|
return osBean.getSystemLoadAverage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetCPUAvailable()
|
public long getCPUAvailable()
|
||||||
{
|
{
|
||||||
return osBean.getAvailableProcessors();
|
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
|
// 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;
|
this.resString = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Call(Response res)
|
public void call(Response res)
|
||||||
{
|
{
|
||||||
if(resEmbed == null)
|
if(resEmbed == null)
|
||||||
res.Call(resString);
|
res.send(resString);
|
||||||
else
|
else
|
||||||
res.CallEmbed(resEmbed);
|
res.send(resEmbed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,43 +16,43 @@ public class BenchmarkFramework
|
|||||||
this.benchmarkManager = new BenchmarkManager();
|
this.benchmarkManager = new BenchmarkManager();
|
||||||
this.benchmarkCommand = new HashMap<String, BenchmarkCommand>();
|
this.benchmarkCommand = new HashMap<String, BenchmarkCommand>();
|
||||||
|
|
||||||
RegisterCommand("find", new BenchmarkCommandFind());
|
registerCommand("find", new BenchmarkCommandFind());
|
||||||
RegisterCommand("compare", new BenchmarkCommandCompare());
|
registerCommand("compare", new BenchmarkCommandCompare());
|
||||||
RegisterCommand("info", new BenchmarkCommandInfo());
|
registerCommand("info", new BenchmarkCommandInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs a command if possible.
|
// Runs a command if possible.
|
||||||
public BenchmarkFormattable Run(String args)
|
public BenchmarkFormattable run(String args)
|
||||||
{
|
{
|
||||||
BenchmarkInput input = new BenchmarkInput(args);
|
BenchmarkInput input = new BenchmarkInput(args);
|
||||||
return ExecuteCommand(input.key, input);
|
return executeCommand(input.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void update()
|
||||||
{
|
{
|
||||||
synchronized(benchmarkManager)
|
synchronized(benchmarkManager)
|
||||||
{
|
{
|
||||||
benchmarkManager.Update();
|
benchmarkManager.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers a command
|
// Registers a command
|
||||||
private void RegisterCommand(String commandName, BenchmarkCommand command)
|
private void registerCommand(String commandName, BenchmarkCommand command)
|
||||||
{
|
{
|
||||||
commandName = commandName.toLowerCase();
|
commandName = commandName.toLowerCase();
|
||||||
if(benchmarkCommand.put(commandName, command) != null)
|
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.
|
// 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());
|
BenchmarkCommand command = benchmarkCommand.get(name.toLowerCase());
|
||||||
|
|
||||||
if(command != null && benchmarkManager != null)
|
if(command != null && benchmarkManager != null)
|
||||||
return command.OnRun(benchmarkManager, input);
|
return command.onRun(benchmarkManager, input);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class BenchmarkInput
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
raw = raw.trim();
|
raw = raw.trim();
|
||||||
int whitespacePos = StringUtils.FindFirstWhitespace(raw);
|
int whitespacePos = StringUtils.findFirstWhitespace(raw);
|
||||||
|
|
||||||
if(whitespacePos == -1)
|
if(whitespacePos == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import utils.GlobalLog;
|
|||||||
//Logging shim
|
//Logging shim
|
||||||
public class BenchmarkLog
|
public class BenchmarkLog
|
||||||
{
|
{
|
||||||
public static void Log(String str) { GlobalLog.Log("[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 warn(String str) { GlobalLog.warn("[Benchmark] " + str); }
|
||||||
public static void Error(String str) { GlobalLog.Error(" [Benchmark] " + str); }
|
public static void error(String str) { GlobalLog.error(" [Benchmark] " + str); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ public class BenchmarkManager
|
|||||||
directoryMonitor = new DirectoryMonitor(directory);
|
directoryMonitor = new DirectoryMonitor(directory);
|
||||||
needsUpdate = false;
|
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
|
// Rebuilds the files being monitored
|
||||||
public void RebuildLookup()
|
public void rebuildLookup()
|
||||||
{
|
{
|
||||||
long start = Instant.now().toEpochMilli();
|
long start = Instant.now().toEpochMilli();
|
||||||
|
|
||||||
@@ -50,14 +50,14 @@ public class BenchmarkManager
|
|||||||
|
|
||||||
synchronized(directoryMonitor)
|
synchronized(directoryMonitor)
|
||||||
{
|
{
|
||||||
files = directoryMonitor.GetCurrentFiles();
|
files = directoryMonitor.getCurrentFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(files != null)
|
if(files != null)
|
||||||
{
|
{
|
||||||
for(MonitoredFile mf : files)
|
for(MonitoredFile mf : files)
|
||||||
{
|
{
|
||||||
String contents = FileUtils.ReadContent(mf.path);
|
String contents = FileUtils.readContent(mf.path);
|
||||||
String[] lines = contents.split(lineDelimiter);
|
String[] lines = contents.split(lineDelimiter);
|
||||||
|
|
||||||
for(int i = 1; i < lines.length; ++i)
|
for(int i = 1; i < lines.length; ++i)
|
||||||
@@ -66,17 +66,17 @@ public class BenchmarkManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BenchmarkLog.Warn("No " + extension + " files where found in " + directory);
|
BenchmarkLog.warn("No " + extension + " files where found in " + directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = Instant.now().toEpochMilli();
|
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
|
// 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.
|
// 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
|
// Populate cost list with heuristic results
|
||||||
List<Pair<BenchmarkEntry, Integer>> cost = new ArrayList<Pair<BenchmarkEntry, Integer>>();
|
List<Pair<BenchmarkEntry, Integer>> cost = new ArrayList<Pair<BenchmarkEntry, Integer>>();
|
||||||
@@ -86,7 +86,7 @@ public class BenchmarkManager
|
|||||||
BenchmarkEntry entry = entries.get(i);
|
BenchmarkEntry entry = entries.get(i);
|
||||||
String entryString = entry.brand + " " + entry.model;
|
String entryString = entry.brand + " " + entry.model;
|
||||||
|
|
||||||
int heuristic = LevenshteinHeuristic(entryString, search, bestSoFar);
|
int heuristic = levenshteinHeuristic(entryString, search, bestSoFar);
|
||||||
if(heuristic < bestSoFar)
|
if(heuristic < bestSoFar)
|
||||||
bestSoFar = heuristic;
|
bestSoFar = heuristic;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public class BenchmarkManager
|
|||||||
// Returns cost based on distance of characters from string. This is a kinda sloppy way
|
// 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.
|
// 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.
|
// 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;
|
int cost;
|
||||||
|
|
||||||
@@ -139,15 +139,15 @@ public class BenchmarkManager
|
|||||||
if(distance > bestSoFar)
|
if(distance > bestSoFar)
|
||||||
return distance;
|
return distance;
|
||||||
|
|
||||||
int s1 = LevenshteinHeuristic(str1.substring(1), str2, bestSoFar) + 1;
|
int s1 = levenshteinHeuristic(str1.substring(1), str2, bestSoFar) + 1;
|
||||||
int s2 = LevenshteinHeuristic(str1, str2.substring(1), bestSoFar) + 1;
|
int s2 = levenshteinHeuristic(str1, str2.substring(1), bestSoFar) + 1;
|
||||||
int s3 = LevenshteinHeuristic(str1.substring(1), str2.substring(1), bestSoFar) + cost;
|
int s3 = levenshteinHeuristic(str1.substring(1), str2.substring(1), bestSoFar) + cost;
|
||||||
|
|
||||||
return min(new int[] {s1, s2, s3 });
|
return min(new int[] {s1, s2, s3 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for a substring in the model name
|
// 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();
|
long start = Instant.now().toEpochMilli();
|
||||||
List<BenchmarkEntry> matching = new ArrayList<BenchmarkEntry>();
|
List<BenchmarkEntry> matching = new ArrayList<BenchmarkEntry>();
|
||||||
@@ -161,27 +161,27 @@ public class BenchmarkManager
|
|||||||
matching.add(e);
|
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;
|
return matching;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keeps tabs on any changes of the files.
|
// Keeps tabs on any changes of the files.
|
||||||
public void Update()
|
public void update()
|
||||||
{
|
{
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
directoryMonitor.Update(this::OnRescan, this::OnRescan, this::OnRescan);
|
directoryMonitor.update(this::onRescan, this::onRescan, this::onRescan);
|
||||||
|
|
||||||
if(needsUpdate)
|
if(needsUpdate)
|
||||||
RebuildLookup();
|
rebuildLookup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a file is changed, handle it.
|
// 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.
|
// For now, all we need is to note that something was adjusted.
|
||||||
if(file.path.toString().contains(extension))
|
if(file.path.toString().contains(extension))
|
||||||
{
|
{
|
||||||
BenchmarkLog.Log("File status changed: " + file.path);
|
BenchmarkLog.log("File status changed: " + file.path);
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,17 +44,17 @@ public class Plugin
|
|||||||
}
|
}
|
||||||
catch (IOException e)
|
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
|
try
|
||||||
{
|
{
|
||||||
List<String> outputs = new Vector<String>();
|
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())
|
if(!res.isnil())
|
||||||
{
|
{
|
||||||
@@ -87,7 +87,7 @@ public class Plugin
|
|||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
PluginLog.Error("Failed to run plugin from file " + filepath);
|
PluginLog.error("Failed to run plugin from file " + filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import utils.LogFilter;
|
|||||||
|
|
||||||
public class PluginLog
|
public class PluginLog
|
||||||
{
|
{
|
||||||
public static void Log(String s) { GlobalLog.Log(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 warn(String s) { GlobalLog.warn(LogFilter.Plugin, s); }
|
||||||
public static void Error(String s) { GlobalLog.Error(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.
|
// Reads in, handles, and manipulates plugins. Plugins are loaded in the order they appear in the folder.
|
||||||
public class PluginManager
|
public class PluginManager
|
||||||
{
|
{
|
||||||
|
// Variables
|
||||||
public final String pluginFolder;
|
public final String pluginFolder;
|
||||||
public ArrayList<Plugin> plugins;
|
public ArrayList<Plugin> plugins;
|
||||||
|
|
||||||
public void AddPlugin(Path path)
|
// Constructor
|
||||||
{
|
|
||||||
plugins.add(new Plugin(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public PluginManager(String folder)
|
public PluginManager(String folder)
|
||||||
{
|
{
|
||||||
this.pluginFolder = folder;
|
this.pluginFolder = folder;
|
||||||
@@ -29,30 +26,35 @@ public class PluginManager
|
|||||||
{
|
{
|
||||||
try (Stream<Path> paths = Files.walk(Paths.get(this.pluginFolder)))
|
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)
|
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
|
// 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
|
// are mutliple strings returned in the list, it is because the plugin
|
||||||
// that was run returned multiple strings. Since plugins don't stack, it
|
// that was run returned multiple strings. Since plugins don't stack, it
|
||||||
// will never indicate that multiple
|
// will never indicate that multiple
|
||||||
// Otherwise, returns null.
|
// 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)
|
for(int i = 0; i < plugins.size(); ++i)
|
||||||
{
|
{
|
||||||
Plugin plugin = plugins.get(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)
|
if(out != null)
|
||||||
{
|
{
|
||||||
PluginLog.Log("Executed plugin at " + plugin.filepath);
|
PluginLog.log("Executed plugin at " + plugin.filepath);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,9 +62,10 @@ public class PluginManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrintAll()
|
// Dumps the contents of all plugins for debug
|
||||||
|
public void printAll()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < plugins.size(); ++i)
|
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 class PluginStructure
|
||||||
{
|
{
|
||||||
public LuaValue AsLua()
|
public LuaValue asLua()
|
||||||
{
|
{
|
||||||
return CoerceJavaToLua.coerce(this);
|
return CoerceJavaToLua.coerce(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ public class RPGArmor extends RPGItem
|
|||||||
defense = 1;
|
defense = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long GetDefense() { return defense; }
|
public long getDefense() { return defense; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ public abstract class RPGCommand
|
|||||||
public RPGCommand() { }
|
public RPGCommand() { }
|
||||||
|
|
||||||
// OVERRIDE ME
|
// OVERRIDE ME
|
||||||
public abstract String OnRun(RPGState state, RPGInput input);
|
public abstract String onRun(RPGState state, RPGInput input);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package core.rpg;
|
|||||||
|
|
||||||
public final class RPGExpTable
|
public final class RPGExpTable
|
||||||
{
|
{
|
||||||
public static long EXPFloor(long level)
|
public static long expFloor(long level)
|
||||||
{
|
{
|
||||||
if(level > Levels.length - 1)
|
if(level > Levels.length - 1)
|
||||||
level = Levels.length - 1;
|
level = Levels.length - 1;
|
||||||
@@ -13,7 +13,7 @@ public final class RPGExpTable
|
|||||||
return Levels[(int) level];
|
return Levels[(int) level];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long EXPCeil(long level)
|
public static long expCeil(long level)
|
||||||
{
|
{
|
||||||
if(level > Levels.length - 1)
|
if(level > Levels.length - 1)
|
||||||
level = Levels.length - 1;
|
level = Levels.length - 1;
|
||||||
@@ -23,7 +23,7 @@ public final class RPGExpTable
|
|||||||
|
|
||||||
return Levels[(int) (level + 1)];
|
return Levels[(int) (level + 1)];
|
||||||
}
|
}
|
||||||
public static long LevelFromEXP(long exp)
|
public static long levelFromEXP(long exp)
|
||||||
{
|
{
|
||||||
if(exp < 0)
|
if(exp < 0)
|
||||||
exp = 0;
|
exp = 0;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user