Merge branch 'develop' into feature/dew
This commit is contained in:
@@ -5,6 +5,8 @@ import java.util.Random;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
public class CommandBetBeans extends Command
|
||||
{
|
||||
@@ -17,12 +19,30 @@ public class CommandBetBeans extends Command
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String call = "";
|
||||
|
||||
int min = 50;
|
||||
int bet = 0;
|
||||
int win = 0;
|
||||
|
||||
try
|
||||
{
|
||||
String valAsString = LocStrings.stub("BetBeansMinThreshold");
|
||||
int parsed = Integer.parseInt(valAsString);
|
||||
|
||||
if(parsed < 0)
|
||||
parsed = 0;
|
||||
|
||||
min = parsed;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GlobalLog.log(LogFilter.Command, "Betting took place, but a value was not specified in the config file so 50 was used as the minimum bet threshold. Consider specifying BetBeansMinThreshold.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
bet = Integer.parseInt(input.args);
|
||||
if(bet < 50)
|
||||
if(bet < min)
|
||||
{
|
||||
res.send(LocStrings.stub("BetBeansLowBet"));
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package commands.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
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;
|
||||
import utils.ImageOverlayBuilder;
|
||||
import utils.ImageUtils;
|
||||
|
||||
public class CommandDefaultDance extends Command
|
||||
{
|
||||
// Required constructor
|
||||
public CommandDefaultDance(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
private static Long num = 0l;
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("DefaultDanceInfo"); }
|
||||
|
||||
// Called when the command is run!
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String name = null;
|
||||
File dancerFile = null;
|
||||
File danceeFile = null;
|
||||
|
||||
synchronized(num)
|
||||
{
|
||||
name = "defaultDance_" + num + ".gif";
|
||||
++num;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
KittyUser person = null;
|
||||
|
||||
if(input.mentions == null)
|
||||
person = user;
|
||||
else
|
||||
person = input.mentions[0];
|
||||
|
||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||
if(yeeteeFilename == null)
|
||||
return;
|
||||
|
||||
danceeFile = new File(yeeteeFilename);
|
||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/dance/default/", "defaultDance ", 118, 18);
|
||||
builder.overlay(ImageIO.read(danceeFile), name);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dancerFile = new File (name);
|
||||
res.sendFile(dancerFile, "gif");
|
||||
|
||||
// Thread cleanup...
|
||||
ImageUtils.blockingFileDelete(dancerFile);
|
||||
ImageUtils.blockingFileDelete(danceeFile);
|
||||
}
|
||||
}
|
||||
@@ -49,15 +49,25 @@ public class CommandLeaderboard extends Command
|
||||
if(userID.length() < 1)
|
||||
continue;
|
||||
|
||||
// Look up in the database the user beans
|
||||
String dbUserData = DatabaseManager.instance.globalGetRemoteValue(guildID + userID);
|
||||
String dbUserData = null;
|
||||
Long parsedBeans = null;
|
||||
|
||||
// Leverage the fact that the user is automatically read and parsed when constructed.
|
||||
Long parsedBeans = KittyUser.parseBeans(KittyUser.prepareFromString(dbUserData));
|
||||
|
||||
// If we were only using cached users, we would use this. However, we're not.
|
||||
// KittyUser cachedUser = ObjectBuilderFactory.getCachedUser(guildID, userID);
|
||||
users.add(new Pair<Long, String>(parsedBeans, userID));
|
||||
try
|
||||
{
|
||||
// Look up in the database the user beans
|
||||
dbUserData = DatabaseManager.instance.globalGetRemoteValue(guildID + userID);
|
||||
|
||||
// Leverage the fact that the user is automatically read and parsed when constructed.
|
||||
parsedBeans = KittyUser.parseBeans(KittyUser.prepareFromString(dbUserData));
|
||||
|
||||
// If we were only using cached users, we would use this. However, we're not.
|
||||
// KittyUser cachedUser = ObjectBuilderFactory.getCachedUser(guildID, userID);
|
||||
users.add(new Pair<Long, String>(parsedBeans, userID));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GlobalLog.error(LogFilter.Command, "Issue parsing for leaderboard,\ndbUserData:" + dbUserData + "\nparsedBeans:" + parsedBeans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,21 +22,21 @@ public class SubCommandAdd extends SubCommand
|
||||
String formatted = "";
|
||||
for(int i = 0; i < roles.length; i++)
|
||||
{
|
||||
role = roles[i].trim();
|
||||
role = roles[i].trim().toLowerCase();
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
if(guild.control.addRole(user.discordID, role))
|
||||
{
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddSuccess"), role, user.name);
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddSuccess"), role, user.name) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddFailure"), role, user.name);
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddFailure"), role, user.name) + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddNotAllowed"), role);
|
||||
formatted += String.format(LocStrings.stub("GuildRoleAddNotAllowed"), role) + "\n";
|
||||
}
|
||||
}
|
||||
return new SubCommandFormattable(formatted);
|
||||
|
||||
@@ -29,6 +29,6 @@ public class SubCommandList extends SubCommand
|
||||
roles += "\n";
|
||||
roles += guild.roleList.get(i);
|
||||
}
|
||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleListOutput"), roles));
|
||||
return new SubCommandFormattable(String.format(LocStrings.stub("GuildRoleListOutput") + "\n", roles));
|
||||
}
|
||||
}
|
||||
@@ -12,23 +12,29 @@ public class SubCommandRemove extends SubCommand
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
String role = input.args.split(" ")[0];
|
||||
String [] roles = input.args.split(",");
|
||||
String role;
|
||||
String formatted = "";
|
||||
if(guild.roleList.contains(role))
|
||||
for(int i = 0; i < roles.length; i ++)
|
||||
{
|
||||
if(guild.control.removeRole(user.discordID, role))
|
||||
role = roles[i].trim().toLowerCase();
|
||||
if(guild.roleList.contains(role))
|
||||
{
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveSuccess"), role, user.name));
|
||||
if(guild.control.removeRole(user.discordID, role))
|
||||
{
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveSuccess"), role, user.name)) + "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveFailure"), role, user.name)) + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveFailure"), role, user.name));
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveNotAllowed"), role)) + "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
formatted += (String.format(LocStrings.stub("GuildRoleRemoveNotAllowed"), role));
|
||||
}
|
||||
|
||||
|
||||
return new SubCommandFormattable(formatted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user