+ Added first-pass leaderboard command and all requirements
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package dataStructures;
|
||||
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
|
||||
public class KittyCore
|
||||
{
|
||||
public final JDA jda;
|
||||
|
||||
public KittyCore(JDA kitty)
|
||||
{
|
||||
this.jda = kitty;
|
||||
}
|
||||
}
|
||||
@@ -64,12 +64,27 @@ public class KittyUser extends DatabaseTrackedObject
|
||||
return beans + "," + role.getValue();
|
||||
}
|
||||
|
||||
public static String[] prepareFromString(String string)
|
||||
{
|
||||
return string.split(",");
|
||||
}
|
||||
|
||||
public static long parseBeans(String[] prepared)
|
||||
{
|
||||
return Integer.parseInt(prepared[0]);
|
||||
}
|
||||
|
||||
public static KittyRole parseRole(String[] prepared)
|
||||
{
|
||||
return KittyRole.valueOf(Integer.parseInt(prepared[1])).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeSerialzie(String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] strings = string.split(",");
|
||||
String[] strings = prepareFromString(string);
|
||||
if(strings.length < 2)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Database, "Upgrading user " + name + " to include 'role' in DB");
|
||||
@@ -80,14 +95,15 @@ public class KittyUser extends DatabaseTrackedObject
|
||||
}
|
||||
else
|
||||
{
|
||||
beans = Integer.parseInt(strings[0]);
|
||||
role = KittyRole.valueOf(Integer.parseInt(strings[1])).get();
|
||||
beans = parseBeans(strings);
|
||||
role = parseRole(strings);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
GlobalLog.Warn(LogFilter.Database, "Invalid user data for user " + name + "! "
|
||||
+ "Starting over at 0 beans with a general role!");
|
||||
|
||||
// We don't need to specify the role at this point because it is set at this point.
|
||||
// We use what the user was created with whatever defaults were in the factory.
|
||||
// Beans are maintained too, just in case there's some in cache.
|
||||
|
||||
@@ -2,6 +2,7 @@ package dataStructures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.*;
|
||||
@@ -16,15 +17,15 @@ public class Response
|
||||
{
|
||||
// Variables
|
||||
private GuildMessageReceivedEvent event;
|
||||
private JDA kitty;
|
||||
private final int discordMessageMax = 2000;
|
||||
private final int kittyMessageMax = 1950;
|
||||
private JDA kitty;
|
||||
|
||||
// Constructor
|
||||
public Response(GuildMessageReceivedEvent event, JDA kitty)
|
||||
public Response(GuildMessageReceivedEvent event, KittyCore kitty)
|
||||
{
|
||||
this.event = event;
|
||||
this.kitty = kitty;
|
||||
this.kitty = kitty.jda;
|
||||
}
|
||||
|
||||
// Builds a nicely formatted embedded message based on information provided
|
||||
|
||||
@@ -93,7 +93,7 @@ public class UserInput
|
||||
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
|
||||
for(int i = 0; i < KittyMentions.length; i ++)
|
||||
{
|
||||
KittyMentions [i] = ObjectBuilderFactory.getCachedUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId());
|
||||
KittyMentions [i] = ObjectBuilderFactory.getKittyUser(event.getGuild().getId(), JDAMentions.get(i).getUser().getId());
|
||||
}
|
||||
return KittyMentions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user