Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,8 +1,23 @@
|
||||
package commands.general;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import core.Command;
|
||||
import core.Constants;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandBeansShow extends Command
|
||||
{
|
||||
@@ -15,7 +30,15 @@ public class CommandBeansShow extends Command
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(input.mentions == null)
|
||||
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
|
||||
{
|
||||
res.send("" + user.getBeans());
|
||||
try {
|
||||
res.sendFile(combineImages(user.getBeans()), "png");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
|
||||
}
|
||||
else
|
||||
{
|
||||
String mentionedBeans = "";
|
||||
@@ -26,4 +49,75 @@ public class CommandBeansShow extends Command
|
||||
res.send(String.format(LocStrings.stub("BeansShowMentioned"), mentionedBeans));
|
||||
}
|
||||
}
|
||||
|
||||
private File combineImages(long beans) throws IOException
|
||||
{
|
||||
// Acquire images
|
||||
BufferedImage imageBase = ImageIO.read(new File(Constants.AssetDirectory + "beans/BeansBG.png"));
|
||||
BufferedImage thouBean = ImageIO.read(new File(Constants.AssetDirectory + "beans/thouBean.png"));
|
||||
BufferedImage hunBean = ImageIO.read(new File(Constants.AssetDirectory + "beans/hunBean.png"));
|
||||
BufferedImage tenBean = ImageIO.read(new File(Constants.AssetDirectory + "beans/tenBean.png"));
|
||||
BufferedImage oneBean = ImageIO.read(new File(Constants.AssetDirectory + "beans/oneBean.png"));
|
||||
|
||||
final int baseWidth = imageBase.getWidth();
|
||||
final int baseHeight = imageBase.getHeight();
|
||||
|
||||
long calcBean = beans;
|
||||
|
||||
System.out.println("BEANS: " + beans);
|
||||
|
||||
long thousands = beans / 1000;
|
||||
calcBean = beans % 1000;
|
||||
long hundreds = (calcBean / 100);
|
||||
calcBean = calcBean % 100;
|
||||
long tens = (calcBean / 10);
|
||||
calcBean = calcBean % 10;
|
||||
long ones = calcBean;
|
||||
|
||||
BufferedImage beanImage = new BufferedImage(baseWidth, baseHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics beanGraphics = beanImage.getGraphics();
|
||||
|
||||
for(int i = 0; i < ones; i++)
|
||||
{
|
||||
int x = (int)(Math.random() * (baseWidth - oneBean.getWidth())) + 1;
|
||||
int y = (int)(Math.random() * (baseHeight - oneBean.getHeight())) + 1;
|
||||
beanGraphics.drawImage(oneBean, x, y, null);
|
||||
}
|
||||
|
||||
for(int i = 0; i < tens; i++)
|
||||
{
|
||||
int x = (int)(Math.random() * (baseWidth - tenBean.getWidth())) + 1;
|
||||
int y = (int)(Math.random() * (baseHeight - tenBean.getHeight())) + 1;
|
||||
beanGraphics.drawImage(tenBean, x, y, null);
|
||||
}
|
||||
|
||||
for(int i = 0; i < hundreds; i++)
|
||||
{
|
||||
int x = (int)(Math.random() * (baseWidth - hunBean.getWidth())) + 1;
|
||||
int y = (int)(Math.random() * (baseHeight - hunBean.getHeight())) + 1;
|
||||
beanGraphics.drawImage(hunBean, x, y, null);
|
||||
}
|
||||
|
||||
for(int i = 0; i < thousands; i++)
|
||||
{
|
||||
int x = (int)(Math.random() * (baseWidth - thouBean.getWidth())) + 1;
|
||||
int y = (int)(Math.random() * (baseHeight - thouBean.getHeight())) + 1;
|
||||
beanGraphics.drawImage(thouBean, x, y, null);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
Font font = null;
|
||||
font = Font.createFont(Font.TRUETYPE_FONT, new File(Constants.AssetDirectory +"fonts/B612Mono-Regular.ttf"));
|
||||
} catch (Exception e)
|
||||
{
|
||||
}
|
||||
Font beanFont = new Font("font", Font.BOLD, 45);
|
||||
beanGraphics.setFont(beanFont);
|
||||
beanGraphics.drawString("YOU GOT " + beans + " BEANS", 0, baseHeight / 2);
|
||||
|
||||
ImageIO.write(beanImage, "PNG", new File("beanImage.png"));
|
||||
return new File("beanImage.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CommandColor extends Command
|
||||
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());
|
||||
ColorData colorData = theColorAPI.lookupHex(input.args);
|
||||
|
||||
// Verify the color was even found
|
||||
if(colorData == null)
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
package commands.general;
|
||||
|
||||
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.NetworkDerpi;
|
||||
|
||||
public class CommandDerpi extends Command
|
||||
{
|
||||
NetworkDerpi searcher = new NetworkDerpi();
|
||||
KittyEmbed response;
|
||||
|
||||
// Required constructor
|
||||
public CommandDerpi(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return "Will search derpibooru for the tags entered, if KittyBot's content filter allows it"; }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.contentRating == KittyRating.Filtered)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = searcher.getDerpi(input.args.replace(',', ' ') + " safe").output();
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
res.send("DerpiNoSearchError");
|
||||
else
|
||||
{
|
||||
response = searcher.getDerpi(input.args).output();
|
||||
try
|
||||
{
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(input.args.startsWith("ID:"))
|
||||
{
|
||||
response = searcher.getDerpiByID(input.args.substring(input.args.indexOf(':'))).output();
|
||||
try
|
||||
{
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
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.NetworkDerpi;
|
||||
|
||||
public class CommandDerpi extends Command
|
||||
{
|
||||
NetworkDerpi searcher = new NetworkDerpi();
|
||||
KittyEmbed response;
|
||||
|
||||
// Required constructor
|
||||
public CommandDerpi(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return "Will search derpibooru for the tags entered, if KittyBot's content filter allows it"; }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.contentRating == KittyRating.Filtered)
|
||||
{
|
||||
try
|
||||
{
|
||||
response = searcher.getDerpi(input.args.replace(',', ' ') + " safe").output();
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
res.send("DerpiNoSearchError");
|
||||
else
|
||||
{
|
||||
response = searcher.getDerpi(input.args).output();
|
||||
try
|
||||
{
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(input.args.startsWith("ID:"))
|
||||
{
|
||||
response = searcher.getDerpiByID(input.args.substring(input.args.indexOf(':'))).output();
|
||||
try
|
||||
{
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("DerpiError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +1,71 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
import network.NetworkE6;
|
||||
|
||||
public class CommandE6 extends Command
|
||||
{
|
||||
NetworkE6 searcher = new NetworkE6();
|
||||
KittyEmbed response;
|
||||
|
||||
public CommandE6(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText()
|
||||
{
|
||||
String toRet = "Will search e6";
|
||||
toRet += "21 for the tags entered, if KittyBot's content filter allows it";
|
||||
return toRet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.contentRating == KittyRating.Filtered || !guild.channels.get(Long.getLong(channel.uniqueID)).mature)
|
||||
{
|
||||
if(!guild.channels.get(Long.getLong(channel.uniqueID)).mature)
|
||||
{
|
||||
res.send("This channel is SFW only! Have some (probably) wholesome content ^^~");
|
||||
}
|
||||
response = searcher.getE6(input.args + " rating:safe").output();
|
||||
try
|
||||
{
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("E6Blacklisted"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
res.send("E6NoSearchError");
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
response = searcher.getE6(input.args).output();
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("E6Blacklisted"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
import network.NetworkE6;
|
||||
|
||||
public class CommandE6 extends Command
|
||||
{
|
||||
NetworkE6 searcher = new NetworkE6();
|
||||
KittyEmbed response;
|
||||
GenericImage image;
|
||||
|
||||
public CommandE6(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText()
|
||||
{
|
||||
String toRet = "Will search e6";
|
||||
toRet += "21 for the tags entered, if KittyBot's content filter allows it";
|
||||
return toRet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.contentRating == KittyRating.Filtered)
|
||||
{
|
||||
image = searcher.getE6(input.args + " rating:safe");
|
||||
try
|
||||
{
|
||||
response = image.output();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("E6Blacklisted"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if(response.bodyImageURL == null)
|
||||
{
|
||||
Exception e = new Exception();
|
||||
throw e;
|
||||
}
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("E6Blacklisted"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
res.send("E6NoSearchError");
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
response = searcher.getE6(input.args).output();
|
||||
res.send(response);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("E6Blacklisted"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user