= 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)
{
if(input.mentions == null)
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.GetBeans()));
res.send(String.format(LocStrings.stub("BeansShowDisplay"), user.getBeans()));
else
{
String mentionedBeans = "";
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));
}
+5 -5
View File
@@ -34,13 +34,13 @@ public class CommandBetBeans extends Command
return;
}
if(user.GetBeans() < bet)
if(user.getBeans() < bet)
{
res.send(LocStrings.stub("BetBeansNotEnough"));
return;
}
user.ChangeBeans(-bet);
user.changeBeans(-bet);
int [] slots = getSlots();
call += slotString(slots);
slots = sort(slots);
@@ -52,12 +52,12 @@ public class CommandBetBeans extends Command
if(win == 0)
{
res.send(LocStrings.stub("BetBeansLose"));
guild.beans.Add(bet);
guild.beans.add(bet);
return;
}
user.ChangeBeans(bet*win);
guild.beans.Subtract(bet*win);
user.changeBeans(bet*win);
guild.beans.subtract(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
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!
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));
}
}
+3 -3
View File
@@ -16,11 +16,11 @@ public class CommandRole extends Command
{
if(input.args.isEmpty())
{
res.send(LocStrings.stub("RoleStandardResponse") + " " + user.GetRole().name() + "!");
res.send(LocStrings.stub("RoleStandardResponse") + " " + user.getRole().name() + "!");
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()));
return;
@@ -52,7 +52,7 @@ public class CommandRole extends Command
String users = "";
for(int i = 0; i < input.mentions.length; i++)
{
input.mentions[i].ChangeRole(newRole);
input.mentions[i].changeRole(newRole);
users += input.mentions[i].name + " ";
}
+4 -4
View File
@@ -36,7 +36,7 @@ public class CommandTradeBeans extends Command
return;
}
if(user.GetBeans() < beans)
if(user.getBeans() < beans)
{
res.send(LocStrings.stub("TradeBeansNotEnoughError"));
return;
@@ -45,12 +45,12 @@ public class CommandTradeBeans extends Command
if(beans < 0)
{
res.send(String.format(LocStrings.stub("TradeBeansStealingBeans"), user.name));
user.ChangeBeans(-10);
user.changeBeans(-10);
return;
}
input.mentions[0].ChangeBeans(beans);
user.ChangeBeans(-beans);
input.mentions[0].changeBeans(beans);
user.changeBeans(-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)
return input;
String value = stringStore.GetKey(input);
String value = stringStore.getKey(input);
if(value == null || value.trim().length() < 1)
return input;
@@ -206,6 +206,6 @@ public abstract class BaseLocFile
FileUtils.AcquireAllFiles(KittySourceDirectory).forEach((path) -> TryStripSpecified(path, 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()));
uniqueID.Add(1);
characters.add(new KittyCharacter(user, name, bio, refImage, uniqueID.get()));
uniqueID.add(1);
return true;
}
+1 -1
View File
@@ -43,7 +43,7 @@ public abstract class Command
//TODO: ADD CHANNEL CHECK HERE
if(user.GetRole().getValue() >= roleLevel.getValue())
if(user.getRole().getValue() >= roleLevel.getValue())
{
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)
{
// 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;
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.
void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response responseContext)
{
if(input == null || !input.IsValid())
if(input == null || !input.isValid())
return;
Command command = commands.get(input.key);
+1 -1
View File
@@ -47,7 +47,7 @@ public class LocCommands extends BaseLocFile
public static ArrayList<String> GetUnlocalizedCommands()
{
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;
}
+1 -1
View File
@@ -172,7 +172,7 @@ public class ObjectBuilderFactory
{
KittyUser cachedUser = userCache.get(uid);
if(cachedUser != null)
role = cachedUser.GetRole();
role = cachedUser.getRole();
}
return role;
+1 -1
View File
@@ -39,7 +39,7 @@ public class RPManager
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);
}
+2 -2
View File
@@ -18,13 +18,13 @@ public class KittyChannel //extends DatabaseTrackedObject
}
// @Override
// public String Serialize()
// public String serialize()
// {
// return "";
// }
//
// @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)
{
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);
return true;
}
+1 -1
View File
@@ -45,7 +45,7 @@ public class KittyRP
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;
}
+4 -4
View File
@@ -27,26 +27,26 @@ public class KittyTrackedLong extends DatabaseTrackedObject
super(differentiator + readableName + UniqueID);
}
public long Add(long toAdd)
public long add(long toAdd)
{
tracked += toAdd;
markDirty();
return tracked;
}
public long Subtract(long toSubtract)
public long subtract(long toSubtract)
{
tracked -= toSubtract;
markDirty();
return tracked;
}
public long Get()
public long get()
{
return tracked;
}
public long Set(long newValue)
public long set(long newValue)
{
tracked = newValue;
markDirty();
+4 -4
View File
@@ -31,7 +31,7 @@ public class KittyUser extends DatabaseTrackedObject
}
// Can be positive or negative
public void ChangeBeans(int amount)
public void changeBeans(int amount)
{
beans += amount;
@@ -39,7 +39,7 @@ public class KittyUser extends DatabaseTrackedObject
markDirty();
}
public void ChangeRole(KittyRole newRole)
public void changeRole(KittyRole newRole)
{
if(newRole != role)
{
@@ -48,12 +48,12 @@ public class KittyUser extends DatabaseTrackedObject
}
}
public long GetBeans()
public long getBeans()
{
return beans;
}
public KittyRole GetRole()
public KittyRole getRole()
{
return role;
}
+11 -11
View File
@@ -39,12 +39,12 @@ public class TaggedPairStore
{
taggedPairs = new HashMap<String, 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.
@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();
while (it.hasNext())
@@ -62,7 +62,7 @@ public class TaggedPairStore
// Calls back each item in the structure but does not priv
@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();
while (it.hasNext())
@@ -123,7 +123,7 @@ public class TaggedPairStore
// Parses out the string passed in into the sectionkeyValue HashMap.
// Any character used in a split call is escaped just in case on
// account of some characters having specific regex meanings.
private void Parse(String input)
private void parse(String input)
{
if(input == null)
return;
@@ -143,7 +143,7 @@ public class TaggedPairStore
// Parse section name. If it already exists, don't bother making it.
String sectionName = section.substring(0, pos);
AddSection(sectionName);
addSection(sectionName);
// Parse out the pairs within the section, split them all out.
String unparsedPairs = section.substring(pos + 1);
@@ -171,7 +171,7 @@ public class TaggedPairStore
// Dumps out a string array
@SuppressWarnings("unused")
private void Dump(String[] toPrint)
private void dump(String[] toPrint)
{
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.
// 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);
allPairs.putIfAbsent(key, value);
}
// 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>());
}
// Returns a HashMap of Keys to Values for a given section
@SuppressWarnings("unchecked")
public HashMap<String, String> GetSection(String sectionName)
public HashMap<String, String> getSection(String sectionName)
{
return (HashMap<String, String>) taggedPairs.get(sectionName).clone();
}
// Look up a global key
public String GetKey(String key)
public String getKey(String key)
{
if(allPairs.containsKey(key))
return allPairs.get(key);
+7 -7
View File
@@ -35,13 +35,13 @@ public class UserInput
return;
if(!event.getMessage().getMentionedMembers().isEmpty())
mentions = FindMentionedUsers(event);
mentions = findMentionedUsers(event);
toParse = toParse.trim();
String commandIndicator = guildContext.getCommandIndicator();
if(toParse.startsWith(commandIndicator))
{
int loc = FindFirstWhitespace(toParse);
int loc = findFirstWhitespace(toParse);
if(loc <= 0)
{
@@ -61,22 +61,22 @@ public class UserInput
}
}
//Used for injecting direct commands from plugins
// Used for injecting direct commands from plugins
public UserInput(String input, KittyGuild contextGuild)
{
int loc = FindFirstWhitespace(input);
int loc = findFirstWhitespace(input);
key = input.substring(0, loc);
args = input.substring(loc);
isValid = true;
}
public boolean IsValid()
public boolean isValid()
{
return isValid;
}
// Finds first whitespace in the string
private int FindFirstWhitespace(String str)
private int findFirstWhitespace(String str)
{
for (int i = 0; i < str.length(); ++i)
{
@@ -87,7 +87,7 @@ public class UserInput
return -1;
}
private KittyUser[] FindMentionedUsers(GuildMessageReceivedEvent event)
private KittyUser[] findMentionedUsers(GuildMessageReceivedEvent event)
{
List <Member> JDAMentions = event.getMessage().getMentionedMembers();
KittyUser [] KittyMentions = new KittyUser[JDAMentions.size()];
+1 -1
View File
@@ -82,7 +82,7 @@ public class Main extends ListenerAdapter
return;
// Track beans!
user.ChangeBeans(1);
user.changeBeans(1);
// RP logging system
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(event.getMember().isOwner())
user.ChangeRole(KittyRole.Admin);
user.changeRole(KittyRole.Admin);
// Give devs the dev role
for(int i = 0; i < Ref.devIDs.length; ++i)
{
if(event.getAuthor().getId().equals(Ref.devIDs[i]))
{
user.ChangeRole(KittyRole.Dev);
user.changeRole(KittyRole.Dev);
break;
}
}