=More package sorting
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.beans;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.beans;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
+24
-24
@@ -1,25 +1,25 @@
|
|||||||
package commands.general;
|
package commands.beans;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class CommandBetHistory extends Command
|
public class CommandBetHistory extends Command
|
||||||
{
|
{
|
||||||
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandBetHistory(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
public String getHelpText() { return LocStrings.stub("BetHistoryInfo"); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get()));
|
res.send(String.format(LocStrings.stub("BetHistoryOutput"), guild.beans.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.beans;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.beans;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.Constants;
|
import core.Constants;
|
||||||
import core.DatabaseManager;
|
import core.DatabaseManager;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyEmbed;
|
import dataStructures.KittyEmbed;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class CommandDBFlush extends Command
|
public class CommandDBFlush extends Command
|
||||||
{
|
{
|
||||||
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandDBFlush(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
public String getHelpText() { return LocStrings.stub("DBFlushInfo"); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
int numUpdated = DatabaseManager.instance.upkeep();
|
int numUpdated = DatabaseManager.instance.upkeep();
|
||||||
|
|
||||||
KittyEmbed embed = new KittyEmbed();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.title = "Database queue flushed";
|
embed.title = "Database queue flushed";
|
||||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||||
embed.color = Constants.ColorDefault;
|
embed.color = Constants.ColorDefault;
|
||||||
|
|
||||||
res.send(embed);
|
res.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,43 +1,43 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.Constants;
|
import core.Constants;
|
||||||
import core.DatabaseManager;
|
import core.DatabaseManager;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyEmbed;
|
import dataStructures.KittyEmbed;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class CommandDBStats extends Command
|
public class CommandDBStats extends Command
|
||||||
{
|
{
|
||||||
DateFormat dateFormat;
|
DateFormat dateFormat;
|
||||||
public CommandDBStats(KittyRole level, KittyRating rating)
|
public CommandDBStats(KittyRole level, KittyRating rating)
|
||||||
{
|
{
|
||||||
super(level, rating);
|
super(level, rating);
|
||||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
public String getHelpText() { return LocStrings.stub("DBStatsInfo"); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
KittyEmbed embed = new KittyEmbed();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.title = "Database Info";
|
embed.title = "Database Info";
|
||||||
embed.descriptionText = "**Tracked Items:** " + DatabaseManager.instance.getTrackedObjectsSize();
|
embed.descriptionText = "**Tracked Items:** " + DatabaseManager.instance.getTrackedObjectsSize();
|
||||||
embed.descriptionText += "\n";
|
embed.descriptionText += "\n";
|
||||||
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.getLastUpkeep()) + " UTC-7";
|
||||||
embed.color = Constants.ColorDefault;
|
embed.color = Constants.ColorDefault;
|
||||||
|
|
||||||
res.send(embed);
|
res.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.*;
|
import core.*;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
|
|
||||||
public class CommandDoWork extends Command
|
public class CommandDoWork extends Command
|
||||||
{
|
{
|
||||||
// Required constructor
|
// Required constructor
|
||||||
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandDoWork(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
public String getHelpText() { return LocStrings.stub("DoWorkInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
long thispieceofshit = 0;
|
long thispieceofshit = 0;
|
||||||
for(int i = 0; i < 200000000 + Math.random() * 30; i ++)
|
for(int i = 0; i < 200000000 + Math.random() * 30; i ++)
|
||||||
{
|
{
|
||||||
thispieceofshit += Math.log((double)i);
|
thispieceofshit += Math.log((double)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send(LocStrings.stub("DoWorkFinished"));
|
res.send(LocStrings.stub("DoWorkFinished"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+135
-135
@@ -1,136 +1,136 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import core.Stats;
|
import core.Stats;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
import utils.ImageUtils;
|
import utils.ImageUtils;
|
||||||
|
|
||||||
public class CommandHelpBuilder extends Command {
|
public class CommandHelpBuilder extends Command {
|
||||||
|
|
||||||
public CommandHelpBuilder(KittyRole role, KittyRating rating) {
|
public CommandHelpBuilder(KittyRole role, KittyRating rating) {
|
||||||
super(role, rating);
|
super(role, rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
public String getHelpText() { return LocStrings.stub("HelpBuilderInfo"); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
// Holds command groups
|
// Holds command groups
|
||||||
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
HashMap<KittyRole, ArrayList<Command>> commandsByRole = new HashMap<KittyRole, ArrayList<Command>>();
|
||||||
|
|
||||||
// Populate w/ empty array lists
|
// Populate w/ empty array lists
|
||||||
for(int i = 0; i < KittyRole.values().length; ++i)
|
for(int i = 0; i < KittyRole.values().length; ++i)
|
||||||
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
commandsByRole.put(KittyRole.values()[i], new ArrayList<Command>());
|
||||||
|
|
||||||
// Sort commands out
|
// Sort commands out
|
||||||
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
ArrayList<Command> commands = Stats.instance.getAllCommands();
|
||||||
for(int i = 0; i < commands.size(); ++i)
|
for(int i = 0; i < commands.size(); ++i)
|
||||||
{
|
{
|
||||||
Command current = commands.get(i);
|
Command current = commands.get(i);
|
||||||
commandsByRole.get(current.requiredRole()).add(current);
|
commandsByRole.get(current.requiredRole()).add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format outstring and send it back for now
|
// Format outstring and send it back for now
|
||||||
String out = "";
|
String out = "";
|
||||||
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
out += populateSection(KittyRole.Admin, commandsByRole, true) + "\n";
|
||||||
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
out += populateSection(KittyRole.Mod, commandsByRole, true) + "\n";
|
||||||
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
out += populateSection(KittyRole.General, commandsByRole, false) + "\n";
|
||||||
|
|
||||||
// Write out file
|
// Write out file
|
||||||
String filename = "buildhelp_out.txt";
|
String filename = "buildhelp_out.txt";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PrintWriter writer = new PrintWriter(filename);
|
PrintWriter writer = new PrintWriter(filename);
|
||||||
writer.println(out);
|
writer.println(out);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e)
|
||||||
{
|
{
|
||||||
GlobalLog.error(e.toString());
|
GlobalLog.error(e.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
res.sendFile(file, "txt");
|
res.sendFile(file, "txt");
|
||||||
ImageUtils.blockingFileDelete(file);
|
ImageUtils.blockingFileDelete(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates the section for a specific role, optionally adding spacing after for another section
|
// Generates the section for a specific role, optionally adding spacing after for another section
|
||||||
private String populateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
private String populateSection(KittyRole role, HashMap<KittyRole, ArrayList<Command>> commandsByRole, boolean delimitSection)
|
||||||
{
|
{
|
||||||
// Formatting variables
|
// Formatting variables
|
||||||
final String headerStart = "<h2>";
|
final String headerStart = "<h2>";
|
||||||
final String headerEnd = "</h2>\n";
|
final String headerEnd = "</h2>\n";
|
||||||
final String sectionStart = "<p>\n";
|
final String sectionStart = "<p>\n";
|
||||||
final String sectionEnd = "</p>";
|
final String sectionEnd = "</p>";
|
||||||
final String indent = " ";
|
final String indent = " ";
|
||||||
final String leadStart = "<code>";
|
final String leadStart = "<code>";
|
||||||
final String leadEnd = "</code>";
|
final String leadEnd = "</code>";
|
||||||
final String leadFollow = ": ";
|
final String leadFollow = ": ";
|
||||||
final String lineDelimiter = "<br/>\n";
|
final String lineDelimiter = "<br/>\n";
|
||||||
final String sectionDelimiter = "\n\n";
|
final String sectionDelimiter = "\n\n";
|
||||||
|
|
||||||
String accumulated = "";
|
String accumulated = "";
|
||||||
ArrayList<Command> commands = commandsByRole.get(role);
|
ArrayList<Command> commands = commandsByRole.get(role);
|
||||||
ArrayList<Command> commandsSoFar = new ArrayList<Command>();
|
ArrayList<Command> commandsSoFar = new ArrayList<Command>();
|
||||||
if(commands.size() > 0)
|
if(commands.size() > 0)
|
||||||
{
|
{
|
||||||
String roleStr = role.toString();
|
String roleStr = role.toString();
|
||||||
roleStr = roleStr.substring(0, 1).toUpperCase() + roleStr.toLowerCase().substring(1);
|
roleStr = roleStr.substring(0, 1).toUpperCase() + roleStr.toLowerCase().substring(1);
|
||||||
|
|
||||||
// Section header
|
// Section header
|
||||||
accumulated += headerStart + roleStr + " commands" + headerEnd;
|
accumulated += headerStart + roleStr + " commands" + headerEnd;
|
||||||
accumulated += sectionStart;
|
accumulated += sectionStart;
|
||||||
|
|
||||||
// Section content
|
// Section content
|
||||||
for(int i = 0; i < commands.size(); ++i)
|
for(int i = 0; i < commands.size(); ++i)
|
||||||
{
|
{
|
||||||
accumulated += indent;
|
accumulated += indent;
|
||||||
Command command = commands.get(i);
|
Command command = commands.get(i);
|
||||||
|
|
||||||
// Skip multiples
|
// Skip multiples
|
||||||
if(commandsSoFar.contains(command))
|
if(commandsSoFar.contains(command))
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
commandsSoFar.add(command);
|
commandsSoFar.add(command);
|
||||||
|
|
||||||
// Write out all the keys and the help text
|
// Write out all the keys and the help text
|
||||||
ArrayList<String> keys = command.registeredNames();
|
ArrayList<String> keys = command.registeredNames();
|
||||||
for(int j = 0; j < keys.size(); ++j)
|
for(int j = 0; j < keys.size(); ++j)
|
||||||
{
|
{
|
||||||
if(j != 0)
|
if(j != 0)
|
||||||
accumulated += ", ";
|
accumulated += ", ";
|
||||||
|
|
||||||
accumulated += leadStart + keys.get(j) + leadEnd;
|
accumulated += leadStart + keys.get(j) + leadEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
accumulated += leadFollow + commands.get(i).getHelpText() + lineDelimiter;;
|
||||||
}
|
}
|
||||||
|
|
||||||
accumulated += sectionEnd;
|
accumulated += sectionEnd;
|
||||||
|
|
||||||
// Add spaces after if needed
|
// Add spaces after if needed
|
||||||
if(delimitSection)
|
if(delimitSection)
|
||||||
accumulated += sectionDelimiter;
|
accumulated += sectionDelimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return accumulated;
|
return accumulated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,60 +1,60 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.DatabaseManager;
|
import core.DatabaseManager;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import core.Stats;
|
import core.Stats;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
import utils.LogFilter;
|
import utils.LogFilter;
|
||||||
|
|
||||||
// NOTE(wisp): This is a sort of special command.
|
// NOTE(wisp): This is a sort of special command.
|
||||||
public class CommandShutdown extends Command
|
public class CommandShutdown extends Command
|
||||||
{
|
{
|
||||||
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandShutdown(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
public String getHelpText() { return LocStrings.stub("ShutdownInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
// Flag the shutdown immediately.
|
// Flag the shutdown immediately.
|
||||||
Stats.instance.indicateShutdown();
|
Stats.instance.indicateShutdown();
|
||||||
|
|
||||||
boolean isSafe = false;
|
boolean isSafe = false;
|
||||||
switch(input.args.toLowerCase().trim())
|
switch(input.args.toLowerCase().trim())
|
||||||
{
|
{
|
||||||
case "s":
|
case "s":
|
||||||
case "safe":
|
case "safe":
|
||||||
case "-s":
|
case "-s":
|
||||||
case "-safe":
|
case "-safe":
|
||||||
case "snafe":
|
case "snafe":
|
||||||
isSafe = true;
|
isSafe = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isSafe)
|
if(isSafe)
|
||||||
{
|
{
|
||||||
// Force upkeep, this works so long as upkeep is on the main thread.
|
// Force upkeep, this works so long as upkeep is on the main thread.
|
||||||
res.sendImmediate(LocStrings.stub("ShutdownSafe"));
|
res.sendImmediate(LocStrings.stub("ShutdownSafe"));
|
||||||
DatabaseManager.instance.upkeep();
|
DatabaseManager.instance.upkeep();
|
||||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||||
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``");
|
||||||
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
GlobalLog.warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe"));
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,89 +1,89 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import core.CommandManager.ThreadData;
|
import core.CommandManager.ThreadData;
|
||||||
import core.Constants;
|
import core.Constants;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyEmbed;
|
import dataStructures.KittyEmbed;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
import core.Stats;
|
import core.Stats;
|
||||||
|
|
||||||
public class CommandStats extends Command
|
public class CommandStats extends Command
|
||||||
{
|
{
|
||||||
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
public String getHelpText() { return LocStrings.stub("StatsInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
// Variables
|
// Variables
|
||||||
Stats stats = Stats.instance;
|
Stats stats = Stats.instance;
|
||||||
String out = "";
|
String out = "";
|
||||||
long seen = stats.getMessagesSeen();
|
long seen = stats.getMessagesSeen();
|
||||||
long processed = stats.getCommandsProcessed();
|
long processed = stats.getCommandsProcessed();
|
||||||
|
|
||||||
// General
|
// General
|
||||||
out += "General";
|
out += "General";
|
||||||
out += "```\n";
|
out += "```\n";
|
||||||
out += " Messages observed: " + seen + "\n";
|
out += " Messages observed: " + seen + "\n";
|
||||||
out += "Commands processed: " + processed + "\n";
|
out += "Commands processed: " + processed + "\n";
|
||||||
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n";
|
||||||
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
out += " Bot uptime: " + stats.getFormattedUptime() + "\n";
|
||||||
out += "```\n";
|
out += "```\n";
|
||||||
|
|
||||||
// Health
|
// Health
|
||||||
out += "Health";
|
out += "Health";
|
||||||
out += "```\n";
|
out += "```\n";
|
||||||
out += " SMT cores: " + stats.getCPUAvailable() + "\n";
|
out += " SMT cores: " + stats.getCPUAvailable() + "\n";
|
||||||
|
|
||||||
// If CPU load works on this OS, list it. -1.0 is the error state
|
// If CPU load works on this OS, list it. -1.0 is the error state
|
||||||
double CPULoad = stats.getSystemCPULoad();
|
double CPULoad = stats.getSystemCPULoad();
|
||||||
out += CPULoad > -0.9
|
out += CPULoad > -0.9
|
||||||
? " CPU Load: " + (CPULoad * 100) + "%\n" : "";
|
? " CPU Load: " + (CPULoad * 100) + "%\n" : "";
|
||||||
|
|
||||||
ThreadData data = stats.getThreadData();
|
ThreadData data = stats.getThreadData();
|
||||||
Integer terminated = data.states.get(Thread.State.TERMINATED);
|
Integer terminated = data.states.get(Thread.State.TERMINATED);
|
||||||
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
Integer runnable = data.states.get(Thread.State.RUNNABLE);
|
||||||
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
Integer blocked = data.states.get(Thread.State.BLOCKED);
|
||||||
Integer timed_waiting = data.states.get(Thread.State.TIMED_WAITING);
|
Integer timed_waiting = data.states.get(Thread.State.TIMED_WAITING);
|
||||||
Integer waiting = data.states.get(Thread.State.WAITING);
|
Integer waiting = data.states.get(Thread.State.WAITING);
|
||||||
|
|
||||||
out += " Threads:"
|
out += " Threads:"
|
||||||
+ " run-" + (runnable == null ? 0 : runnable)
|
+ " run-" + (runnable == null ? 0 : runnable)
|
||||||
+ " block-" + (blocked == null ? 0 : blocked)
|
+ " block-" + (blocked == null ? 0 : blocked)
|
||||||
+ " sleep-" + (timed_waiting == null ? 0 : timed_waiting)
|
+ " sleep-" + (timed_waiting == null ? 0 : timed_waiting)
|
||||||
+ " wait-" + (waiting == null ? 0 : waiting)
|
+ " wait-" + (waiting == null ? 0 : waiting)
|
||||||
+ " term-" + (terminated == null ? 0 : terminated)
|
+ " term-" + (terminated == null ? 0 : terminated)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
|
||||||
out += "```\n";
|
out += "```\n";
|
||||||
|
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
Integer guildCount = stats.getGuildCount();
|
Integer guildCount = stats.getGuildCount();
|
||||||
Integer userCount = stats.getUserCount();
|
Integer userCount = stats.getUserCount();
|
||||||
|
|
||||||
out += "Cache";
|
out += "Cache";
|
||||||
out += "```\n"
|
out += "```\n"
|
||||||
+ "Cached Guilds: " + guildCount + "\n"
|
+ "Cached Guilds: " + guildCount + "\n"
|
||||||
+ " Cached Users: " + userCount;
|
+ " Cached Users: " + userCount;
|
||||||
|
|
||||||
out += "\n```";
|
out += "\n```";
|
||||||
|
|
||||||
KittyEmbed embed = new KittyEmbed();
|
KittyEmbed embed = new KittyEmbed();
|
||||||
embed.title = "Bot Stats";
|
embed.title = "Bot Stats";
|
||||||
embed.descriptionText = out;
|
embed.descriptionText = out;
|
||||||
embed.color = Constants.ColorDefault;
|
embed.color = Constants.ColorDefault;
|
||||||
|
|
||||||
res.send(embed);
|
res.send(embed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.dev;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
+71
-71
@@ -1,71 +1,71 @@
|
|||||||
package commands.general;
|
package commands.images;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
import dataStructures.KittyChannel;
|
import dataStructures.KittyChannel;
|
||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import dataStructures.Response;
|
import dataStructures.Response;
|
||||||
import dataStructures.UserInput;
|
import dataStructures.UserInput;
|
||||||
import utils.ImageOverlayBuilder;
|
import utils.ImageOverlayBuilder;
|
||||||
import utils.ImageUtils;
|
import utils.ImageUtils;
|
||||||
|
|
||||||
public class CommandDefaultDance extends Command
|
public class CommandDefaultDance extends Command
|
||||||
{
|
{
|
||||||
// Required constructor
|
// Required constructor
|
||||||
public CommandDefaultDance(KittyRole level, KittyRating rating) { super(level, rating); }
|
public CommandDefaultDance(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||||
|
|
||||||
private static Long num = 0l;
|
private static Long num = 0l;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHelpText() { return LocStrings.stub("DefaultDanceInfo"); }
|
public String getHelpText() { return LocStrings.stub("DefaultDanceInfo"); }
|
||||||
|
|
||||||
// Called when the command is run!
|
// Called when the command is run!
|
||||||
@Override
|
@Override
|
||||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||||
{
|
{
|
||||||
String name = null;
|
String name = null;
|
||||||
File dancerFile = null;
|
File dancerFile = null;
|
||||||
File danceeFile = null;
|
File danceeFile = null;
|
||||||
|
|
||||||
synchronized(num)
|
synchronized(num)
|
||||||
{
|
{
|
||||||
name = "defaultDance_" + num + ".gif";
|
name = "defaultDance_" + num + ".gif";
|
||||||
++num;
|
++num;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
KittyUser person = null;
|
KittyUser person = null;
|
||||||
|
|
||||||
if(input.mentions == null)
|
if(input.mentions == null)
|
||||||
person = user;
|
person = user;
|
||||||
else
|
else
|
||||||
person = input.mentions[0];
|
person = input.mentions[0];
|
||||||
|
|
||||||
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
String yeeteeFilename = ImageUtils.downloadFromURL(person.avatarID, ".png");
|
||||||
if(yeeteeFilename == null)
|
if(yeeteeFilename == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
danceeFile = new File(yeeteeFilename);
|
danceeFile = new File(yeeteeFilename);
|
||||||
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/dance/default/", "defaultDance ", 118, 18);
|
ImageOverlayBuilder builder = new ImageOverlayBuilder("assets/dance/default/", "defaultDance ", 118, 18);
|
||||||
builder.overlay(ImageIO.read(danceeFile), name);
|
builder.overlay(ImageIO.read(danceeFile), name);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
dancerFile = new File (name);
|
dancerFile = new File (name);
|
||||||
res.sendFile(dancerFile, "gif");
|
res.sendFile(dancerFile, "gif");
|
||||||
|
|
||||||
// Thread cleanup...
|
// Thread cleanup...
|
||||||
ImageUtils.blockingFileDelete(dancerFile);
|
ImageUtils.blockingFileDelete(dancerFile);
|
||||||
ImageUtils.blockingFileDelete(danceeFile);
|
ImageUtils.blockingFileDelete(danceeFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import core.Command;
|
import core.Command;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package commands.general;
|
package commands.network;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -4,17 +4,37 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import commands.beans.CommandBeansShow;
|
||||||
|
import commands.beans.CommandBetBeans;
|
||||||
|
import commands.beans.CommandBetHistory;
|
||||||
|
import commands.beans.CommandGiveBeans;
|
||||||
|
import commands.beans.CommandTradeBeans;
|
||||||
import commands.characters.CommandCharacterMain;
|
import commands.characters.CommandCharacterMain;
|
||||||
|
import commands.dev.CommandDBFlush;
|
||||||
|
import commands.dev.CommandDBStats;
|
||||||
|
import commands.dev.CommandDoWork;
|
||||||
|
import commands.dev.CommandHelpBuilder;
|
||||||
|
import commands.dev.CommandInvite;
|
||||||
|
import commands.dev.CommandShutdown;
|
||||||
|
import commands.dev.CommandStats;
|
||||||
|
import commands.dev.CommandTweet;
|
||||||
import commands.general.*;
|
import commands.general.*;
|
||||||
import commands.guildrole.CommandGuildRoleMain;
|
import commands.guildrole.CommandGuildRoleMain;
|
||||||
import commands.images.CommandBlurry;
|
import commands.images.CommandBlurry;
|
||||||
import commands.images.CommandCatch;
|
import commands.images.CommandCatch;
|
||||||
|
import commands.images.CommandDefaultDance;
|
||||||
import commands.images.CommandPerish;
|
import commands.images.CommandPerish;
|
||||||
import commands.images.CommandStark;
|
import commands.images.CommandStark;
|
||||||
import commands.images.CommandTeey;
|
import commands.images.CommandTeey;
|
||||||
import commands.images.CommandYeet;
|
import commands.images.CommandYeet;
|
||||||
import commands.mod.CommandModMain;
|
import commands.mod.CommandModMain;
|
||||||
import commands.music.CommandMusicMain;
|
import commands.music.CommandMusicMain;
|
||||||
|
import commands.network.CommandColiru;
|
||||||
|
import commands.network.CommandDerpi;
|
||||||
|
import commands.network.CommandE6;
|
||||||
|
import commands.network.CommandGetSauce;
|
||||||
|
import commands.network.CommandJDoodle;
|
||||||
|
import commands.network.CommandWolfram;
|
||||||
import commands.poll.CommandPollMain;
|
import commands.poll.CommandPollMain;
|
||||||
import commands.raffle.CommandRaffleMain;
|
import commands.raffle.CommandRaffleMain;
|
||||||
import dataStructures.*;
|
import dataStructures.*;
|
||||||
|
|||||||
Reference in New Issue
Block a user