mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-16 20:44:43 +02:00
Misc code fixes
This commit is contained in:
@ -12,19 +12,19 @@ import java.util.UUID;
|
||||
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
// 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.
|
||||
@ -33,14 +33,14 @@ public interface DatabaseManager {
|
||||
* @param uuid player UUID, can be null
|
||||
* @return true if the user was successfully removed, false otherwise
|
||||
*/
|
||||
public boolean removeUser(String playerName, UUID uuid);
|
||||
boolean removeUser(String playerName, UUID uuid);
|
||||
|
||||
/**
|
||||
* Removes any cache used for faster lookups
|
||||
* Currently only used for SQL
|
||||
* @param uuid target UUID to cleanup
|
||||
*/
|
||||
public void cleanupUser(UUID uuid);
|
||||
void cleanupUser(UUID uuid);
|
||||
|
||||
/**
|
||||
* Save a user to the database.
|
||||
@ -48,7 +48,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.
|
||||
@ -58,7 +58,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.
|
||||
@ -69,7 +69,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.
|
||||
@ -77,7 +77,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.
|
||||
@ -91,7 +91,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.
|
||||
@ -99,7 +99,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
|
||||
@ -111,14 +111,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
|
||||
@ -126,21 +126,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();
|
||||
}
|
||||
|
@ -809,20 +809,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
SkillComparator c = new SkillComparator();
|
||||
|
||||
Collections.sort(mining, c);
|
||||
Collections.sort(woodcutting, c);
|
||||
Collections.sort(repair, c);
|
||||
Collections.sort(unarmed, c);
|
||||
Collections.sort(herbalism, c);
|
||||
Collections.sort(excavation, c);
|
||||
Collections.sort(archery, c);
|
||||
Collections.sort(swords, c);
|
||||
Collections.sort(axes, c);
|
||||
Collections.sort(acrobatics, c);
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(alchemy, c);
|
||||
Collections.sort(powerLevels, c);
|
||||
mining.sort(c);
|
||||
woodcutting.sort(c);
|
||||
repair.sort(c);
|
||||
unarmed.sort(c);
|
||||
herbalism.sort(c);
|
||||
excavation.sort(c);
|
||||
archery.sort(c);
|
||||
swords.sort(c);
|
||||
axes.sort(c);
|
||||
acrobatics.sort(c);
|
||||
taming.sort(c);
|
||||
fishing.sort(c);
|
||||
alchemy.sort(c);
|
||||
powerLevels.sort(c);
|
||||
|
||||
playerStatHash.put(PrimarySkillType.MINING, mining);
|
||||
playerStatHash.put(PrimarySkillType.WOODCUTTING, woodcutting);
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private static final String ALL_QUERY_VERSION = "total";
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
private final String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
|
||||
|
||||
@ -33,7 +33,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
private boolean debug = false;
|
||||
|
||||
private ReentrantLock massUpdateLock = new ReentrantLock();
|
||||
private final ReentrantLock massUpdateLock = new ReentrantLock();
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
|
||||
@ -1488,9 +1488,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
int id = resultSet.getInt("id");
|
||||
|
||||
return id;
|
||||
return resultSet.getInt("id");
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
|
Reference in New Issue
Block a user