1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-21 19:22:59 +01:00

Code cleanup and new settings for Database config

This commit is contained in:
nossr50
2019-04-03 18:42:58 -07:00
parent 8991c2bf2c
commit 0e39656c88
8 changed files with 85 additions and 30 deletions

View File

@@ -12,19 +12,19 @@ import java.util.UUID;
public interface DatabaseManager {
// One month in milliseconds
public final long PURGE_TIME = 2630000000L * mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths();
long PURGE_TIME = 2630000000L * mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths();
// During convertUsers, how often to output a status
public final int progressInterval = 200;
int progressInterval = 200;
/**
* Purge users with 0 power level from the database.
*/
public void purgePowerlessUsers();
void purgePowerlessUsers();
/**
* Purge users who haven't logged on in over a certain time frame from the database.
*/
public void purgeOldUsers();
void purgeOldUsers();
/**
* Remove a user from the database.
@@ -32,7 +32,7 @@ public interface DatabaseManager {
* @param playerName The name of the user to remove
* @return true if the user was successfully removed, false otherwise
*/
public boolean removeUser(String playerName);
boolean removeUser(String playerName);
/**
* Save a user to the database.
@@ -40,7 +40,7 @@ public interface DatabaseManager {
* @param profile The profile of the player to save
* @return true if successful, false on failure
*/
public boolean saveUser(PlayerProfile profile);
boolean saveUser(PlayerProfile profile);
/**
* Retrieve leaderboard info.
@@ -50,7 +50,7 @@ public interface DatabaseManager {
* @param statsPerPage The number of stats per page
* @return the requested leaderboard information
*/
public List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage);
List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage);
/**
* Retrieve rank info into a HashMap from PrimarySkillType to the rank.
@@ -61,7 +61,7 @@ public interface DatabaseManager {
* @param playerName The name of the user to retrieve the rankings for
* @return the requested rank information
*/
public Map<PrimarySkillType, Integer> readRank(String playerName);
Map<PrimarySkillType, Integer> readRank(String playerName);
/**
* Add a new user to the database.
@@ -69,7 +69,7 @@ public interface DatabaseManager {
* @param playerName The name of the player to be added to the database
* @param uuid The uuid of the player to be added to the database
*/
public void newUser(String playerName, UUID uuid);
void newUser(String playerName, UUID uuid);
/**
* Load a player from the database.
@@ -83,7 +83,7 @@ public interface DatabaseManager {
* and createNew is false
*/
@Deprecated
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
PlayerProfile loadPlayerProfile(String playerName, boolean createNew);
/**
* Load a player from the database.
@@ -91,7 +91,7 @@ public interface DatabaseManager {
* @param uuid The uuid of the player to load from the database
* @return The player's data, or an unloaded PlayerProfile if not found
*/
public PlayerProfile loadPlayerProfile(UUID uuid);
PlayerProfile loadPlayerProfile(UUID uuid);
/**
* Load a player from the database. Attempt to use uuid, fall back on playername
@@ -103,14 +103,14 @@ public interface DatabaseManager {
* @return The player's data, or an unloaded PlayerProfile if not found
* and createNew is false
*/
public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew);
PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew);
/**
* Get all users currently stored in the database.
*
* @return list of playernames
*/
public List<String> getStoredUsers();
List<String> getStoredUsers();
/**
* Convert all users from this database to the provided database using
@@ -118,21 +118,21 @@ public interface DatabaseManager {
*
* @param destination The DatabaseManager to save to
*/
public void convertUsers(DatabaseManager destination);
void convertUsers(DatabaseManager destination);
public boolean saveUserUUID(String userName, UUID uuid);
boolean saveUserUUID(String userName, UUID uuid);
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs);
boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs);
/**
* Retrieve the type of database in use. Custom databases should return CUSTOM.
*
* @return The type of database
*/
public DatabaseType getDatabaseType();
DatabaseType getDatabaseType();
/**
* Called when the plugin disables
*/
public void onDisable();
void onDisable();
}