From feca9e542a8aa6a2daec789b9b419564addec848 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Wed, 19 Jun 2019 21:48:37 -0700 Subject: [PATCH] = Core subsystem formatting update --- src/commands/CommandChangeIndicator.java | 2 +- src/commands/CommandChoose.java | 2 +- src/commands/CommandHelp.java | 2 +- src/commands/CommandHelpBuilder.java | 6 +- src/commands/CommandShutdown.java | 6 +- src/commands/CommandStats.java | 16 +-- src/core/BaseKeyValueFile.java | 4 +- src/core/BaseLocFile.java | 52 ++++---- src/core/Command.java | 18 +-- src/core/CommandEnabler.java | 20 +-- src/core/CommandManager.java | 24 ++-- src/core/CommandThread.java | 8 +- src/core/DatabaseDriverKeyValue.java | 38 +++--- src/core/DatabaseManager.java | 14 +-- src/core/LocCommands.java | 14 +-- src/core/LocStrings.java | 16 +-- src/core/ObjectBuilderFactory.java | 149 ++++++++++++----------- src/core/RPManager.java | 2 +- src/core/Stats.java | 34 +++--- src/main/Main.java | 14 +-- src/main/Superintendent.java | 18 +-- 21 files changed, 230 insertions(+), 229 deletions(-) diff --git a/src/commands/CommandChangeIndicator.java b/src/commands/CommandChangeIndicator.java index f4133bf..e3d73e8 100644 --- a/src/commands/CommandChangeIndicator.java +++ b/src/commands/CommandChangeIndicator.java @@ -24,7 +24,7 @@ public class CommandChangeIndicator extends Command String indicator = arg.substring(0, 1); if(indicator.charAt(0) == '\n' || indicator.charAt(0) == '\t' || indicator.charAt(0) == '\r') { - res.send(LocStrings.Lookup("ChangeIndicatorError")); + res.send(LocStrings.lookup("ChangeIndicatorError")); return; } diff --git a/src/commands/CommandChoose.java b/src/commands/CommandChoose.java index 30893a7..bb71dd4 100644 --- a/src/commands/CommandChoose.java +++ b/src/commands/CommandChoose.java @@ -21,7 +21,7 @@ public class CommandChoose extends Command { if(input.args.trim().length() == 0) { - res.send(Stats.instance.GetHelpText(input.key)); + res.send(Stats.instance.getHelpText(input.key)); return; } diff --git a/src/commands/CommandHelp.java b/src/commands/CommandHelp.java index 0340e2e..41d33ec 100644 --- a/src/commands/CommandHelp.java +++ b/src/commands/CommandHelp.java @@ -20,7 +20,7 @@ public class CommandHelp extends Command @Override public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { - String help = Stats.instance.GetHelpText(input.args); + String help = Stats.instance.getHelpText(input.args); if(help == null) { diff --git a/src/commands/CommandHelpBuilder.java b/src/commands/CommandHelpBuilder.java index 3898c12..e736c5e 100644 --- a/src/commands/CommandHelpBuilder.java +++ b/src/commands/CommandHelpBuilder.java @@ -39,11 +39,11 @@ public class CommandHelpBuilder extends Command { commandsByRole.put(KittyRole.values()[i], new ArrayList()); // Sort commands out - ArrayList commands = Stats.instance.GetAllCommands(); + ArrayList commands = Stats.instance.getAllCommands(); for(int i = 0; i < commands.size(); ++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 @@ -112,7 +112,7 @@ public class CommandHelpBuilder extends Command { commandsSoFar.add(command); // Write out all the keys and the help text - ArrayList keys = command.RegisteredNames(); + ArrayList keys = command.registeredNames(); for(int j = 0; j < keys.size(); ++j) { if(j != 0) diff --git a/src/commands/CommandShutdown.java b/src/commands/CommandShutdown.java index ddb8e41..afcb43f 100644 --- a/src/commands/CommandShutdown.java +++ b/src/commands/CommandShutdown.java @@ -27,7 +27,7 @@ public class CommandShutdown extends Command public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { // Flag the shutdown immediately. - Stats.instance.IndicateShutdown(); + Stats.instance.indicateShutdown(); boolean isSafe = false; switch(input.args.toLowerCase().trim()) @@ -48,14 +48,14 @@ public class CommandShutdown extends Command // Force upkeep, this works so long as upkeep is on the main thread. res.sendImmediate(LocStrings.stub("ShutdownSafe")); DatabaseManager.instance.upkeep(); - GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe")); + GlobalLog.Warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe")); System.exit(0); } else { res.sendImmediate(LocStrings.stub("ShutdownUnsafe"));// "``"); - GlobalLog.Warn(LogFilter.Command, LocStrings.Lookup("ShutdownSafe")); + GlobalLog.Warn(LogFilter.Command, LocStrings.lookup("ShutdownSafe")); System.exit(0); } } diff --git a/src/commands/CommandStats.java b/src/commands/CommandStats.java index 1eea9e7..3e6217a 100644 --- a/src/commands/CommandStats.java +++ b/src/commands/CommandStats.java @@ -28,8 +28,8 @@ public class CommandStats extends Command // Variables Stats stats = Stats.instance; String out = ""; - long seen = stats.GetMessagesSeen(); - long processed = stats.GetCommandsProcessed(); + long seen = stats.getMessagesSeen(); + long processed = stats.getCommandsProcessed(); // General out += "General"; @@ -37,20 +37,20 @@ public class CommandStats extends Command out += " Messages observed: " + seen + "\n"; out += "Commands processed: " + processed + "\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"; // Health out += "Health"; 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 - double CPULoad = stats.GetSystemCPULoad(); + double CPULoad = stats.getSystemCPULoad(); out += CPULoad > -0.9 ? " CPU Load: " + (CPULoad * 100) + "%\n" : ""; - ThreadData data = stats.GetThreadData(); + ThreadData data = stats.getThreadData(); Integer terminated = data.states.get(Thread.State.TERMINATED); Integer runnable = data.states.get(Thread.State.RUNNABLE); Integer blocked = data.states.get(Thread.State.BLOCKED); @@ -69,8 +69,8 @@ public class CommandStats extends Command // Cache - Integer guildCount = stats.GetGuildCount(); - Integer userCount = stats.GetUserCount(); + Integer guildCount = stats.getGuildCount(); + Integer userCount = stats.getUserCount(); out += "Cache"; out += "```\n" diff --git a/src/core/BaseKeyValueFile.java b/src/core/BaseKeyValueFile.java index cb27fc5..9519fb6 100644 --- a/src/core/BaseKeyValueFile.java +++ b/src/core/BaseKeyValueFile.java @@ -33,7 +33,7 @@ public class BaseKeyValueFile } // Reads in and calls the specifid function for each keyvalue pair we find - protected void Parse(Consumer> keyValueCallback) + protected void parse(Consumer> keyValueCallback) { File f = new File(filename); if(f.isFile() && f.canRead()) @@ -60,7 +60,7 @@ public class BaseKeyValueFile } // Writes out a set of keyvalue pairs - protected void Write(List> toWrite) + protected void write(List> toWrite) { try { diff --git a/src/core/BaseLocFile.java b/src/core/BaseLocFile.java index f05eafc..672fd30 100644 --- a/src/core/BaseLocFile.java +++ b/src/core/BaseLocFile.java @@ -30,9 +30,9 @@ public abstract class BaseLocFile protected TaggedPairStore stringStore; // Logging - private void Log(String str) { GlobalLog.Log(LogFilter.Strings, str); } - private void Warn(String str) { GlobalLog.Warn(LogFilter.Strings, str); } - private void Error(String str) { GlobalLog.Error(LogFilter.Strings, str); } + private void log(String str) { GlobalLog.Log(LogFilter.Strings, str); } + private void warn(String str) { GlobalLog.Warn(LogFilter.Strings, str); } + private void error(String str) { GlobalLog.Error(LogFilter.Strings, str); } // File monitoring protected FileMonitor fileMonitor; @@ -45,19 +45,19 @@ public abstract class BaseLocFile } // Checks the file specified for updates - public void Update() + public void update() { synchronized(stringStore) { - fileMonitor.Update(this::OnFileChange); + fileMonitor.Update(this::onFileChange); } } // When the file is changed - protected void OnFileChange(MonitoredFile file) + protected void onFileChange(MonitoredFile file) { - Log("Loc file was modified at path " + file.path); - UpdateLocFromDisk(); + log("Loc file was modified at path " + file.path); + updateLocFromDisk(); } // Structure used for holding a pair of strings and any other info we need @@ -75,7 +75,7 @@ public abstract class BaseLocFile } // Do processing on each path in the scraped directory here, assuming it's .java - public void StripForContents(Path path, ArrayList strings) + public void stripForContents(Path path, ArrayList strings) { String filename = path.getFileName().toString(); if(filename.contains(".java")) @@ -101,11 +101,11 @@ public abstract class BaseLocFile strings.add(new LocInfo(filename.substring(0, filename.lastIndexOf('.')), toLocalize)); - Log("Found lookup call in " + path + ": " + toLocalize); + log("Found lookup call in " + path + ": " + toLocalize); } catch(IndexOutOfBoundsException e) { - Warn("Found phrase but couldn't parse in file " + path); + warn("Found phrase but couldn't parse in file " + path); } } } @@ -116,7 +116,7 @@ public abstract class BaseLocFile // Nothing for now, but in the future will return a parsed and localized version of // the string in question if one can be found. If the localized string is empty, // returns a the key instead which is the default phrase. - public String GetKey(String input) + public String getKey(String input) { if(stringStore == null) return input; @@ -129,7 +129,7 @@ public abstract class BaseLocFile } // Reads a file to string, adapted from https://stackoverflow.com/a/326440/5383198 - private String ReadFileAsString(String path, Charset encoding) + private String readFileAsString(String path, Charset encoding) { try { @@ -138,7 +138,7 @@ public abstract class BaseLocFile } catch (IOException e) { - Warn("No file found to read from!"); + warn("No file found to read from!"); } return null; @@ -146,13 +146,13 @@ public abstract class BaseLocFile // Update localization from the disk on file. Creates the file if it doesn't exist. // This file is internally formatted as an ini file. - public void UpdateLocFromDisk() + public void updateLocFromDisk() { - Log("Attempting to read localization file: " + filename); + log("Attempting to read localization file: " + filename); try { - String fileContents = ReadFileAsString(filename, Charset.defaultCharset()); + String fileContents = readFileAsString(filename, Charset.defaultCharset()); if(fileContents == null) { @@ -164,15 +164,15 @@ public abstract class BaseLocFile } catch(IOException e) { - Error("IO exception during localization file read"); + error("IO exception during localization file read"); } } // Rewrites out at the specified filename with existing stubs. // This preserves existing localized phrases. - public void SaveLocToDisk() + public void saveLocToDisk() { - Log("Attempting to write updated localization file"); + log("Attempting to write updated localization file"); try { @@ -182,28 +182,28 @@ public abstract class BaseLocFile } catch(IOException e) { - Error("IO exception during localization file write"); + error("IO exception during localization file write"); } } - private void TryStripSpecified(Path path, ArrayList toFill) + private void tryStripSpecified(Path path, ArrayList toFill) { try { - StripForContents(path, toFill); + stripForContents(path, toFill); } catch(Exception e) { - Error("issue with file: " + path.toString()); + error("issue with file: " + path.toString()); } } // Scrape the project and generate all the possible localizeable phrases. // This stubs out phrases to be localized. - public void ScrapeAll() + public void scrapeAll() { ArrayList localizeList = new ArrayList(); - FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> TryStripSpecified(path, localizeList)); + FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> tryStripSpecified(path, localizeList)); for(LocInfo toStub : localizeList) stringStore.addKeyValue(toStub.file, toStub.phrase, toStub.phrase); diff --git a/src/core/Command.java b/src/core/Command.java index 829c65f..954edb5 100644 --- a/src/core/Command.java +++ b/src/core/Command.java @@ -26,18 +26,18 @@ public abstract class Command this.contentRating = contentRating; } - private void Reject(KittyUser user, String reason) + private void reject(KittyUser user, String reason) { GlobalLog.Warn(LogFilter.Command, this.getClass().getSimpleName() + " from " + user.name + " rejected due to command's " + reason); } // Determine if we're exclusive enough for this command and // if the command is permitted by the guild we're in - private boolean CanCall(KittyGuild guild, KittyChannel channel, KittyUser user) + private boolean canCall(KittyGuild guild, KittyChannel channel, KittyUser user) { if(guild.contentRating.getValue() < contentRating.getValue()) { - Reject(user, "content rating"); + reject(user, "content rating"); return false; } @@ -48,31 +48,31 @@ public abstract class Command return true; } - Reject(user, "permissions"); + reject(user, "permissions"); return false; } // Called by the Command manager - this will run the command // if the issuing user has the permission to do so! - protected final void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) + protected final void invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { - if(!CanCall(guild, channel, user)) + if(!canCall(guild, channel, user)) return; onRun(guild, channel, user, input, res); } - public ArrayList RegisteredNames() + public ArrayList registeredNames() { return registeredNames; } - public KittyRating Rating() + public KittyRating rating() { return contentRating; } - public KittyRole RequiredRole() + public KittyRole requiredRole() { return roleLevel; } diff --git a/src/core/CommandEnabler.java b/src/core/CommandEnabler.java index 25a83cc..160c921 100644 --- a/src/core/CommandEnabler.java +++ b/src/core/CommandEnabler.java @@ -35,15 +35,15 @@ public class CommandEnabler extends BaseKeyValueFile keyList = new ArrayList<>(); // Startup - ReadIn(); - GetTrackedCommands(); - WriteOut(); + readIn(); + getTrackedCommands(); + writeOut(); } // Reads in the config file and parses it, keeping tabs on the order it read things - private void ReadIn() + private void readIn() { - Parse((pair) ->{ + parse((pair) ->{ String key = pair.First; String value = pair.Second; @@ -58,9 +58,9 @@ public class CommandEnabler extends BaseKeyValueFile // Look up the already scraped values from the localizer and store them if they // don't already exist in the lookup. Defaults to defaultEnabledState. - private void GetTrackedCommands() + private void getTrackedCommands() { - ArrayList unloc = LocCommands.GetUnlocalizedCommands(); + ArrayList unloc = LocCommands.getUnlocalizedCommands(); for(int i = 0; i < unloc.size(); ++i) { @@ -75,7 +75,7 @@ public class CommandEnabler extends BaseKeyValueFile } // Write out enabled/disabled file info. - private void WriteOut() + private void writeOut() { List> list = new Vector>(); @@ -92,11 +92,11 @@ public class CommandEnabler extends BaseKeyValueFile Collections.sort(list, (c1, c2) -> { return c1.First.compareTo(c2.First); }); - Write(list); + write(list); } // Looks up a key to see if it's enabled or not - public boolean IsEnabled(String key) + public boolean isEnabled(String key) { String toCheck = key.toLowerCase(); diff --git a/src/core/CommandManager.java b/src/core/CommandManager.java index 5314457..e4ada68 100644 --- a/src/core/CommandManager.java +++ b/src/core/CommandManager.java @@ -31,7 +31,7 @@ public class CommandManager // Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands) // and the command associated with the localized commands. - public void Register(Pair pair, Command command) + public void register(Pair pair, Command command) { if(pair == null || pair.Second == null) return; @@ -39,7 +39,7 @@ public class CommandManager // If we haven't already split a multisplit command (or even assessed that), // then verify if we even need to register the commands at all. If it's // not enabled, don't register it. - if(pair.First != null && !commandEnabler.IsEnabled(pair.First)) + if(pair.First != null && !commandEnabler.isEnabled(pair.First)) return; String key = pair.Second; @@ -48,7 +48,7 @@ public class CommandManager { String[] keys = key.split(","); - Register(keys, command); + register(keys, command); return; } @@ -67,14 +67,14 @@ public class CommandManager } // Registers a command under multiple names! - public void Register(String[] keys, Command command) + public void register(String[] keys, Command command) { for(int i = 0; i < keys.length; ++i) - Register(new Pair(null, keys[i].trim()), command); + register(new Pair(null, keys[i].trim()), command); } // Calls the command but on a whole new thread! - public boolean InvokeOnNewThread(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext) + public boolean invokeOnNewThread(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext) { // This is here to prevent spinning up a thread if this wasn't even a command. if(input == null || !input.isValid()) @@ -97,7 +97,7 @@ public class CommandManager } // Calls the command specified with the key, providing user information arguments, etc. - void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext) + void invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext) { if(input == null || !input.isValid()) return; @@ -106,12 +106,12 @@ public class CommandManager if(command != null) { ++invokeCount; - command.Invoke(guild, channel, user, input, responseContext); + command.invoke(guild, channel, user, input, responseContext); } } // Looks up command by name. If it exists, dumps help text, otherwise returns null. - public String GetCommandHelpText(String key) + public String getCommandHelpText(String key) { Command command = commands.get(key); @@ -122,13 +122,13 @@ public class CommandManager } // Returns the number of commands sent so far during this program run - public long GetInvokeCount() + public long getInvokeCount() { return invokeCount; } // Returns all commands by name - public ArrayList GetAllRegisteredCommands() + public ArrayList getAllRegisteredCommands() { ArrayList cmds = new ArrayList(); for(Entry entry : commands.entrySet()) @@ -142,7 +142,7 @@ public class CommandManager { public HashMap states = new HashMap(); } - public ThreadData DumpThreadData() + public ThreadData dumpThreadData() { ThreadData data = new ThreadData(); diff --git a/src/core/CommandThread.java b/src/core/CommandThread.java index 2fc5707..2d044e5 100644 --- a/src/core/CommandThread.java +++ b/src/core/CommandThread.java @@ -31,17 +31,17 @@ public class CommandThread extends Thread @Override public void run() { - InvokeCommand(); + invokeCommand(); } - private void InvokeCommand() + private void invokeCommand() { - manager.Invoke(guild, channel, user, input, response); + manager.invoke(guild, channel, user, input, response); } // Handles the try catch requirement java has for sleeping @SuppressWarnings("unused") - private void ThreadSleep(int ms) + private void threadSleep(int ms) { try { diff --git a/src/core/DatabaseDriverKeyValue.java b/src/core/DatabaseDriverKeyValue.java index 01e63c1..c7f7469 100644 --- a/src/core/DatabaseDriverKeyValue.java +++ b/src/core/DatabaseDriverKeyValue.java @@ -35,14 +35,14 @@ public class DatabaseDriverKeyValue // Makes sure a table exists with the specified name. // The keyName specifies the key column label, and the valueName specifies the value column label. - public void EnsureTableExists(String tableName, String keyName, String valueName) + public void ensureTableExists(String tableName, String keyName, String valueName) { // Require a global table if it doesn't exist already driver.ExecuteStatement(JDBCStatementType.Create, "CREATE TABLE IF NOT EXISTS " + tableName + " (" + keyName + " text PRIMARY KEY, " + valueName + " text)", null); } // Set up and create a table in the database - public boolean Connect() + public boolean connect() { driver = new JDBCDriverSQLite(); if(driver.Connect() == false) @@ -51,45 +51,45 @@ public class DatabaseDriverKeyValue } // Verify tables we want to use exist - EnsureTableExists(tableName, keyColumnName, valueColumnName); // General table. Do not remove. + ensureTableExists(tableName, keyColumnName, valueColumnName); // General table. Do not remove. return true; } // The key will be created if it doesn't exist and the value specified will be stored. - public void CreateSetKey(String key, String value) + public void createSetKey(String key, String value) { GlobalLog.Log(LogFilter.Database, "CreateSetKey: Key-" + key + " value-" + value); - if(HasKey(key)) + if(hasKey(key)) { - UpdateKey(key, value); + updateKey(key, value); } else { - CreateKey(key, value); + createKey(key, value); } } // Creates a key. The key will be created if it doesn't exist, and the default value returned. - public String CreateGetKey(String key) + public String createGetKey(String key) { GlobalLog.Log(LogFilter.Database, "CreateGetKey: " + key); - if(HasKey(key)) + if(hasKey(key)) { - return GetKey(key); + return getKey(key); } else { String newValue = ""; - CreateKey(key, newValue); + createKey(key, newValue); return newValue; } } // Prototype formatting for key updating - private void UpdateKey(String key, String value) + private void updateKey(String key, String value) { String command = "UPDATE " + tableName + " SET " + valueColumnName + " = ? WHERE " + keyColumnName + " = ?"; boolean status = driver.ExecuteStatement(JDBCStatementType.Update, command, new String[] { value, key }); @@ -97,24 +97,24 @@ public class DatabaseDriverKeyValue } // Protoype updating for seeing if a key exists - private boolean HasKey(String key) + private boolean hasKey(String key) { String command = "SELECT COUNT(1) as count FROM " + tableName + " WHERE " + keyColumnName + " = ?"; ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key }); - String out = ResultAsString(set, "count"); + String out = resultAsString(set, "count"); return out.charAt(0) == '1'; } // Prototype for getting a key - private String GetKey(String key) + private String getKey(String key) { String command = "SELECT " + valueColumnName + " as searchedKey FROM " + tableName +" WHERE " + keyColumnName + " = ?"; ResultSet set = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { key }); - return ResultAsString(set, "searchedKey"); + return resultAsString(set, "searchedKey"); } // Prototype for creating a key - private void CreateKey(String key, String value) + private void createKey(String key, String value) { String command = "INSERT INTO " + tableName + " (GlobalKey, GlobalValue) VALUES (?, ?)"; boolean status = driver.ExecuteStatement(JDBCStatementType.Insert, command, new String[] { key, value }); @@ -122,7 +122,7 @@ public class DatabaseDriverKeyValue } // Get all keys containing a substring - public List GetKeysWith(String keySubstring) + public List getKeysWith(String keySubstring) { String command = "SELECT * FROM " + tableName + " WHERE " + keyColumnName + " like ?"; ResultSet result = driver.ExecuteReturningStatement(JDBCStatementType.Select, command, new String[] { "%" + keySubstring + "%" }); @@ -146,7 +146,7 @@ public class DatabaseDriverKeyValue } // Transforms a result into a string if possible. - private String ResultAsString(ResultSet rs, String key) + private String resultAsString(ResultSet rs, String key) { if(rs == null) return ""; diff --git a/src/core/DatabaseManager.java b/src/core/DatabaseManager.java index e647cbb..f5a3a11 100644 --- a/src/core/DatabaseManager.java +++ b/src/core/DatabaseManager.java @@ -57,13 +57,13 @@ public class DatabaseManager characterDataDriver = new DatabaseDriverKeyValue(characterTableName, characterKeyColumnName, characterValueColumnName); // Connect data sets - if(globalDataDriver.Connect() == false) + if(globalDataDriver.connect() == false) { GlobalLog.Error("Global database failed to connect. Without this DB, this bot can not run."); System.exit(1); } - if(characterDataDriver.Connect() == false) + if(characterDataDriver.connect() == false) { GlobalLog.Error("Character database failed to connect. Without this DB, this bot can not run."); System.exit(1); @@ -131,7 +131,7 @@ public class DatabaseManager public List scrapeGlobalForString(String substring) { - return globalDataDriver.GetKeysWith(substring); + return globalDataDriver.getKeysWith(substring); } ///////////////// @@ -151,7 +151,7 @@ public class DatabaseManager { synchronized(globalDataDriver) { - return globalDataDriver.CreateGetKey(key); + return globalDataDriver.createGetKey(key); } } @@ -159,7 +159,7 @@ public class DatabaseManager { synchronized(globalDataDriver) { - globalDataDriver.CreateSetKey(key, value); + globalDataDriver.createSetKey(key, value); } } @@ -181,7 +181,7 @@ public class DatabaseManager { synchronized(characterDataDriver) { - return characterDataDriver.CreateGetKey(key); + return characterDataDriver.createGetKey(key); } } @@ -189,7 +189,7 @@ public class DatabaseManager { synchronized(characterDataDriver) { - characterDataDriver.CreateSetKey(key, value); + characterDataDriver.createSetKey(key, value); } } diff --git a/src/core/LocCommands.java b/src/core/LocCommands.java index 831eadb..6c2b40e 100644 --- a/src/core/LocCommands.java +++ b/src/core/LocCommands.java @@ -25,9 +25,9 @@ public class LocCommands extends BaseLocFile { instance = this; - UpdateLocFromDisk(); - ScrapeAll(); - SaveLocToDisk(); + updateLocFromDisk(); + scrapeAll(); + saveLocToDisk(); fileMonitor = new FileMonitor(filename); } @@ -40,19 +40,19 @@ public class LocCommands extends BaseLocFile // Returns a pair, the raw key and the stub key public static Pair stub(String toStub) { - return new Pair(toStub, instance.GetKey(toStub)); + return new Pair(toStub, instance.getKey(toStub)); } // Gets all of the un-translated defaults in the commands list. - public static ArrayList GetUnlocalizedCommands() + public static ArrayList getUnlocalizedCommands() { ArrayList raw = new ArrayList<>(); instance.stringStore.forEach((pair) -> raw.add((String)((Pair)pair).First )); return raw; } - public static void Upkeep() + public static void upkeep() { - instance.Update(); + instance.update(); } } diff --git a/src/core/LocStrings.java b/src/core/LocStrings.java index 642a75a..95f1594 100644 --- a/src/core/LocStrings.java +++ b/src/core/LocStrings.java @@ -24,9 +24,9 @@ public class LocStrings extends BaseLocFile { instance = this; - UpdateLocFromDisk(); - ScrapeAll(); - SaveLocToDisk(); + updateLocFromDisk(); + scrapeAll(); + saveLocToDisk(); fileMonitor = new FileMonitor(filename); } @@ -38,17 +38,17 @@ public class LocStrings extends BaseLocFile public static String stub(String toStub) { - return Lookup(toStub); + return lookup(toStub); } // Won't be picked up when scraping - public static String Lookup(String stubbedPreviously) + public static String lookup(String stubbedPreviously) { - return instance.GetKey(stubbedPreviously); + return instance.getKey(stubbedPreviously); } - public static void Upkeep() + public static void upkeep() { - instance.Update(); + instance.update(); } } \ No newline at end of file diff --git a/src/core/ObjectBuilderFactory.java b/src/core/ObjectBuilderFactory.java index 140204e..87cc63a 100644 --- a/src/core/ObjectBuilderFactory.java +++ b/src/core/ObjectBuilderFactory.java @@ -67,7 +67,7 @@ public class ObjectBuilderFactory private static JDA kitty; // This is it, this is how the lazy init starts! - private static void LazyInit() + private static void lazyInit() { if(hasInitialized) return; @@ -111,7 +111,7 @@ public class ObjectBuilderFactory // Explicitly locks: guildCache public static KittyGuild extractGuild(GuildMessageReceivedEvent event) { - LazyInit(); + lazyInit(); // Look up the guild. This process can only happen in a single-threaded way // because of the nature of the cache. We wait until the last second to @@ -155,7 +155,7 @@ public class ObjectBuilderFactory // Explicitly locks: guildCache public static KittyRole extractRole(GuildMessageReceivedEvent event) { - LazyInit(); + lazyInit(); // Looks up the user role. If none is found we check to see if they own // the guild if not, they're assumed to be @@ -182,7 +182,7 @@ public class ObjectBuilderFactory // Extracts the content rating information it can from the provided event. public static KittyRating extractContentRating(GuildMessageReceivedEvent event) { - LazyInit(); + lazyInit(); // Look up content rating of the guild, returns a safe content rating. KittyRating contentRating = KittyRating.Safe; @@ -200,7 +200,7 @@ public class ObjectBuilderFactory // Implicitly locks guild cache by calling ExtractGuild public static KittyChannel extractChannel(GuildMessageReceivedEvent event) { - LazyInit(); + lazyInit(); String channelID = event.getChannel().getId(); String guildID = event.getGuild().getId(); @@ -228,7 +228,7 @@ public class ObjectBuilderFactory // Implicitly locks guild cache by calling ExtractRole and ExtractGuild public static KittyUser extractUser(GuildMessageReceivedEvent event) { - LazyInit(); + lazyInit(); String uid = event.getGuild().getId() + event.getAuthor().getId(); KittyUser user = null; @@ -280,7 +280,7 @@ public class ObjectBuilderFactory // TODO: Clean up public static KittyUser extractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID) { - LazyInit(); + lazyInit(); String uid = guildID + userID; KittyUser user = null; @@ -332,6 +332,7 @@ public class ObjectBuilderFactory return user; } + // Updates a user's name appropriately based on nickname if available public static void updateUser(KittyUser user, Member member) { if(member.getNickname() == null) @@ -350,10 +351,10 @@ public class ObjectBuilderFactory ////////////////////////// // Construction Methods // ////////////////////////// - - public static KittyCore ConstructKittyCore() throws LoginException, InterruptedException + // Builds the core of the bot + public static KittyCore constructKittyCore() throws LoginException, InterruptedException { - LazyInit(); + lazyInit(); kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking(); kitty.getPresence().setGame(Game.playing("with digital yarn")); @@ -368,75 +369,75 @@ public class ObjectBuilderFactory // only have one CommandEnabler. public static CommandManager constructCommandManager(CommandEnabler commandEnabler) { - LazyInit(); + lazyInit(); CommandManager manager = new CommandManager(commandEnabler); // Dev - manager.Register(LocCommands.stub("work"), new CommandDoWork(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("shutdown"), new CommandShutdown(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("stats"), new CommandStats(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("invite"), new CommandInvite(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe)); - manager.Register(LocCommands.stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("work"), new CommandDoWork(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("shutdown"), new CommandShutdown(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("stats"), new CommandStats(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("invite"), new CommandInvite(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe)); + manager.register(LocCommands.stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe)); // Admin - manager.Register(LocCommands.stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe)); - manager.Register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe)); - manager.Register(LocCommands.stub("guildroleallowed"), new CommandGuildRoleAllowed(KittyRole.Admin, KittyRating.Safe)); - manager.Register(LocCommands.stub("guildrolenotallowed"), new CommandGuildRoleNotAllowed(KittyRole.Admin, KittyRating.Safe)); + manager.register(LocCommands.stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe)); + manager.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe)); + manager.register(LocCommands.stub("guildroleallowed"), new CommandGuildRoleAllowed(KittyRole.Admin, KittyRating.Safe)); + manager.register(LocCommands.stub("guildrolenotallowed"), new CommandGuildRoleNotAllowed(KittyRole.Admin, KittyRating.Safe)); // Mod - manager.Register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe)); - manager.Register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe)); - manager.Register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe)); - manager.Register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe)); - manager.Register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe)); - manager.Register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe)); + manager.register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe)); // General - manager.Register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("guildroleadd"), new CommandGuildRoleAdd(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("guildroleremove"), new CommandGuildRoleRemove(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("teey"), new CommandTeey(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("perish, thenperish"), new CommandPerish(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("yeet"), new CommandYeet(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("ping"), new CommandPing(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("boop"), new CommandBoop(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("roll"), new CommandRoll(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("beans"), new CommandBeansShow(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("role"), new CommandRole(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("bet"), new CommandBetBeans(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("map"), new CommandMap(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("rpstart"), new CommandRPStart(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("rpend"), new CommandRPEnd(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("tony, stark, dontfeelgood, dontfeelsogood"), new CommandStark(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("blur"), new CommandBlurry(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("eightball, 8ball"), new CommandEightBall(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("catch"), new CommandCatch(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("guildrolelist"), new CommandGuildRoleList(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("charactercreate"), new CommandCharacterCreate(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("searchcharacter"), new CommandCharacterSearch(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("charactereditbio"), new CommandCharacterEditBio(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("charactereditname"), new CommandCharacterEditName(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("charactereditURL"), new CommandCharacterEditURL(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe)); - manager.Register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("guildroleadd"), new CommandGuildRoleAdd(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("guildroleremove"), new CommandGuildRoleRemove(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("teey"), new CommandTeey(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("perish, thenperish"), new CommandPerish(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("yeet"), new CommandYeet(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("ping"), new CommandPing(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("boop"), new CommandBoop(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("roll"), new CommandRoll(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("beans"), new CommandBeansShow(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("role"), new CommandRole(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("bet"), new CommandBetBeans(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("map"), new CommandMap(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("rpstart"), new CommandRPStart(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("rpend"), new CommandRPEnd(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("tony, stark, dontfeelgood, dontfeelsogood"), new CommandStark(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("blur"), new CommandBlurry(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("eightball, 8ball"), new CommandEightBall(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("catch"), new CommandCatch(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("guildrolelist"), new CommandGuildRoleList(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("charactercreate"), new CommandCharacterCreate(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("searchcharacter"), new CommandCharacterSearch(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("charactereditbio"), new CommandCharacterEditBio(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("charactereditname"), new CommandCharacterEditName(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("charactereditURL"), new CommandCharacterEditURL(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe)); + manager.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe)); return manager; } @@ -444,7 +445,7 @@ public class ObjectBuilderFactory // Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does. public static CommandEnabler constructCommandEnabler() { - LazyInit(); + lazyInit(); if(commandEnabler == null) commandEnabler = new CommandEnabler(); @@ -458,7 +459,7 @@ public class ObjectBuilderFactory // Effectively we cache the database here. public static DatabaseManager constructDatabaseManager() { - LazyInit(); + lazyInit(); if(database == null) database = new DatabaseManager(); @@ -468,7 +469,7 @@ public class ObjectBuilderFactory public static Stats constructStats(CommandManager manager) { - LazyInit(); + lazyInit(); if(stats == null) stats = new Stats(manager); @@ -478,7 +479,7 @@ public class ObjectBuilderFactory public static RPManager constructRPManager() { - LazyInit(); + lazyInit(); if(rpManager == null) rpManager = new RPManager(); @@ -488,7 +489,7 @@ public class ObjectBuilderFactory public static PluginManager constructPluginManager() { - LazyInit(); + lazyInit(); if(pluginManager == null) pluginManager = new PluginManager("./plugins/"); diff --git a/src/core/RPManager.java b/src/core/RPManager.java index 1fe718d..91c7a05 100644 --- a/src/core/RPManager.java +++ b/src/core/RPManager.java @@ -55,7 +55,7 @@ public class RPManager return log; } - public static void Upkeep(KittyCore kitty) + public static void upkeep(KittyCore kitty) { Response res = new Response(null, kitty); String reminder = ""; diff --git a/src/core/Stats.java b/src/core/Stats.java index 25aa46e..4c7353c 100644 --- a/src/core/Stats.java +++ b/src/core/Stats.java @@ -43,12 +43,12 @@ public class Stats osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); } - public void NoteMessageEvent() + public void noteMessageEvent() { ++messagesSeen; } - public void IndicateShutdown() + public void indicateShutdown() { synchronized(instance) { @@ -56,7 +56,7 @@ public class Stats } } - public boolean GetIsShuttingDown() + public boolean getIsShuttingDown() { synchronized(instance) { @@ -69,7 +69,7 @@ public class Stats ///////////////////////////////////////// // Formatted as HH:MM:SS - public String GetFormattedUptime() + public String getFormattedUptime() { long dif = System.currentTimeMillis() - initTimeMS; @@ -80,48 +80,48 @@ public class Stats } // Get number of commands that kitty has run! - public long GetCommandsProcessed() + public long getCommandsProcessed() { - return commandManager.GetInvokeCount(); + return commandManager.getInvokeCount(); } - public long GetMessagesSeen() + public long getMessagesSeen() { return messagesSeen; } - public double GetSystemCPULoad() + public double getSystemCPULoad() { return osBean.getSystemLoadAverage(); } - public long GetCPUAvailable() + public long getCPUAvailable() { return osBean.getAvailableProcessors(); } - public ThreadData GetThreadData() + public ThreadData getThreadData() { - return commandManager.DumpThreadData(); + return commandManager.dumpThreadData(); } - public int GetGuildCount() + public int getGuildCount() { return ObjectBuilderFactory.getGuildCount(); } - public int GetUserCount() + public int getUserCount() { return ObjectBuilderFactory.getUserCount(); } - public ArrayList GetAllCommands() + public ArrayList getAllCommands() { - return commandManager.GetAllRegisteredCommands(); + return commandManager.getAllRegisteredCommands(); } - public String GetHelpText(String commandName) + public String getHelpText(String commandName) { - return commandManager.GetCommandHelpText(commandName); + return commandManager.getCommandHelpText(commandName); } } diff --git a/src/main/Main.java b/src/main/Main.java index 8c1310c..c0387a8 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -57,7 +57,7 @@ public class Main extends ListenerAdapter pluginManager = ObjectBuilderFactory.constructPluginManager(); // Bot startup - kittyCore = ObjectBuilderFactory.ConstructKittyCore(); + kittyCore = ObjectBuilderFactory.constructKittyCore(); } // When a message is sent in a server that kitty is in, this is what's called. @@ -65,7 +65,7 @@ public class Main extends ListenerAdapter public void onGuildMessageReceived(GuildMessageReceivedEvent event) { // Tweak the event as necessary - if(!Superintendent.PreProcessSetup(event, stats)) + if(!Superintendent.preProcessSetup(event, stats)) return; // Factory objects @@ -78,7 +78,7 @@ public class Main extends ListenerAdapter UserInput input = new UserInput(event, guild); // Tweak object construction as necessary - if(!Superintendent.PostProcessSetup(event, user, guild, channel, response, input)) + if(!Superintendent.postProcessSetup(event, user, guild, channel, response, input)) return; // Track beans! @@ -88,11 +88,11 @@ public class Main extends ListenerAdapter RPManager.instance.addLine(channel, user, input); // Run any pre-emptive upkeep we need to - Superintendent.PerCommandUpkeepPre(); + Superintendent.perCommandUpkeepPre(); // Attempt to spin up a command. If the command doesn't exist. // Run plugins right before invoking the commands but after all other setup. - if(commandManager.InvokeOnNewThread(guild, channel, user, input, response) == false) + if(commandManager.invokeOnNewThread(guild, channel, user, input, response) == false) { List pluginOutput = pluginManager.runAll(input.message, user); @@ -102,7 +102,7 @@ public class Main extends ListenerAdapter { if(pluginOutput.get(i).startsWith("!")) { - commandManager.InvokeOnNewThread(guild, channel, user, new UserInput(pluginOutput.get(i).substring(1), guild), response); + commandManager.invokeOnNewThread(guild, channel, user, new UserInput(pluginOutput.get(i).substring(1), guild), response); } else { @@ -113,6 +113,6 @@ public class Main extends ListenerAdapter } // Run any upkeep in post we need to - Superintendent.PerCommandUpkeepPost(kittyCore, databaseManager); + Superintendent.perCommandUpkeepPost(kittyCore, databaseManager); } } \ No newline at end of file diff --git a/src/main/Superintendent.java b/src/main/Superintendent.java index c3c4797..aae634c 100644 --- a/src/main/Superintendent.java +++ b/src/main/Superintendent.java @@ -21,17 +21,17 @@ import offline.Ref; public class Superintendent { // This is run on the JDA GuildMessageReceivedEvent before anything else happens. - public static boolean PreProcessSetup(GuildMessageReceivedEvent event, Stats stats) + public static boolean preProcessSetup(GuildMessageReceivedEvent event, Stats stats) { // Verify we have an event if(event == null) return false; // Track number of messages seen - stats.NoteMessageEvent(); + stats.noteMessageEvent(); // If we're mid-shutdown, no more commands. - if(stats.GetIsShuttingDown()) + if(stats.getIsShuttingDown()) return false; // Swat down highest ban level immediately before even hitting command parsing. @@ -47,7 +47,7 @@ public class Superintendent // This runs after all the objects have been constructed! // Modifications to objects here stick! - public static boolean PostProcessSetup(GuildMessageReceivedEvent event, KittyUser user, KittyGuild guild, KittyChannel channel, Response res, UserInput input) + public static boolean postProcessSetup(GuildMessageReceivedEvent event, KittyUser user, KittyGuild guild, KittyChannel channel, Response res, UserInput input) { // Verify we have everything. From here out, we promise we have that all. if(event == null || user == null || guild == null || channel == null || res == null || input == null) @@ -72,11 +72,11 @@ public class Superintendent // Only called once per command. Good for lazily updating. // Happens just before the command / plugin runs. - public static boolean PerCommandUpkeepPre() + public static boolean perCommandUpkeepPre() { // Upkeep localization system's file monitoring - LocStrings.Upkeep(); - LocCommands.Upkeep(); + LocStrings.upkeep(); + LocCommands.upkeep(); return true; } @@ -87,7 +87,7 @@ public class Superintendent // This is for stuff that we need to do on a regular basis, but don't // necessarily want running at all points in time. // Happens just after the command / plugin runs. - public static boolean PerCommandUpkeepPost(KittyCore kittyCore, DatabaseManager databaseManager) + public static boolean perCommandUpkeepPost(KittyCore kittyCore, DatabaseManager databaseManager) { // Upkeep database lazily on occasion if(delayTimerCurrent.decrementAndGet() < 0) @@ -97,7 +97,7 @@ public class Superintendent } // Update command-specific - RPManager.Upkeep(kittyCore); + RPManager.upkeep(kittyCore); return true; }