Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
+7
-1
@@ -1,7 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="module" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="lib/commons-codec-1.11.jar"/>
|
<classpathentry kind="lib" path="lib/commons-codec-1.11.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
|
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/gson-2.6.2.jar"/>
|
<classpathentry kind="lib" path="lib/gson-2.6.2.jar"/>
|
||||||
@@ -20,5 +24,7 @@
|
|||||||
<classpathentry kind="lib" path="lib/commons-collections4-4.3.jar"/>
|
<classpathentry kind="lib" path="lib/commons-collections4-4.3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-lang3-3.9.jar"/>
|
<classpathentry kind="lib" path="lib/commons-lang3-3.9.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-text-1.6.jar"/>
|
<classpathentry kind="lib" path="lib/commons-text-1.6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/google-api-services-youtube-v3-rev212-1.25.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/lavaplayer-1.3.19.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
+9
-2
@@ -37,9 +37,12 @@
|
|||||||
"Localized Commands","kittyrole",""
|
"Localized Commands","kittyrole",""
|
||||||
"Localized Commands","leaderboard",""
|
"Localized Commands","leaderboard",""
|
||||||
"Localized Commands","map",""
|
"Localized Commands","map",""
|
||||||
|
"Localized Commands","mod",""
|
||||||
|
"Localized Commands","music",""
|
||||||
"Localized Commands","perish, thenperish",""
|
"Localized Commands","perish, thenperish",""
|
||||||
"Localized Commands","ping",""
|
"Localized Commands","ping",""
|
||||||
"Localized Commands","poll",""
|
"Localized Commands","poll",""
|
||||||
|
"Localized Commands","raffle",""
|
||||||
"Localized Commands","raffleend",""
|
"Localized Commands","raffleend",""
|
||||||
"Localized Commands","rafflejoin",""
|
"Localized Commands","rafflejoin",""
|
||||||
"Localized Commands","rafflespin",""
|
"Localized Commands","rafflespin",""
|
||||||
@@ -189,16 +192,17 @@
|
|||||||
"Localized Strings","MapSeed","Seed"
|
"Localized Strings","MapSeed","Seed"
|
||||||
"Localized Strings","MapVersion","Using mapgen v0.1"
|
"Localized Strings","MapVersion","Using mapgen v0.1"
|
||||||
"Localized Strings","MapWidth",""
|
"Localized Strings","MapWidth",""
|
||||||
|
"Localized Strings","MusicInfo",""
|
||||||
"Localized Strings","PerishInfo","Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned"
|
"Localized Strings","PerishInfo","Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned"
|
||||||
"Localized Strings","PingInfo","Will respond with Pong!"
|
"Localized Strings","PingInfo","Will respond with Pong!"
|
||||||
"Localized Strings","PingResponse","Pong!"
|
"Localized Strings","PingResponse","Pong!"
|
||||||
"Localized Strings","PollManageInfo","'start' will start a new poll with the query of the line you put after, 'choice' will add a choice to the poll, 'stop' will end the poll"
|
"Localized Strings","PollManageInfo","'start' will start a new poll with the query of the line you put after, 'choice' will add a choice to the poll, 'stop' will end the poll"
|
||||||
"Localized Strings","PollResultsInfo","Will show current results of a poll and percentages of votes per choice"
|
"Localized Strings","PollResultsInfo","Will show current results of a poll and percentages of votes per choice"
|
||||||
"Localized Strings","PollResultsResponse","%s people voted for %s `%s` with `%s%` !n"
|
"Localized Strings","PollResultsResponse","%s people voted for `%s` with `%s%%` "
|
||||||
"Localized Strings","PollShowChoices","And the choices are:n"
|
"Localized Strings","PollShowChoices","And the choices are:n"
|
||||||
"Localized Strings","PollShowInfo","Will show the current poll running"
|
"Localized Strings","PollShowInfo","Will show the current poll running"
|
||||||
"Localized Strings","PollShowNoPoll","There is no poll running!"
|
"Localized Strings","PollShowNoPoll","There is no poll running!"
|
||||||
"Localized Strings","PollShowPoll","The current poll is `%s`n"
|
"Localized Strings","PollShowPoll","The current poll is `%s`"
|
||||||
"Localized Strings","PollVoteAlreadyVoted","You already voted"
|
"Localized Strings","PollVoteAlreadyVoted","You already voted"
|
||||||
"Localized Strings","PollVoteInfo","Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful!"
|
"Localized Strings","PollVoteInfo","Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful!"
|
||||||
"Localized Strings","PollVoteNoPoll","There is no poll running!"
|
"Localized Strings","PollVoteNoPoll","There is no poll running!"
|
||||||
@@ -293,9 +297,12 @@
|
|||||||
"Command Enabler","kittyrole","1"
|
"Command Enabler","kittyrole","1"
|
||||||
"Command Enabler","leaderboard","1"
|
"Command Enabler","leaderboard","1"
|
||||||
"Command Enabler","map","1"
|
"Command Enabler","map","1"
|
||||||
|
"Command Enabler","mod","1"
|
||||||
|
"Command Enabler","music","1"
|
||||||
"Command Enabler","perish, thenperish","1"
|
"Command Enabler","perish, thenperish","1"
|
||||||
"Command Enabler","ping","1"
|
"Command Enabler","ping","1"
|
||||||
"Command Enabler","poll","1"
|
"Command Enabler","poll","1"
|
||||||
|
"Command Enabler","raffle","1"
|
||||||
"Command Enabler","raffleend","1"
|
"Command Enabler","raffleend","1"
|
||||||
"Command Enabler","rafflejoin","1"
|
"Command Enabler","rafflejoin","1"
|
||||||
"Command Enabler","rafflespin","1"
|
"Command Enabler","rafflespin","1"
|
||||||
|
|||||||
|
Binary file not shown.
Binary file not shown.
@@ -22,12 +22,9 @@ public class CommandCharacterMain extends Command
|
|||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("CharacterInfo"); }
|
public String getHelpText() { return LocStrings.stub("CharacterInfo"); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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.run(guild, channel, user, input.args).Call(res);
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,16 +4,21 @@ import core.CharacterManager;
|
|||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import core.SubCommand;
|
import core.SubCommand;
|
||||||
import core.SubCommandFormattable;
|
import core.SubCommandFormattable;
|
||||||
import dataStructures.*;
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandCreate extends SubCommand
|
public class SubCommandCreate extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
String [] info = input.split(",");
|
String [] info = input.args.split(",");
|
||||||
if(info.length < 3)
|
if(info.length < 3)
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterCreateNullInfo"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterCreateNullInfo"));
|
||||||
|
|||||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandEditBio extends SubCommand
|
public class SubCommandEditBio extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Long.parseLong(input.split(" ")[0]);
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioNotValid"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioNotValid"));
|
||||||
}
|
}
|
||||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||||
if(character.getOwner().equals(user))
|
if(character.getOwner().equals(user))
|
||||||
{
|
{
|
||||||
CharacterManager.instance.editBio(character, input.substring(input.indexOf(' ')));
|
CharacterManager.instance.editBio(character, input.args.substring(input.args.indexOf(' ')));
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioSuccess"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioSuccess"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandEditName extends SubCommand
|
public class SubCommandEditName extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Long.parseLong(input.split(" ")[0]);
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameNotValid"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameNotValid"));
|
||||||
}
|
}
|
||||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||||
if(character.getOwner().equals(user))
|
if(character.getOwner().equals(user))
|
||||||
{
|
{
|
||||||
CharacterManager.instance.editName(character, input.substring(input.indexOf(' ')));
|
CharacterManager.instance.editName(character, input.args.substring(input.args.indexOf(' ')));
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameSuccess"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameSuccess"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -10,26 +10,27 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandEditURL extends SubCommand
|
public class SubCommandEditURL extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Long.parseLong(input.split(" ")[0]);
|
Long.parseLong(input.args.split(" ")[0]);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLNotValid"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLNotValid"));
|
||||||
}
|
}
|
||||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||||
if(character.getOwner().equals(user))
|
if(character.getOwner().equals(user))
|
||||||
{
|
{
|
||||||
CharacterManager.instance.editRefImage(character, input.substring(input.indexOf(' ')));
|
CharacterManager.instance.editRefImage(character, input.args.substring(input.args.indexOf(' ')));
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLSuccess"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLSuccess"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -12,15 +12,16 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandSearch extends SubCommand
|
public class SubCommandSearch extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input);
|
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input.args);
|
||||||
if(characters.size() < 1)
|
if(characters.size() < 1)
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable (LocStrings.stub("CharacterSearchNoCharacterFound"));
|
return new SubCommandFormattable (LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class CommandBlurry extends Command
|
|||||||
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
public String getHelpText() { return LocStrings.stub("BlurryInfo"); };
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
private static float [] weights = {.00390625f, .0156625f, .0234475f, .0156625f, .00390625f};
|
||||||
|
|
||||||
|
|
||||||
@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)
|
||||||
@@ -53,7 +55,7 @@ public class CommandBlurry extends Command
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preProcessed = new File(filename);
|
preProcessed = new File(filename);
|
||||||
applySnap(ImageIO.read(preProcessed), name);
|
applyBlur(ImageIO.read(preProcessed), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -67,20 +69,20 @@ public class CommandBlurry extends Command
|
|||||||
ImageUtils.blockingFileDelete(postProcessed);
|
ImageUtils.blockingFileDelete(postProcessed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applySnap(BufferedImage image, String name) throws IOException
|
private static void applyBlur(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
|
||||||
for(int i = 0; i < 50; ++i)
|
for(int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
for(int x = 1; x < image.getWidth() - 1; ++x)
|
for(int x = 0; x < image.getWidth(); ++x)
|
||||||
{
|
{
|
||||||
for(int y = 1; y < image.getHeight() - 1; ++y)
|
for(int y = 0; y < image.getHeight(); ++y)
|
||||||
{
|
{
|
||||||
blurred.setRGB(x, y, getColorAvg(image, x, y).getRGB());
|
blurred.setRGB(x, y, getColorAvg(image, x, y).getRGB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
image = ImageUtils.copyImage(blurred);
|
image = blurred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -90,28 +92,54 @@ public class CommandBlurry extends Command
|
|||||||
|
|
||||||
private static Color getColorAvg(BufferedImage image, int x, int y)
|
private static Color getColorAvg(BufferedImage image, int x, int y)
|
||||||
{
|
{
|
||||||
Color center = new Color(image.getRGB(x, y), true);
|
Color current;
|
||||||
Color one = new Color(image.getRGB(x - 1, y), true);
|
float r = 0;
|
||||||
Color two = new Color(image.getRGB(x - 1, y - 1), true);
|
float g = 0;
|
||||||
Color three = new Color(image.getRGB(x, y - 1), true);
|
float b = 0;
|
||||||
Color four = new Color(image.getRGB(x + 1, y - 1), true);
|
|
||||||
Color five = new Color(image.getRGB(x + 1, y), true);
|
|
||||||
Color six = new Color(image.getRGB(x + 1, y + 1), true);
|
|
||||||
Color seven = new Color(image.getRGB(x, y + 1), true);
|
|
||||||
Color eight = new Color(image.getRGB(x -1, y + 1), true);
|
|
||||||
|
|
||||||
int blue = center.getBlue() + one.getBlue() + two.getBlue() + three.getBlue() + four.getBlue() + five.getBlue() + six.getBlue() + seven.getBlue() + eight.getBlue();
|
for(int xCor = -2; xCor <= 2; xCor++)
|
||||||
int red = center.getRed() + one.getRed() + two.getRed() + three.getRed() + four.getRed() + five.getRed() + six.getRed() + seven.getRed() + eight.getRed();
|
{
|
||||||
int green = center.getGreen() + one.getGreen() + two.getGreen() + three.getGreen() + four.getGreen() + five.getGreen() + six.getGreen() + seven.getGreen() + eight.getGreen();
|
for(int yCor = -2; yCor <= 2; yCor++)
|
||||||
int alpha = center.getAlpha() + one.getAlpha() + two.getAlpha() + three.getAlpha() + four.getAlpha() + five.getAlpha() + six.getAlpha() + seven.getAlpha() + eight.getAlpha();
|
{
|
||||||
|
int curX = clamp(x + xCor, 0, image.getWidth() - 1);
|
||||||
|
int curY = clamp(y + yCor, 0, image.getHeight() - 1);
|
||||||
|
|
||||||
blue /= 9;
|
|
||||||
red /= 9;
|
|
||||||
green /= 9;
|
|
||||||
alpha /= 9;
|
|
||||||
|
|
||||||
Color blur = new Color(red, green, blue, alpha);
|
current = new Color(image.getRGB(curX, curY));
|
||||||
|
|
||||||
return blur;
|
r += getGaus(current.getRed(), xCor, yCor);
|
||||||
|
g += getGaus(current.getGreen(), xCor, yCor);
|
||||||
|
b += getGaus(current.getBlue(), xCor, yCor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
int red = (int)r;
|
||||||
|
int green = (int)g;
|
||||||
|
int blue = (int)b;
|
||||||
|
return new Color(red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int clamp(int num, int min, int max)
|
||||||
|
{
|
||||||
|
if(num >= max)
|
||||||
|
return max;
|
||||||
|
if(num < min)
|
||||||
|
return min;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float getGaus(int col, int x, int y)
|
||||||
|
{
|
||||||
|
x += 2;
|
||||||
|
y+= 2;
|
||||||
|
float result = weights[x];
|
||||||
|
if(y == 2 || y == 4)
|
||||||
|
result *= 4;
|
||||||
|
if(y==3)
|
||||||
|
result *= 6;
|
||||||
|
|
||||||
|
result *= col;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.*;
|
|
||||||
import dataStructures.KittyChannel;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandPollManage extends Command
|
|
||||||
{
|
|
||||||
public CommandPollManage(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("PollManageInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
switch(input.args.split(" ")[0].toLowerCase())
|
|
||||||
{
|
|
||||||
case "start":
|
|
||||||
res.send(guild.startPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "choice":
|
|
||||||
res.send(guild.addChoiceToPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "stop":
|
|
||||||
res.send(guild.endPoll());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.*;
|
|
||||||
import dataStructures.*;
|
|
||||||
|
|
||||||
public class CommandPollShow extends Command
|
|
||||||
{
|
|
||||||
public CommandPollShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("PollShowInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
if(!guild.polling)
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("PollShowNoPoll"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
|
||||||
poll += LocStrings.stub("PollShowChoices");
|
|
||||||
for(int i = 0; i < guild.choices.size(); i++)
|
|
||||||
{
|
|
||||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
res.send(poll);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.*;
|
|
||||||
import dataStructures.*;
|
|
||||||
|
|
||||||
public class CommandPollVote extends Command
|
|
||||||
{
|
|
||||||
public CommandPollVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("PollVoteInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
if(guild.polling)
|
|
||||||
{
|
|
||||||
if(guild.hasVoted.contains(user.uniqueID))
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("PollVoteAlreadyVoted"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int voteNum = Integer.parseInt(input.args)-1;
|
|
||||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
|
||||||
{
|
|
||||||
res.send(String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KittyPoll polled = guild.choices.get(voteNum);
|
|
||||||
polled.votes++;
|
|
||||||
guild.hasVoted.add(user.uniqueID);
|
|
||||||
res.send(LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("PollVoteNotValidNumber"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res.send(LocStrings.stub("PollVoteNoPoll"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.Command;
|
|
||||||
import core.LocStrings;
|
|
||||||
import dataStructures.KittyChannel;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRaffleEnd extends Command
|
|
||||||
{
|
|
||||||
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("RaffleEndInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
if(guild.endRaffle())
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleEndSuccess"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleEndFailure"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.Command;
|
|
||||||
import core.LocStrings;
|
|
||||||
import dataStructures.KittyChannel;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRaffleJoin extends Command
|
|
||||||
{
|
|
||||||
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("RaffleJoinInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
if(guild.joinRaffle(user))
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleJoinSuccess"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleJoinFailure"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.Command;
|
|
||||||
import core.LocStrings;
|
|
||||||
import dataStructures.KittyChannel;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRaffleSpin extends Command
|
|
||||||
{
|
|
||||||
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("RaffleSpinInfo"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
res.send(String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleSpinFailure"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package commands.general;
|
|
||||||
|
|
||||||
import core.Command;
|
|
||||||
import core.LocStrings;
|
|
||||||
import dataStructures.KittyChannel;
|
|
||||||
import dataStructures.KittyGuild;
|
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRaffleStart extends Command
|
|
||||||
{
|
|
||||||
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpText() { return LocStrings.stub("RaffleStartInfo"); }
|
|
||||||
|
|
||||||
public int beanCost;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
beanCost = Integer.parseInt(input.args);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
beanCost = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(guild.startRaffle(beanCost))
|
|
||||||
{
|
|
||||||
res.send(String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res.send(LocStrings.stub("RaffleStartFailure"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
package commands.general;
|
package commands.general;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import core.*;
|
import core.Command;
|
||||||
import dataStructures.KittyChannel;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.*;
|
||||||
import dataStructures.KittyRating;
|
|
||||||
import dataStructures.KittyRole;
|
|
||||||
import dataStructures.KittyUser;
|
|
||||||
import dataStructures.Response;
|
|
||||||
import dataStructures.UserInput;
|
|
||||||
|
|
||||||
public class CommandRoll extends Command
|
public class CommandRoll extends Command
|
||||||
{
|
{
|
||||||
@@ -23,7 +20,15 @@ public class CommandRoll extends Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
res.send(rollDice(input.args));
|
KittyEmbed embed = new KittyEmbed();
|
||||||
|
embed.title = user.name +"'s roll!";
|
||||||
|
embed.descriptionText = rollDice(input.args);
|
||||||
|
Random numGen = new Random(user.name.hashCode());
|
||||||
|
float hue = numGen.nextFloat();
|
||||||
|
float sat = .7f;
|
||||||
|
float bright = .7f;
|
||||||
|
embed.color = Color.getHSBColor(hue, sat, bright);
|
||||||
|
res.send(embed);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@@ -35,6 +40,7 @@ public class CommandRoll extends Command
|
|||||||
{
|
{
|
||||||
Stack<Integer> values = new Stack<Integer>();
|
Stack<Integer> values = new Stack<Integer>();
|
||||||
Stack<Character> operators = new Stack<Character>();
|
Stack<Character> operators = new Stack<Character>();
|
||||||
|
String steps = "";
|
||||||
for(int i = 0; i < thing.length(); i ++)
|
for(int i = 0; i < thing.length(); i ++)
|
||||||
{
|
{
|
||||||
char current = thing.charAt(i);
|
char current = thing.charAt(i);
|
||||||
@@ -49,7 +55,7 @@ public class CommandRoll extends Command
|
|||||||
operators.add(current);
|
operators.add(current);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
calculate(values, operators);
|
steps += "\n" + calculate(values, operators);
|
||||||
operators.add(current);
|
operators.add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +71,7 @@ public class CommandRoll extends Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
i --;
|
i --;
|
||||||
calculate(values, operators);
|
steps += "\n" + calculate(values, operators);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -73,7 +79,7 @@ public class CommandRoll extends Command
|
|||||||
if(operators.isEmpty() || operators.peek() == '(' || !hasPrecendence(operators.peek(), current))
|
if(operators.isEmpty() || operators.peek() == '(' || !hasPrecendence(operators.peek(), current))
|
||||||
operators.add(current);
|
operators.add(current);
|
||||||
else
|
else
|
||||||
calculate(values, operators);
|
steps += "\n" + calculate(values, operators);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
@@ -114,19 +120,22 @@ public class CommandRoll extends Command
|
|||||||
|
|
||||||
while(operators.size() > 0)
|
while(operators.size() > 0)
|
||||||
{
|
{
|
||||||
calculate(values, operators);
|
steps += "\n" + calculate(values, operators);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "" + values.pop();
|
return "Roll```" + thing + "```" + "Steps```" + steps + "```" + "Final value ```" + values.pop() +"```";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculate(Stack<Integer> nums, Stack<Character> operators)
|
|
||||||
|
private String calculate(Stack<Integer> nums, Stack<Character> operators)
|
||||||
{
|
{
|
||||||
int second = nums.pop();
|
int second = nums.pop();
|
||||||
int first = nums.pop();
|
int first = nums.pop();
|
||||||
|
int rolls[] = null;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
char op = operators.pop();
|
||||||
|
|
||||||
switch(operators.pop())
|
switch(op)
|
||||||
{
|
{
|
||||||
case '+':
|
case '+':
|
||||||
value = first + second;
|
value = first + second;
|
||||||
@@ -141,27 +150,39 @@ public class CommandRoll extends Command
|
|||||||
value = first / second;
|
value = first / second;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
value = roll(first, second);
|
rolls = roll(first, second);
|
||||||
|
for(int i= 0; i < first; i++)
|
||||||
|
{
|
||||||
|
value += rolls[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
nums.add(value);
|
nums.add(value);
|
||||||
|
if(rolls == null)
|
||||||
|
return (first + "" + op + "" + second + "=" + value);
|
||||||
|
String rollValues = "";
|
||||||
|
for(int i= 0; i < first; i++)
|
||||||
|
{
|
||||||
|
rollValues += "\uD83C\uDFB2" + rolls[i] + " ";
|
||||||
|
}
|
||||||
|
return (first + "" + op + "" + second + "=" + value + "(" + rollValues.trim() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int roll(int first, int second)
|
private int[] roll(int first, int second)
|
||||||
{
|
{
|
||||||
int total = 0;
|
|
||||||
int roll = 0;
|
int roll = 0;
|
||||||
int dice = first;
|
int dice = first;
|
||||||
int sides = second;
|
int sides = second;
|
||||||
|
int [] rolls = new int [sides];
|
||||||
|
|
||||||
if(dice < 1)
|
if(dice < 1)
|
||||||
return 0;
|
return new int[0];
|
||||||
for(int i = 0; dice > i; i ++)
|
for(int i = 0; dice > i; i ++)
|
||||||
{
|
{
|
||||||
roll = (int)(Math.random() * sides) + 1;
|
roll = (int)(Math.random() * sides) + 1;
|
||||||
total += roll;
|
rolls[i] = roll;
|
||||||
}
|
}
|
||||||
return total;
|
return rolls;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPrecendence(char op1, char op2)
|
private boolean hasPrecendence(char op1, char op2)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class CommandGuildRoleMain extends Command
|
|||||||
super(level, rating);
|
super(level, rating);
|
||||||
framework.addCommand("add", new SubCommandAdd (KittyRole.General, KittyRating.Safe));
|
framework.addCommand("add", new SubCommandAdd (KittyRole.General, KittyRating.Safe));
|
||||||
framework.addCommand("remove", new SubCommandRemove(KittyRole.General, KittyRating.Safe));
|
framework.addCommand("remove", new SubCommandRemove(KittyRole.General, KittyRating.Safe));
|
||||||
|
framework.addCommand("list", new SubCommandList(KittyRole.General, KittyRating.Safe));
|
||||||
framework.addCommand("allowed", new SubCommandAllowed(KittyRole.Admin, KittyRating.Safe));
|
framework.addCommand("allowed", new SubCommandAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||||
framework.addCommand("unallowed", new SubCommandNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
framework.addCommand("unallowed", new SubCommandNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||||
}
|
}
|
||||||
@@ -26,12 +27,9 @@ public class CommandGuildRoleMain extends Command
|
|||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("GuildRoleInfo"); }
|
public String getHelpText() { return LocStrings.stub("GuildRoleInfo"); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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.run(guild, channel, user, input.args).Call(res);
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,30 +7,38 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandAdd extends SubCommand
|
public class SubCommandAdd extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandAdd(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandAdd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
String role = input.split(" ")[0];
|
String [] roles = input.args.split(",");
|
||||||
|
String role;
|
||||||
|
String formatted = "";
|
||||||
|
for(int i = 0; i < roles.length; i++)
|
||||||
|
{
|
||||||
|
role = roles[i].trim();
|
||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
if(guild.control.addRole(user.discordID, role))
|
if(guild.control.addRole(user.discordID, role))
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable("ADDED RIN YOU NEED TO FIX THIS");
|
formatted += "Addded " + role + "!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable("FAILED RIN YOU NEED TO FIX THIS TOO");
|
formatted += "Failed to add " + role + "!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable("NOT ALLOWED FIX THIS ONE TOO SNEP FACE");
|
formatted += "You're not allowed to add " + role + "!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new SubCommandFormattable(formatted);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,15 +8,16 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandAllowed extends SubCommand
|
public class SubCommandAllowed extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
String [] roles = input.split(",");
|
String [] roles = input.args.split(",");
|
||||||
String role;
|
String role;
|
||||||
String formatted = "";
|
String formatted = "";
|
||||||
for(int i = 0; i < roles.length; i++)
|
for(int i = 0; i < roles.length; i++)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandList extends SubCommand
|
public class SubCommandList extends SubCommand
|
||||||
{
|
{
|
||||||
@@ -15,7 +16,7 @@ public class SubCommandList extends SubCommand
|
|||||||
public SubCommandList(KittyRole level, KittyRating rating) { super(level, rating);}
|
public SubCommandList(KittyRole level, KittyRating rating) { super(level, rating);}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
String roles = "";
|
String roles = "";
|
||||||
if(guild.roleList.isEmpty())
|
if(guild.roleList.isEmpty())
|
||||||
|
|||||||
@@ -8,28 +8,36 @@ import dataStructures.KittyGuild;
|
|||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class SubCommandNotAllowed extends SubCommand
|
public class SubCommandNotAllowed extends SubCommand
|
||||||
{
|
{
|
||||||
public SubCommandNotAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandNotAllowed(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
input = input.toLowerCase();
|
String lowerInput = input.args.toLowerCase();
|
||||||
String [] roles = input.split(",");
|
String [] roles = lowerInput.split(",");
|
||||||
|
String formatted = "";
|
||||||
|
|
||||||
|
if(roles.length < 1)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedNoArgs")));
|
||||||
|
}
|
||||||
|
|
||||||
for(String role:roles)
|
for(String role:roles)
|
||||||
{
|
{
|
||||||
if(guild.roleList.contains(role.trim()))
|
if(guild.roleList.contains(role.trim()))
|
||||||
{
|
{
|
||||||
guild.roleList.remove(role);
|
guild.roleList.remove(role);
|
||||||
return new SubCommandFormattable(LocStrings.stub("GuildRoleNotAllowedSuccess"));
|
formatted += String.format(LocStrings.stub("GuildRoleNotAllowedSuccess"), role);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedFailure"), role));
|
formatted += String.format(LocStrings.stub("GuildRoleNotAllowedFailure"), role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleNotAllowedNoArgs")));
|
return new SubCommandFormattable(formatted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,9 @@ public class SubCommandRemove extends SubCommand
|
|||||||
public SubCommandRemove(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandRemove(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
String role = input.split(" ")[0];
|
String role = input.args.split(" ")[0];
|
||||||
String formatted = "";
|
String formatted = "";
|
||||||
if(guild.roleList.contains(role))
|
if(guild.roleList.contains(role))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package commands.mod;
|
||||||
|
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommandFramework;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.Response;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class CommandModMain extends Command
|
||||||
|
{
|
||||||
|
SubCommandFramework framework = new SubCommandFramework();
|
||||||
|
public CommandModMain(KittyRole level, KittyRating rating)
|
||||||
|
{
|
||||||
|
super(level, rating);
|
||||||
|
framework.addCommand("kick", new SubCommandKick(KittyRole.Admin, KittyRating.Safe));
|
||||||
|
framework.addCommand("mute", new SubCommandMute(KittyRole.Admin, KittyRating.Safe));
|
||||||
|
framework.addCommand("ban", new SubCommandBan(KittyRole.Admin, KittyRating.Safe));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("GuildRoleInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package commands.mod;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandBan extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandBan(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable(guild.control.banMember(input.mentions[0].discordID) + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package commands.mod;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandKick extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandKick(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
if(guild.control.kickMember(input.mentions[0].discordID))
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable("Success");
|
||||||
|
}
|
||||||
|
return new SubCommandFormattable("Fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package commands.mod;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandMute extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandMute(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable("" + guild.control.muteMember(input.mentions[0].avatarID));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package commands.music;
|
||||||
|
|
||||||
|
import core.Command;
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommandFramework;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandMusicMain extends Command
|
||||||
|
{
|
||||||
|
SubCommandFramework framework = new SubCommandFramework();
|
||||||
|
public CommandMusicMain(KittyRole level, KittyRating rating)
|
||||||
|
{
|
||||||
|
super(level, rating);
|
||||||
|
framework.addCommand("join", new SubCommandJoin(KittyRole.General, KittyRating.Safe));
|
||||||
|
framework.addCommand("leave", new SubCommandLeave(KittyRole.General, KittyRating.Safe));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelpText() { return LocStrings.stub("MusicInfo"); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package commands.music;
|
||||||
|
|
||||||
|
import com.google.api.services.youtube.YouTube;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandAddTrack extends SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public SubCommandAddTrack(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package commands.music;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandJoin extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable("" + guild.audio.joinChannel(input.args));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package commands.music;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandLeave extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandLeave(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable("" + guild.audio.leaveChannel());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.Command;
|
||||||
|
import core.SubCommandFramework;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.Response;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class CommandPollMain extends Command
|
||||||
|
{
|
||||||
|
SubCommandFramework framework = new SubCommandFramework();
|
||||||
|
public CommandPollMain(KittyRole level, KittyRating rating)
|
||||||
|
{
|
||||||
|
super(level, rating);
|
||||||
|
|
||||||
|
framework.addCommand("start", new SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
framework.addCommand("addoption", new SubCommandAddOption(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
|
||||||
|
framework.addCommand("show", new SubCommandShow(KittyRole.General, KittyRating.Safe));
|
||||||
|
framework.addCommand("results", new SubCommandResults(KittyRole.General, KittyRating.Safe));
|
||||||
|
framework.addCommand("vote", new SubCommandVote(KittyRole.General, KittyRating.Safe));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandAddOption extends SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public SubCommandAddOption(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating);}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (guild.addChoiceToPoll(input.args));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandEnd extends SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public SubCommandEnd(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (guild.endPoll());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+6
-9
@@ -1,19 +1,16 @@
|
|||||||
package commands.general;
|
package commands.poll;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import core.*;
|
import core.*;
|
||||||
import dataStructures.*;
|
import dataStructures.*;
|
||||||
|
|
||||||
public class CommandPollResults extends Command
|
public class SubCommandResults extends SubCommand
|
||||||
{
|
{
|
||||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
public SubCommandResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("PollResultsInfo"); }
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
|
||||||
@Override
|
|
||||||
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 +25,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)) + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send(results);
|
return new SubCommandFormattable (results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandShow extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
if(!guild.polling)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("PollShowNoPoll"));
|
||||||
|
}
|
||||||
|
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||||
|
poll += LocStrings.stub("PollShowChoices");
|
||||||
|
for(int i = 0; i < guild.choices.size(); i++)
|
||||||
|
{
|
||||||
|
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubCommandFormattable (poll);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandStart extends SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public SubCommandStart(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (guild.startPoll(input.args));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package commands.poll;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyPoll;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandVote extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
if(guild.polling)
|
||||||
|
{
|
||||||
|
if(guild.hasVoted.contains(user.uniqueID))
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("PollVoteAlreadyVoted"));
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int voteNum = Integer.parseInt(input.args.substring(input.args.indexOf(" ")).trim())-1;
|
||||||
|
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
KittyPoll polled = guild.choices.get(voteNum);
|
||||||
|
polled.votes++;
|
||||||
|
guild.hasVoted.add(user.uniqueID);
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("PollVoteNotValidNumber"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("PollVoteNoPoll"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package commands.raffle;
|
||||||
|
|
||||||
|
import core.Command;
|
||||||
|
import core.SubCommandFramework;
|
||||||
|
import dataStructures.*;
|
||||||
|
|
||||||
|
public class CommandRaffleMain extends Command
|
||||||
|
{
|
||||||
|
SubCommandFramework framework = new SubCommandFramework();
|
||||||
|
public CommandRaffleMain(KittyRole level, KittyRating rating)
|
||||||
|
{
|
||||||
|
super(level, rating);
|
||||||
|
framework.addCommand("start", new SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
framework.addCommand("spin", new SubCommandSpin(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||||
|
framework.addCommand("join", new SubCommandJoin(KittyRole.General, KittyRating.Safe));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
|
{
|
||||||
|
framework.run(guild, channel, user, input).Call(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package commands.raffle;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandEnd extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
if(guild.endRaffle())
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleEndSuccess"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleEndFailure"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package commands.raffle;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandJoin extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
if(guild.joinRaffle(user))
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleJoinSuccess"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleJoinFailure"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package commands.raffle;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandSpin extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleSpinFailure"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package commands.raffle;
|
||||||
|
|
||||||
|
import core.LocStrings;
|
||||||
|
import core.SubCommand;
|
||||||
|
import core.SubCommandFormattable;
|
||||||
|
import dataStructures.KittyChannel;
|
||||||
|
import dataStructures.KittyGuild;
|
||||||
|
import dataStructures.KittyRating;
|
||||||
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
|
public class SubCommandStart extends SubCommand
|
||||||
|
{
|
||||||
|
public SubCommandStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
|
public int beanCost;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
beanCost = Integer.parseInt(input.args);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
beanCost = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guild.startRaffle(beanCost))
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable (LocStrings.stub("RaffleStartFailure"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,56 @@
|
|||||||
package core;
|
package core;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import commands.characters.CommandCharacterMain;
|
import commands.characters.CommandCharacterMain;
|
||||||
import commands.general.*;
|
import commands.general.CommandBeansShow;
|
||||||
|
import commands.general.CommandBenchmark;
|
||||||
|
import commands.general.CommandBetBeans;
|
||||||
|
import commands.general.CommandBetHistory;
|
||||||
|
import commands.general.CommandBlurry;
|
||||||
|
import commands.general.CommandBoop;
|
||||||
|
import commands.general.CommandCatch;
|
||||||
|
import commands.general.CommandChangeIndicator;
|
||||||
|
import commands.general.CommandChoose;
|
||||||
|
import commands.general.CommandColiru;
|
||||||
|
import commands.general.CommandColor;
|
||||||
|
import commands.general.CommandCrouton;
|
||||||
|
import commands.general.CommandDBFlush;
|
||||||
|
import commands.general.CommandDBStats;
|
||||||
|
import commands.general.CommandDoWork;
|
||||||
|
import commands.general.CommandEightBall;
|
||||||
|
import commands.general.CommandFetch;
|
||||||
|
import commands.general.CommandGiveBeans;
|
||||||
|
import commands.general.CommandHelp;
|
||||||
|
import commands.general.CommandHelpBuilder;
|
||||||
|
import commands.general.CommandInfo;
|
||||||
|
import commands.general.CommandInvite;
|
||||||
|
import commands.general.CommandJDoodle;
|
||||||
|
import commands.general.CommandLeaderboard;
|
||||||
|
import commands.general.CommandMap;
|
||||||
|
import commands.general.CommandPerish;
|
||||||
|
import commands.general.CommandPing;
|
||||||
|
import commands.general.CommandRPEnd;
|
||||||
|
import commands.general.CommandRPG;
|
||||||
|
import commands.general.CommandRPStart;
|
||||||
|
import commands.general.CommandRating;
|
||||||
|
import commands.general.CommandRemind;
|
||||||
|
import commands.general.CommandRole;
|
||||||
|
import commands.general.CommandRoll;
|
||||||
|
import commands.general.CommandShutdown;
|
||||||
|
import commands.general.CommandStark;
|
||||||
|
import commands.general.CommandStats;
|
||||||
|
import commands.general.CommandTeey;
|
||||||
|
import commands.general.CommandTweet;
|
||||||
|
import commands.general.CommandWolfram;
|
||||||
|
import commands.general.CommandYeet;
|
||||||
import commands.guildrole.CommandGuildRoleMain;
|
import commands.guildrole.CommandGuildRoleMain;
|
||||||
|
import commands.mod.CommandModMain;
|
||||||
|
import commands.music.CommandMusicMain;
|
||||||
|
import commands.poll.CommandPollMain;
|
||||||
|
import commands.raffle.CommandRaffleMain;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
@@ -70,12 +115,9 @@ public class CommandManager
|
|||||||
this.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
this.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
||||||
|
|
||||||
// Mod
|
// Mod
|
||||||
this.register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
this.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
this.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
this.register(LocCommands.stub("mod"), new CommandModMain(KittyRole.Mod, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
|
||||||
|
|
||||||
// General
|
// General
|
||||||
this.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
|
||||||
@@ -88,9 +130,6 @@ public class CommandManager
|
|||||||
this.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
||||||
@@ -107,12 +146,14 @@ public class CommandManager
|
|||||||
this.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
|
|
||||||
this.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("remind"), new CommandRemind(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("remind"), new CommandRemind(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("role"), new CommandGuildRoleMain(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("role"), new CommandGuildRoleMain(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("character"), new CommandCharacterMain(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("character"), new CommandCharacterMain(KittyRole.General, KittyRating.Safe));
|
||||||
|
this.register(LocCommands.stub("raffle"), new CommandRaffleMain(KittyRole.General, KittyRating.Safe));
|
||||||
|
this.register(LocCommands.stub("poll"), new CommandPollMain(KittyRole.General, KittyRating.Safe));
|
||||||
|
this.register(LocCommands.stub("music"), new CommandMusicMain(KittyRole.General, KittyRating.Safe));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import java.util.concurrent.Semaphore;
|
|||||||
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
|
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
|
||||||
|
|
||||||
import core.lua.PluginManager;
|
import core.lua.PluginManager;
|
||||||
import dataStructures.*;
|
import dataStructures.*;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
@@ -17,6 +20,7 @@ import net.dv8tion.jda.core.entities.*;
|
|||||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import offline.Ref;
|
import offline.Ref;
|
||||||
import utils.AdminControl;
|
import utils.AdminControl;
|
||||||
|
import utils.AudioUtils;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
import utils.LogFilter;
|
import utils.LogFilter;
|
||||||
|
|
||||||
@@ -50,6 +54,9 @@ public class ObjectBuilderFactory
|
|||||||
// Command manager
|
// Command manager
|
||||||
private static CommandManager commandManager;
|
private static CommandManager commandManager;
|
||||||
|
|
||||||
|
//Audio track manager
|
||||||
|
private static AudioPlayerManager audioPlayer = new DefaultAudioPlayerManager();
|
||||||
|
|
||||||
// Localization classes - these are singletons, but should be initialized before almost all other
|
// Localization classes - these are singletons, but should be initialized before almost all other
|
||||||
// things so their inclusion in the factory is to ensure they're started at the correct time.
|
// things so their inclusion in the factory is to ensure they're started at the correct time.
|
||||||
@SuppressWarnings("unused") private static LocStrings locStrings;
|
@SuppressWarnings("unused") private static LocStrings locStrings;
|
||||||
@@ -140,7 +147,8 @@ public class ObjectBuilderFactory
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Construct a new guild with defaults
|
// Construct a new guild with defaults
|
||||||
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString);
|
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString,
|
||||||
|
new AudioUtils(event.getGuild(), audioPlayer.createPlayer()));
|
||||||
DatabaseManager.instance.globalRegister(guild);
|
DatabaseManager.instance.globalRegister(guild);
|
||||||
guildCache.put(uid, guild);
|
guildCache.put(uid, guild);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ public abstract class SubCommand
|
|||||||
|
|
||||||
// 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, String input)
|
protected final SubCommandFormattable Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
if(!CanCall(guild, channel, user))
|
if(!CanCall(guild, channel, user))
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
OnRun(guild, channel, user, input);
|
return OnRun(guild, channel, user, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KittyRating Rating()
|
public KittyRating Rating()
|
||||||
@@ -60,5 +60,5 @@ public abstract class SubCommand
|
|||||||
return roleLevel;
|
return roleLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input);
|
public abstract SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input);
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
|
import dataStructures.UserInput;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
|
|
||||||
public class SubCommandFramework
|
public class SubCommandFramework
|
||||||
@@ -25,10 +26,22 @@ public class SubCommandFramework
|
|||||||
GlobalLog.log("Registered SubCommand " + name);
|
GlobalLog.log("Registered SubCommand " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubCommandFormattable run(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
public SubCommandFormattable run(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||||
{
|
{
|
||||||
System.out.print(input);
|
SubCommand res = commands.get(input.args.split(" ")[0].toLowerCase());
|
||||||
SubCommandFormattable res = commands.get(input.split(" ")[0].toLowerCase()).OnRun(guild, channel, user, input.substring(input.indexOf(" ")));
|
try
|
||||||
return res;
|
{
|
||||||
|
input.args = input.args.substring(input.args.indexOf(' ')).trim();
|
||||||
|
}
|
||||||
|
catch(Exception e){}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return res.Invoke(guild, channel, user, input);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return new SubCommandFormattable("That's not a valid subcommand!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import core.DatabaseManager;
|
import core.DatabaseManager;
|
||||||
import core.DatabaseTrackedObject;
|
import core.DatabaseTrackedObject;
|
||||||
import utils.AdminControl;
|
import utils.AdminControl;
|
||||||
|
import utils.AudioUtils;
|
||||||
|
|
||||||
// Context for a given guild for kittybot. Primarily designed to hold guild-specific settings.
|
// Context for a given guild for kittybot. Primarily designed to hold guild-specific settings.
|
||||||
public class KittyGuild extends DatabaseTrackedObject
|
public class KittyGuild extends DatabaseTrackedObject
|
||||||
@@ -21,6 +22,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
|||||||
public ArrayList<String> emoji = new ArrayList<String>();
|
public ArrayList<String> emoji = new ArrayList<String>();
|
||||||
public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>();
|
public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>();
|
||||||
public AdminControl control;
|
public AdminControl control;
|
||||||
|
public AudioUtils audio;
|
||||||
public ArrayList <KittyUser> raffleUsersUnchosen = new ArrayList<KittyUser>();
|
public ArrayList <KittyUser> raffleUsersUnchosen = new ArrayList<KittyUser>();
|
||||||
public ArrayList <KittyUser> raffleUsersChosen = new ArrayList<KittyUser>();
|
public ArrayList <KittyUser> raffleUsersChosen = new ArrayList<KittyUser>();
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default content for a guild
|
// Default content for a guild
|
||||||
public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji)
|
public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji, AudioUtils audio)
|
||||||
{
|
{
|
||||||
super(uniqueID);
|
super(uniqueID);
|
||||||
this.uniqueID = uniqueID;
|
this.uniqueID = uniqueID;
|
||||||
@@ -52,6 +54,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
|||||||
this.contentRating = KittyRating.Safe;
|
this.contentRating = KittyRating.Safe;
|
||||||
this.polling = false;
|
this.polling = false;
|
||||||
this.emoji = emoji;
|
this.emoji = emoji;
|
||||||
|
this.audio = audio;
|
||||||
setCommandIndicator("!");
|
setCommandIndicator("!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package network;
|
||||||
|
|
||||||
|
import com.google.api.services.youtube.YouTube;
|
||||||
|
|
||||||
|
import offline.Ref;
|
||||||
|
|
||||||
|
public class NetworkYoutube
|
||||||
|
{
|
||||||
|
private static YouTube youtube;
|
||||||
|
|
||||||
|
public NetworkYoutube()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,4 +39,43 @@ public class AdminControl
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean kickMember(String memberID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
guildCon.kick(guild.getMemberById(memberID)).complete();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean muteMember(String memberID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
guildCon.setMute(guild.getMemberById(memberID), true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean banMember(String memberID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
guildCon.ban(guild.getMemberById(memberID), 0).complete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package utils;
|
||||||
|
/***
|
||||||
|
* https://developers.google.com/youtube/v3/code_samples/code_snippets?apix_params=%7B%22part%22%3A%22snippet%22%2C%22maxResults%22%3A25%2C%22q%22%3A%22surfing%22%7D
|
||||||
|
* https://github.com/sedmelluq/LavaPlayer#jda-integration
|
||||||
|
* https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/core/entities/VoiceChannel.html
|
||||||
|
* https://developers.google.com/youtube/registering_an_application#Create_API_Keys
|
||||||
|
*/
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.core.entities.Guild;
|
||||||
|
import net.dv8tion.jda.core.entities.VoiceChannel;
|
||||||
|
import net.dv8tion.jda.core.managers.AudioManager;
|
||||||
|
|
||||||
|
public class AudioUtils
|
||||||
|
{
|
||||||
|
private Guild guild;
|
||||||
|
AudioManager audio;
|
||||||
|
AudioPlayer player;
|
||||||
|
|
||||||
|
|
||||||
|
public AudioUtils(Guild guild)
|
||||||
|
{
|
||||||
|
this.guild = guild;
|
||||||
|
audio = guild.getAudioManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean joinChannel(String channelName)
|
||||||
|
{
|
||||||
|
VoiceChannel channel = null;
|
||||||
|
channel = guild.getVoiceChannelsByName(channelName, true).get(0);
|
||||||
|
if(channel != null)
|
||||||
|
{
|
||||||
|
audio.openAudioConnection(channel);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean leaveChannel()
|
||||||
|
{
|
||||||
|
if(audio.isConnected())
|
||||||
|
{
|
||||||
|
audio.closeAudioConnection();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user