= Data Structures formatting update

This commit is contained in:
Matthew Cech
2019-06-19 21:32:42 -07:00
parent 78efa4ad8f
commit ba843ca645
22 changed files with 60 additions and 60 deletions
+2 -2
View File
@@ -15,13 +15,13 @@ public class CommandBeansShow extends Command
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)
{ {
if(input.mentions == null) if(input.mentions == null)
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.GetBeans())); res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
else else
{ {
String mentionedBeans = ""; String mentionedBeans = "";
for(KittyUser mentioned:input.mentions) for(KittyUser mentioned:input.mentions)
{ {
mentionedBeans += mentioned.name + " has " + mentioned.GetBeans() + " "; mentionedBeans += mentioned.name + " has " + mentioned.getBeans() + " ";
} }
res.send(String.format(LocStrings.stub("BeansShowMentioned"), mentionedBeans)); res.send(String.format(LocStrings.stub("BeansShowMentioned"), mentionedBeans));
} }
+5 -5
View File
@@ -34,13 +34,13 @@ public class CommandBetBeans extends Command
return; return;
} }
if(user.GetBeans() < bet) if(user.getBeans() < bet)
{ {
res.send(LocStrings.stub("BetBeansNotEnough")); res.send(LocStrings.stub("BetBeansNotEnough"));
return; return;
} }
user.ChangeBeans(-bet); user.changeBeans(-bet);
int [] slots = getSlots(); int [] slots = getSlots();
call += slotString(slots); call += slotString(slots);
slots = sort(slots); slots = sort(slots);
@@ -52,12 +52,12 @@ public class CommandBetBeans extends Command
if(win == 0) if(win == 0)
{ {
res.send(LocStrings.stub("BetBeansLose")); res.send(LocStrings.stub("BetBeansLose"));
guild.beans.Add(bet); guild.beans.add(bet);
return; return;
} }
user.ChangeBeans(bet*win); user.changeBeans(bet*win);
guild.beans.Subtract(bet*win); guild.beans.subtract(bet*win);
res.send(String.format(LocStrings.stub("BetBeansWin"), "" + (bet*win))); res.send(String.format(LocStrings.stub("BetBeansWin"), "" + (bet*win)));
} }
+1 -1
View File
@@ -20,6 +20,6 @@ public class CommandBetHistory extends Command
@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
View File
@@ -49,7 +49,7 @@ public class CommandGiveBeans extends Command
// Go through all the mentions and make sure every user is given beans! // Go through all the mentions and make sure every user is given beans!
for(int i = 0; i < input.mentions.length; i++) for(int i = 0; i < input.mentions.length; i++)
{ {
input.mentions[i].ChangeBeans(beans); input.mentions[i].changeBeans(beans);
res.send(String.format(LocStrings.stub("GiveBeansSuccess"), input.mentions[i].name, "" + beans)); res.send(String.format(LocStrings.stub("GiveBeansSuccess"), input.mentions[i].name, "" + beans));
} }
} }
+3 -3
View File
@@ -16,11 +16,11 @@ public class CommandRole extends Command
{ {
if(input.args.isEmpty()) if(input.args.isEmpty())
{ {
res.send(LocStrings.stub("RoleStandardResponse") + " " + user.GetRole().name() + "!"); res.send(LocStrings.stub("RoleStandardResponse") + " " + user.getRole().name() + "!");
return; return;
} }
if(user.GetRole().getValue() < KittyRole.Admin.getValue()) if(user.getRole().getValue() < KittyRole.Admin.getValue())
{ {
res.send(String.format(LocStrings.stub("RoleError"), KittyRole.Admin.toString())); res.send(String.format(LocStrings.stub("RoleError"), KittyRole.Admin.toString()));
return; return;
@@ -52,7 +52,7 @@ public class CommandRole extends Command
String users = ""; String users = "";
for(int i = 0; i < input.mentions.length; i++) for(int i = 0; i < input.mentions.length; i++)
{ {
input.mentions[i].ChangeRole(newRole); input.mentions[i].changeRole(newRole);
users += input.mentions[i].name + " "; users += input.mentions[i].name + " ";
} }
+4 -4
View File
@@ -36,7 +36,7 @@ public class CommandTradeBeans extends Command
return; return;
} }
if(user.GetBeans() < beans) if(user.getBeans() < beans)
{ {
res.send(LocStrings.stub("TradeBeansNotEnoughError")); res.send(LocStrings.stub("TradeBeansNotEnoughError"));
return; return;
@@ -45,12 +45,12 @@ public class CommandTradeBeans extends Command
if(beans < 0) if(beans < 0)
{ {
res.send(String.format(LocStrings.stub("TradeBeansStealingBeans"), user.name)); res.send(String.format(LocStrings.stub("TradeBeansStealingBeans"), user.name));
user.ChangeBeans(-10); user.changeBeans(-10);
return; return;
} }
input.mentions[0].ChangeBeans(beans); input.mentions[0].changeBeans(beans);
user.ChangeBeans(-beans); user.changeBeans(-beans);
res.send(String.format(LocStrings.stub("TradeBeansSuccess"), user.name, input.mentions[0].name, beans)); res.send(String.format(LocStrings.stub("TradeBeansSuccess"), user.name, input.mentions[0].name, beans));
} }
} }
+2 -2
View File
@@ -121,7 +121,7 @@ public abstract class BaseLocFile
if(stringStore == null) if(stringStore == null)
return input; return input;
String value = stringStore.GetKey(input); String value = stringStore.getKey(input);
if(value == null || value.trim().length() < 1) if(value == null || value.trim().length() < 1)
return input; return input;
@@ -206,6 +206,6 @@ public abstract class BaseLocFile
FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> TryStripSpecified(path, localizeList)); FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> TryStripSpecified(path, localizeList));
for(LocInfo toStub : localizeList) for(LocInfo toStub : localizeList)
stringStore.AddKeyValue(toStub.file, toStub.phrase, toStub.phrase); stringStore.addKeyValue(toStub.file, toStub.phrase, toStub.phrase);
} }
} }
+2 -2
View File
@@ -66,8 +66,8 @@ public class CharacterManager
} }
} }
characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.Get())); characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.get()));
uniqueID.Add(1); uniqueID.add(1);
return true; return true;
} }
+1 -1
View File
@@ -43,7 +43,7 @@ public abstract class Command
//TODO: ADD CHANNEL CHECK HERE //TODO: ADD CHANNEL CHECK HERE
if(user.GetRole().getValue() >= roleLevel.getValue()) if(user.getRole().getValue() >= roleLevel.getValue())
{ {
return true; return true;
} }
+2 -2
View File
@@ -77,7 +77,7 @@ public class CommandManager
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. // This is here to prevent spinning up a thread if this wasn't even a command.
if(input == null || !input.IsValid()) if(input == null || !input.isValid())
return false; return false;
Command command = commands.get(input.key); Command command = commands.get(input.key);
@@ -99,7 +99,7 @@ public class CommandManager
// Calls the command specified with the key, providing user information arguments, etc. // 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()) if(input == null || !input.isValid())
return; return;
Command command = commands.get(input.key); Command command = commands.get(input.key);
+1 -1
View File
@@ -47,7 +47,7 @@ public class LocCommands extends BaseLocFile
public static ArrayList<String> GetUnlocalizedCommands() public static ArrayList<String> GetUnlocalizedCommands()
{ {
ArrayList<String> raw = new ArrayList<>(); ArrayList<String> raw = new ArrayList<>();
instance.stringStore.ForEach((pair) -> raw.add((String)((Pair<?, ?>)pair).First )); instance.stringStore.forEach((pair) -> raw.add((String)((Pair<?, ?>)pair).First ));
return raw; return raw;
} }
+1 -1
View File
@@ -172,7 +172,7 @@ public class ObjectBuilderFactory
{ {
KittyUser cachedUser = userCache.get(uid); KittyUser cachedUser = userCache.get(uid);
if(cachedUser != null) if(cachedUser != null)
role = cachedUser.GetRole(); role = cachedUser.getRole();
} }
return role; return role;
+1 -1
View File
@@ -39,7 +39,7 @@ public class RPManager
public void addLine(KittyChannel channel, KittyUser user, UserInput input) public void addLine(KittyChannel channel, KittyUser user, UserInput input)
{ {
if(logs.containsKey(Long.parseLong(channel.uniqueID)) && !input.IsValid()) if(logs.containsKey(Long.parseLong(channel.uniqueID)) && !input.isValid())
logs.get(Long.parseLong(channel.uniqueID)).addLine(user, input.message); logs.get(Long.parseLong(channel.uniqueID)).addLine(user, input.message);
} }
+2 -2
View File
@@ -18,13 +18,13 @@ public class KittyChannel //extends DatabaseTrackedObject
} }
// @Override // @Override
// public String Serialize() // public String serialize()
// { // {
// return ""; // return "";
// } // }
// //
// @Override // @Override
// public void DeSerialzie(String string) // public void deSerialzie(String string)
// { // {
// //
// } // }
+2 -2
View File
@@ -119,9 +119,9 @@ public class KittyGuild extends DatabaseTrackedObject
public boolean joinRaffle(KittyUser user) public boolean joinRaffle(KittyUser user)
{ {
if(!raffleUsersChosen.contains(user) && !raffleUsersUnchosen.contains(user) && user.GetBeans() > raffleCost && raffling) if(!raffleUsersChosen.contains(user) && !raffleUsersUnchosen.contains(user) && user.getBeans() > raffleCost && raffling)
{ {
user.ChangeBeans(raffleCost); user.changeBeans(raffleCost);
raffleUsersUnchosen.add(user); raffleUsersUnchosen.add(user);
return true; return true;
} }
+1 -1
View File
@@ -45,7 +45,7 @@ public class KittyRP
public File endRP(KittyUser user) throws FileNotFoundException, UnsupportedEncodingException public File endRP(KittyUser user) throws FileNotFoundException, UnsupportedEncodingException
{ {
if(!users.contains(Long.parseLong(user.discordID)) && user.GetRole().getValue() < 2) if(!users.contains(Long.parseLong(user.discordID)) && user.getRole().getValue() < 2)
{ {
return null; return null;
} }
+4 -4
View File
@@ -27,26 +27,26 @@ public class KittyTrackedLong extends DatabaseTrackedObject
super(differentiator + readableName + UniqueID); super(differentiator + readableName + UniqueID);
} }
public long Add(long toAdd) public long add(long toAdd)
{ {
tracked += toAdd; tracked += toAdd;
markDirty(); markDirty();
return tracked; return tracked;
} }
public long Subtract(long toSubtract) public long subtract(long toSubtract)
{ {
tracked -= toSubtract; tracked -= toSubtract;
markDirty(); markDirty();
return tracked; return tracked;
} }
public long Get() public long get()
{ {
return tracked; return tracked;
} }
public long Set(long newValue) public long set(long newValue)
{ {
tracked = newValue; tracked = newValue;
markDirty(); markDirty();
+4 -4
View File
@@ -31,7 +31,7 @@ public class KittyUser extends DatabaseTrackedObject
} }
// Can be positive or negative // Can be positive or negative
public void ChangeBeans(int amount) public void changeBeans(int amount)
{ {
beans += amount; beans += amount;
@@ -39,7 +39,7 @@ public class KittyUser extends DatabaseTrackedObject
markDirty(); markDirty();
} }
public void ChangeRole(KittyRole newRole) public void changeRole(KittyRole newRole)
{ {
if(newRole != role) if(newRole != role)
{ {
@@ -48,12 +48,12 @@ public class KittyUser extends DatabaseTrackedObject
} }
} }
public long GetBeans() public long getBeans()
{ {
return beans; return beans;
} }
public KittyRole GetRole() public KittyRole getRole()
{ {
return role; return role;
} }
+11 -11
View File
@@ -39,12 +39,12 @@ public class TaggedPairStore
{ {
taggedPairs = new HashMap<String, HashMap<String, String>>(); taggedPairs = new HashMap<String, HashMap<String, String>>();
allPairs = new HashMap<String, String>(); allPairs = new HashMap<String, String>();
Parse(input); parse(input);
} }
// Calls back on each item in the entire structure. Provides section, then a pair of the keyString and valueString. // Calls back on each item in the entire structure. Provides section, then a pair of the keyString and valueString.
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
public void ForEach(BiConsumer<? super String, Pair<? super String, ? super String>> action) public void forEach(BiConsumer<? super String, Pair<? super String, ? super String>> action)
{ {
Iterator it = taggedPairs.entrySet().iterator(); Iterator it = taggedPairs.entrySet().iterator();
while (it.hasNext()) while (it.hasNext())
@@ -62,7 +62,7 @@ public class TaggedPairStore
// Calls back each item in the structure but does not priv // Calls back each item in the structure but does not priv
@SuppressWarnings({"rawtypes"}) @SuppressWarnings({"rawtypes"})
public void ForEach(Consumer<Pair<? super String, ? super String>> action) public void forEach(Consumer<Pair<? super String, ? super String>> action)
{ {
Iterator it = allPairs.entrySet().iterator(); Iterator it = allPairs.entrySet().iterator();
while (it.hasNext()) while (it.hasNext())
@@ -123,7 +123,7 @@ public class TaggedPairStore
// Parses out the string passed in into the sectionkeyValue HashMap. // Parses out the string passed in into the sectionkeyValue HashMap.
// Any character used in a split call is escaped just in case on // Any character used in a split call is escaped just in case on
// account of some characters having specific regex meanings. // account of some characters having specific regex meanings.
private void Parse(String input) private void parse(String input)
{ {
if(input == null) if(input == null)
return; return;
@@ -143,7 +143,7 @@ public class TaggedPairStore
// Parse section name. If it already exists, don't bother making it. // Parse section name. If it already exists, don't bother making it.
String sectionName = section.substring(0, pos); String sectionName = section.substring(0, pos);
AddSection(sectionName); addSection(sectionName);
// Parse out the pairs within the section, split them all out. // Parse out the pairs within the section, split them all out.
String unparsedPairs = section.substring(pos + 1); String unparsedPairs = section.substring(pos + 1);
@@ -171,7 +171,7 @@ public class TaggedPairStore
// Dumps out a string array // Dumps out a string array
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void Dump(String[] toPrint) private void dump(String[] toPrint)
{ {
System.out.println("Length: " + toPrint.length); System.out.println("Length: " + toPrint.length);
@@ -181,28 +181,28 @@ public class TaggedPairStore
// Adds a KeyValue pair to the specified section if it's not already there. // Adds a KeyValue pair to the specified section if it's not already there.
// Also creates the section if it's not already present. // Also creates the section if it's not already present.
public void AddKeyValue(String sectionName, String key, String value) public void addKeyValue(String sectionName, String key, String value)
{ {
AddSection(sectionName); addSection(sectionName);
taggedPairs.get(sectionName).putIfAbsent(key, value); taggedPairs.get(sectionName).putIfAbsent(key, value);
allPairs.putIfAbsent(key, value); allPairs.putIfAbsent(key, value);
} }
// Adds a given section to the hashmap if it's not already present // Adds a given section to the hashmap if it's not already present
public void AddSection(String sectionName) public void addSection(String sectionName)
{ {
taggedPairs.putIfAbsent(sectionName, new HashMap<String, String>()); taggedPairs.putIfAbsent(sectionName, new HashMap<String, String>());
} }
// Returns a HashMap of Keys to Values for a given section // Returns a HashMap of Keys to Values for a given section
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public HashMap<String, String> GetSection(String sectionName) public HashMap<String, String> getSection(String sectionName)
{ {
return (HashMap<String, String>) taggedPairs.get(sectionName).clone(); return (HashMap<String, String>) taggedPairs.get(sectionName).clone();
} }
// Look up a global key // Look up a global key
public String GetKey(String key) public String getKey(String key)
{ {
if(allPairs.containsKey(key)) if(allPairs.containsKey(key))
return allPairs.get(key); return allPairs.get(key);
+6 -6
View File
@@ -35,13 +35,13 @@ public class UserInput
return; return;
if(!event.getMessage().getMentionedMembers().isEmpty()) if(!event.getMessage().getMentionedMembers().isEmpty())
mentions = FindMentionedUsers(event); mentions = findMentionedUsers(event);
toParse = toParse.trim(); toParse = toParse.trim();
String commandIndicator = guildContext.getCommandIndicator(); String commandIndicator = guildContext.getCommandIndicator();
if(toParse.startsWith(commandIndicator)) if(toParse.startsWith(commandIndicator))
{ {
int loc = FindFirstWhitespace(toParse); int loc = findFirstWhitespace(toParse);
if(loc <= 0) if(loc <= 0)
{ {
@@ -64,19 +64,19 @@ public class UserInput
// Used for injecting direct commands from plugins // Used for injecting direct commands from plugins
public UserInput(String input, KittyGuild contextGuild) public UserInput(String input, KittyGuild contextGuild)
{ {
int loc = FindFirstWhitespace(input); int loc = findFirstWhitespace(input);
key = input.substring(0, loc); key = input.substring(0, loc);
args = input.substring(loc); args = input.substring(loc);
isValid = true; isValid = true;
} }
public boolean IsValid() public boolean isValid()
{ {
return isValid; return isValid;
} }
// Finds first whitespace in the string // Finds first whitespace in the string
private int FindFirstWhitespace(String str) private int findFirstWhitespace(String str)
{ {
for (int i = 0; i < str.length(); ++i) for (int i = 0; i < str.length(); ++i)
{ {
@@ -87,7 +87,7 @@ public class UserInput
return -1; return -1;
} }
private KittyUser[] FindMentionedUsers(GuildMessageReceivedEvent event) private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event)
{ {
List <Member> JDAMentions = event.getMessage().getMentionedMembers(); List <Member> JDAMentions = event.getMessage().getMentionedMembers();
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()]; KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
+1 -1
View File
@@ -82,7 +82,7 @@ public class Main extends ListenerAdapter
return; return;
// Track beans! // Track beans!
user.ChangeBeans(1); user.changeBeans(1);
// RP logging system // RP logging system
RPManager.instance.addLine(channel, user, input); RPManager.instance.addLine(channel, user, input);
+2 -2
View File
@@ -55,14 +55,14 @@ public class Superintendent
// If the guild member is the owner, give them admin role by default. // If the guild member is the owner, give them admin role by default.
if(event.getMember().isOwner()) if(event.getMember().isOwner())
user.ChangeRole(KittyRole.Admin); user.changeRole(KittyRole.Admin);
// Give devs the dev role // Give devs the dev role
for(int i = 0; i < Ref.devIDs.length; ++i) for(int i = 0; i < Ref.devIDs.length; ++i)
{ {
if(event.getAuthor().getId().equals(Ref.devIDs[i])) if(event.getAuthor().getId().equals(Ref.devIDs[i]))
{ {
user.ChangeRole(KittyRole.Dev); user.changeRole(KittyRole.Dev);
break; break;
} }
} }