= Capitalization cleanup

This commit is contained in:
Matthew Cech
2019-06-02 17:41:09 -07:00
parent aa25345ba3
commit ff399b138d
3 changed files with 40 additions and 31 deletions
+29 -20
View File
@@ -48,7 +48,7 @@ public class ObjectBuilderFactory
// Handles if we can or can't use specific commands, parsing a config file based on loc data to do so. // Handles if we can or can't use specific commands, parsing a config file based on loc data to do so.
private static CommandEnabler commandEnabler; private static CommandEnabler commandEnabler;
// Lazy initialization multithreaded mutex stuff to prevent explosions. // Lazy initialization multithreaded mutex stuff to prevent explosions.
// TODO: Investigate using 'synchronized' instead potentially // TODO: Investigate using 'synchronized' instead potentially
private static boolean hasInitialized; private static boolean hasInitialized;
@@ -97,7 +97,7 @@ public class ObjectBuilderFactory
//////////////////////// ////////////////////////
// Explicitly locks: guildCache // Explicitly locks: guildCache
public static KittyGuild ExtractGuild(GuildMessageReceivedEvent event) public static KittyGuild extractGuild(GuildMessageReceivedEvent event)
{ {
LazyInit(); LazyInit();
@@ -117,6 +117,7 @@ public class ObjectBuilderFactory
emoteFix += ":" + emote.substring(emote.indexOf("(")+1, emote.length()-1) + ">"; emoteFix += ":" + emote.substring(emote.indexOf("(")+1, emote.length()-1) + ">";
emotesString.add(emoteFix); emotesString.add(emoteFix);
} }
// once we're lazily initialized, we can synchronize w/ the // once we're lazily initialized, we can synchronize w/ the
// guildCache object now instead of having to use a mutex. // guildCache object now instead of having to use a mutex.
KittyGuild guild = null; KittyGuild guild = null;
@@ -140,7 +141,7 @@ public class ObjectBuilderFactory
} }
// Explicitly locks: guildCache // Explicitly locks: guildCache
public static KittyRole ExtractRole(GuildMessageReceivedEvent event) public static KittyRole extractRole(GuildMessageReceivedEvent event)
{ {
LazyInit(); LazyInit();
@@ -167,7 +168,7 @@ public class ObjectBuilderFactory
// Explicitly locks: guildCache // Explicitly locks: guildCache
// Extracts the content rating information it can from the provided event. // Extracts the content rating information it can from the provided event.
public static KittyRating ExtractContentRating(GuildMessageReceivedEvent event) public static KittyRating extractContentRating(GuildMessageReceivedEvent event)
{ {
LazyInit(); LazyInit();
@@ -185,7 +186,7 @@ public class ObjectBuilderFactory
} }
// Implicitly locks guild cache by calling ExtractGuild // Implicitly locks guild cache by calling ExtractGuild
public static KittyChannel ExtractChannel(GuildMessageReceivedEvent event) public static KittyChannel extractChannel(GuildMessageReceivedEvent event)
{ {
LazyInit(); LazyInit();
@@ -213,7 +214,7 @@ public class ObjectBuilderFactory
} }
// Implicitly locks guild cache by calling ExtractRole and ExtractGuild // Implicitly locks guild cache by calling ExtractRole and ExtractGuild
public static KittyUser ExtractUser(GuildMessageReceivedEvent event) public static KittyUser extractUser(GuildMessageReceivedEvent event)
{ {
LazyInit(); LazyInit();
@@ -229,8 +230,8 @@ public class ObjectBuilderFactory
} }
else else
{ {
KittyRole role = ExtractRole(event); KittyRole role = extractRole(event);
KittyGuild guild = ExtractGuild(event); KittyGuild guild = extractGuild(event);
String name; String name;
if(event.getMember().getNickname() == null) if(event.getMember().getNickname() == null)
@@ -254,17 +255,17 @@ public class ObjectBuilderFactory
{ {
mentioned = event.getMessage().getMentionedMembers().get(i); mentioned = event.getMessage().getMentionedMembers().get(i);
if(mentioned.getNickname() != null) if(mentioned.getNickname() != null)
ExtractUserByJDAUser(event.getGuild().getId(), mentioned.getNickname(), extractUserByJDAUser(event.getGuild().getId(), mentioned.getNickname(),
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId()); mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
else else
ExtractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(), extractUserByJDAUser(event.getGuild().getId(), mentioned.getUser().getName(),
mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId()); mentioned.getUser().getId(), mentioned.getUser().getAvatarUrl(), mentioned.getUser().getId());
} }
return user; return user;
} }
public static KittyUser ExtractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID) public static KittyUser extractUserByJDAUser(String guildID, String name, String userID, String avatarID, String discordID)
{ {
LazyInit(); LazyInit();
@@ -277,6 +278,7 @@ public class ObjectBuilderFactory
{ {
if(name != null) if(name != null)
cachedUser.name = name; cachedUser.name = name;
cachedUser.avatarID = avatarID; cachedUser.avatarID = avatarID;
user = cachedUser; user = cachedUser;
} }
@@ -301,19 +303,25 @@ public class ObjectBuilderFactory
{ {
user = userCache.get(uid); user = userCache.get(uid);
} }
return user; return user;
} }
public static void updateUser(KittyUser user, Member member) public static void updateUser(KittyUser user, Member member)
{ {
if(member.getNickname() == null) if(member.getNickname() == null)
{
user.name = member.getUser().getName(); user.name = member.getUser().getName();
}
else else
{
user.name = member.getNickname(); user.name = member.getNickname();
}
user.avatarID = member.getUser().getAvatarUrl(); user.avatarID = member.getUser().getAvatarUrl();
} }
////////////////////////// //////////////////////////
// Construction Methods // // Construction Methods //
////////////////////////// //////////////////////////
@@ -322,7 +330,7 @@ public class ObjectBuilderFactory
// and disabling, what we do is construct the commands with a localized pair that is checked against // and disabling, what we do is construct the commands with a localized pair that is checked against
// the CommandEnabler object passed in. In theory, we could have multiple CommandManagers, tho we can // the CommandEnabler object passed in. In theory, we could have multiple CommandManagers, tho we can
// only have one CommandEnabler. // only have one CommandEnabler.
public static CommandManager ConstructCommandManager(CommandEnabler commandEnabler) public static CommandManager constructCommandManager(CommandEnabler commandEnabler)
{ {
LazyInit(); LazyInit();
@@ -391,7 +399,7 @@ public class ObjectBuilderFactory
} }
// Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does. // Constructs a CommandEnabler if it doesn't exist, and gets the existing one if it does.
public static CommandEnabler ConstructCommandEnabler() public static CommandEnabler constructCommandEnabler()
{ {
LazyInit(); LazyInit();
@@ -405,7 +413,7 @@ public class ObjectBuilderFactory
// in different ways, and so we construct it outside of the constructor for // in different ways, and so we construct it outside of the constructor for
// the factory since it doesn't have to be present / can be elsewhere. // the factory since it doesn't have to be present / can be elsewhere.
// Effectively we cache the database here. // Effectively we cache the database here.
public static DatabaseManager ConstructDatabaseManager() public static DatabaseManager constructDatabaseManager()
{ {
LazyInit(); LazyInit();
@@ -415,7 +423,7 @@ public class ObjectBuilderFactory
return database; return database;
} }
public static Stats ConstructStats(CommandManager manager) public static Stats constructStats(CommandManager manager)
{ {
LazyInit(); LazyInit();
@@ -425,7 +433,7 @@ public class ObjectBuilderFactory
return stats; return stats;
} }
public static RPManager ConstructRPManager() public static RPManager constructRPManager()
{ {
LazyInit(); LazyInit();
@@ -435,7 +443,7 @@ public class ObjectBuilderFactory
return rpManager; return rpManager;
} }
public static PluginManager ConstructPluginManager() public static PluginManager constructPluginManager()
{ {
LazyInit(); LazyInit();
@@ -444,13 +452,14 @@ public class ObjectBuilderFactory
return pluginManager; return pluginManager;
} }
///////////////////// /////////////////////
// Utility Methods // // Utility Methods //
///////////////////// /////////////////////
// Returns number of cached guilds (does not equal total users in the database, only what's in memory) // Returns number of cached guilds (does not equal total users in the database, only what's in memory)
public static Integer GetGuildCount() public static Integer getGuildCount()
{ synchronized(guildCache) { synchronized(guildCache)
{ {
return guildCache.size(); return guildCache.size();
@@ -458,7 +467,7 @@ public class ObjectBuilderFactory
} }
// Returns number of cached users (does not equal total users in the database, only what's in memory) // Returns number of cached users (does not equal total users in the database, only what's in memory)
public static Integer GetUserCount() public static Integer getUserCount()
{ synchronized(userCache) { synchronized(userCache)
{ {
return userCache.size(); return userCache.size();
+2 -2
View File
@@ -107,12 +107,12 @@ public class Stats
public int GetGuildCount() public int GetGuildCount()
{ {
return ObjectBuilderFactory.GetGuildCount(); return ObjectBuilderFactory.getGuildCount();
} }
public int GetUserCount() public int GetUserCount()
{ {
return ObjectBuilderFactory.GetUserCount(); return ObjectBuilderFactory.getUserCount();
} }
public ArrayList<Command> GetAllCommands() public ArrayList<Command> GetAllCommands()
+9 -9
View File
@@ -40,12 +40,12 @@ public class Main extends ListenerAdapter
{ {
// Factory startup. The ordering is intentional. // Factory startup. The ordering is intentional.
GlobalLog.initialize(); GlobalLog.initialize();
databaseManager = ObjectBuilderFactory.ConstructDatabaseManager(); databaseManager = ObjectBuilderFactory.constructDatabaseManager();
commandEnabler = ObjectBuilderFactory.ConstructCommandEnabler(); commandEnabler = ObjectBuilderFactory.constructCommandEnabler();
commandManager = ObjectBuilderFactory.ConstructCommandManager(commandEnabler); commandManager = ObjectBuilderFactory.constructCommandManager(commandEnabler);
stats = ObjectBuilderFactory.ConstructStats(commandManager); stats = ObjectBuilderFactory.constructStats(commandManager);
rpManager = ObjectBuilderFactory.ConstructRPManager(); rpManager = ObjectBuilderFactory.constructRPManager();
pluginManager = ObjectBuilderFactory.ConstructPluginManager(); pluginManager = ObjectBuilderFactory.constructPluginManager();
// Bot startup // Bot startup
kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking(); kitty = new JDABuilder(AccountType.BOT).setToken(Ref.TestToken).buildBlocking();
@@ -62,9 +62,9 @@ public class Main extends ListenerAdapter
return; return;
// Factory objects // Factory objects
KittyUser user = ObjectBuilderFactory.ExtractUser(event); KittyUser user = ObjectBuilderFactory.extractUser(event);
KittyGuild guild = ObjectBuilderFactory.ExtractGuild(event); KittyGuild guild = ObjectBuilderFactory.extractGuild(event);
KittyChannel channel = ObjectBuilderFactory.ExtractChannel(event); KittyChannel channel = ObjectBuilderFactory.extractChannel(event);
// Specialized uncached objects // Specialized uncached objects
Response response = new Response(event, kitty); Response response = new Response(event, kitty);