Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -35,8 +35,8 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
|
||||
private void RegisterTrackedObjects()
|
||||
{
|
||||
DatabaseManager.instance.Register(roleList);
|
||||
DatabaseManager.instance.Register(beans);
|
||||
DatabaseManager.instance.globalRegister(roleList);
|
||||
DatabaseManager.instance.globalRegister(beans);
|
||||
}
|
||||
|
||||
// Default content for a guild
|
||||
|
||||
@@ -17,8 +17,7 @@ import utils.LogFilter;
|
||||
//
|
||||
public class KittyTrackedLong extends DatabaseTrackedObject
|
||||
{
|
||||
private long tracked; // Tracked value
|
||||
private final String databaseID; // in-database ID of this value
|
||||
private long tracked; // Tracked value
|
||||
|
||||
// Config
|
||||
private final static String differentiator = "long-";
|
||||
@@ -26,7 +25,6 @@ public class KittyTrackedLong extends DatabaseTrackedObject
|
||||
public KittyTrackedLong(String readableName, String UniqueID)
|
||||
{
|
||||
super(differentiator + readableName + UniqueID);
|
||||
databaseID = differentiator + readableName + UniqueID;
|
||||
}
|
||||
|
||||
public long Add(long toAdd)
|
||||
@@ -73,7 +71,7 @@ public class KittyTrackedLong extends DatabaseTrackedObject
|
||||
catch(Exception e)
|
||||
{
|
||||
tracked = 0;
|
||||
GlobalLog.Error(LogFilter.Core, "Falling back to default of 0 due to failure to deserialize long with database ID " + databaseID);
|
||||
GlobalLog.Error(LogFilter.Core, "Falling back to default of 0 due to failure to deserialize long with database ID " + identifier);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package dataStructures;
|
||||
|
||||
import core.DatabaseTrackedObject;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
public class KittyTrackedString extends DatabaseTrackedObject
|
||||
{
|
||||
private String trackedString; // This is the string tracked in the database
|
||||
private final static String differentiator = "string-"; // Lends a very slightly human-readable label to the database key
|
||||
|
||||
// Constructor with unique id and readable name
|
||||
public KittyTrackedString(String readableName, String UniqueID)
|
||||
{
|
||||
super(differentiator + readableName + UniqueID);
|
||||
}
|
||||
|
||||
// Sets the value of the string and marks it as dirty
|
||||
public void set(String newValue)
|
||||
{
|
||||
synchronized(trackedString)
|
||||
{
|
||||
trackedString = newValue;
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Returns string. The string is copied because it is immutable.
|
||||
public String get()
|
||||
{
|
||||
synchronized(trackedString)
|
||||
{
|
||||
return trackedString;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Serialize()
|
||||
{
|
||||
return trackedString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeSerialzie(String string)
|
||||
{
|
||||
if(string != null && !string.isEmpty())
|
||||
{
|
||||
trackedString = string;
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Database, "String had null or empty value with identifier: " + identifier);
|
||||
string = "";
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,13 +5,10 @@ import java.util.Vector;
|
||||
|
||||
import core.DatabaseTrackedObject;
|
||||
|
||||
// Acts as a proxy of sorts for the allowedRole arraylist, keeping it tracked for a specific guild.
|
||||
@SuppressWarnings("unused")
|
||||
public class KittyTrackedVector extends DatabaseTrackedObject
|
||||
{
|
||||
// Variables
|
||||
private Vector<String> allowedRole = new Vector<String>();
|
||||
private final String databaseID; // in-database ID of this value
|
||||
private Vector<String> trackedVector = new Vector<String>();
|
||||
|
||||
private final static String delimiter = "\n";
|
||||
private final static String split = "\\n";
|
||||
@@ -21,14 +18,13 @@ public class KittyTrackedVector extends DatabaseTrackedObject
|
||||
public KittyTrackedVector(String readableName, String UniqueID)
|
||||
{
|
||||
super(differentiator + readableName + UniqueID);
|
||||
databaseID = differentiator + readableName + UniqueID;
|
||||
}
|
||||
|
||||
|
||||
// See if the string is contined in the vector, regardless of case.
|
||||
public boolean containsIgnoreCase(String str)
|
||||
{
|
||||
Iterator<String> value = allowedRole.iterator();
|
||||
Iterator<String> value = trackedVector.iterator();
|
||||
|
||||
while (value.hasNext())
|
||||
{
|
||||
@@ -42,33 +38,33 @@ public class KittyTrackedVector extends DatabaseTrackedObject
|
||||
// Mirrored behavior
|
||||
public boolean contains(String str)
|
||||
{
|
||||
return allowedRole.contains(str);
|
||||
return trackedVector.contains(str);
|
||||
}
|
||||
|
||||
public void add(String str)
|
||||
{
|
||||
allowedRole.add(str);
|
||||
trackedVector.add(str);
|
||||
this.MarkDirty();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return allowedRole.isEmpty();
|
||||
return trackedVector.isEmpty();
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return allowedRole.size();
|
||||
return trackedVector.size();
|
||||
}
|
||||
|
||||
public String get(int index)
|
||||
{
|
||||
return allowedRole.get(index);
|
||||
return trackedVector.get(index);
|
||||
}
|
||||
|
||||
public void remove(String str)
|
||||
{
|
||||
allowedRole.remove(str);
|
||||
trackedVector.remove(str);
|
||||
this.MarkDirty();
|
||||
}
|
||||
|
||||
@@ -78,12 +74,12 @@ public class KittyTrackedVector extends DatabaseTrackedObject
|
||||
{
|
||||
String toSerialize = "";
|
||||
|
||||
for(int i = 0; i < allowedRole.size(); ++i)
|
||||
for(int i = 0; i < trackedVector.size(); ++i)
|
||||
{
|
||||
if(i != 0)
|
||||
toSerialize += delimiter;
|
||||
|
||||
toSerialize += allowedRole.get(i);
|
||||
toSerialize += trackedVector.get(i);
|
||||
}
|
||||
|
||||
return toSerialize;
|
||||
@@ -100,7 +96,7 @@ public class KittyTrackedVector extends DatabaseTrackedObject
|
||||
String[] rolesSplit = string.split(split);
|
||||
|
||||
for(int i = 0; i < rolesSplit.length; ++i)
|
||||
allowedRole.add(rolesSplit[i]);
|
||||
trackedVector.add(rolesSplit[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ import utils.LogFilter;
|
||||
// two unique user objects associated with them.
|
||||
public class KittyUser extends DatabaseTrackedObject
|
||||
{
|
||||
public KittyGuild guild;
|
||||
public String name;
|
||||
public String uniqueID;
|
||||
public String discordID;
|
||||
public String avatarID;
|
||||
private KittyRole role;
|
||||
private long beans;
|
||||
public KittyGuild guild; // The guild this user is associated with. A KittyUser can not be associated with more than one guild.
|
||||
public String name; // The 'friendly name' of the user (readable name).
|
||||
public String uniqueID; // The combination of the guild ID that discord uses and the user-specific ID discord uses. (A discord account has one user per server).
|
||||
public String discordID; // The user-specific ID only. This is the ID associated with the discord account.
|
||||
public String avatarID; // The searchable ID of the current avatar image for the user.
|
||||
private KittyRole role; // The command permissions role this user has for issuing bot commands for this bot.
|
||||
private long beans; // A value incremented each time a user sends a message in a server they're in.
|
||||
|
||||
// Explicit Constructor
|
||||
public KittyUser(String name, KittyGuild guild, KittyRole role, String uniqueID, String avatarID, String discordID)
|
||||
|
||||
Reference in New Issue
Block a user