diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 7a0093b50..af0521b58 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -124,7 +124,7 @@ public interface DatabaseManager { public boolean saveUserUUID(String userName, UUID uuid); - public boolean saveUserUUIDs(Map user_info); + public boolean saveUserUUIDs(Map fetchedUUIDs); /** * Retrieve the type of database in use. Custom databases should return CUSTOM. diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 3f2faaa6a..c19e2dde5 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -542,8 +542,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { return worked; } - public boolean saveUserUUIDs(Map user_data) { - + public boolean saveUserUUIDs(Map fetchedUUIDs) { BufferedReader in = null; FileWriter out = null; String usersFilePath = mcMMO.getUsersFilePath(); @@ -554,16 +553,16 @@ public final class FlatfileDatabaseManager implements DatabaseManager { StringBuilder writer = new StringBuilder(); String line; - while (((line = in.readLine()) != null) && !user_data.isEmpty()) { + while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) { String[] character = line.split(":"); - if (user_data.containsKey(character[0])) { + if (fetchedUUIDs.containsKey(character[0])) { if (character.length < 42) { mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!"); mcMMO.p.getLogger().severe("Database entry is invalid."); return false; } - line = line.replace(character[41], user_data.remove(character[0]).toString()); + line = line.replace(character[41], fetchedUUIDs.remove(character[0]).toString()); } writer.append(line).append("\r\n"); diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index cef432148..3596d7426 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -621,7 +621,7 @@ public final class SQLDatabaseManager implements DatabaseManager { // Problem, nothing was returned } - public boolean saveUserUUIDs(Map player_info) { + public boolean saveUserUUIDs(Map fetchedUUIDs) { if (!checkConnected()) { // return false return false; @@ -633,7 +633,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?"); - for (Map.Entry entry : player_info.entrySet()) { + for (Map.Entry entry : fetchedUUIDs.entrySet()) { statement.setString(1, entry.getValue().toString()); statement.setString(2, entry.getKey()); @@ -1051,11 +1051,11 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.executeQuery("SELECT `user` FROM `" + tablePrefix + "users`"); - while(resultSet.next()) { + while (resultSet.next()) { names.add(resultSet.getString("user")); } - new UUIDUpdateAsyncTask(mcMMO.p,names).runTaskAsynchronously(mcMMO.p); + new UUIDUpdateAsyncTask(mcMMO.p, names).runTaskAsynchronously(mcMMO.p); return; } diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index c7ffc2fbb..e9cde41d4 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -38,7 +38,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size); List userNamesSection; - Map fetchedUUIDs = new HashMap(); + Map fetchedUUIDs = new HashMap(); while (size != 0) { if (size > MAX_LOOKUP) { @@ -51,7 +51,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { } try { - fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call()); + fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call()); } catch (Exception e) { plugin.getLogger().severe("Unable to fetch UUIDs!"); @@ -59,9 +59,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { } checkedUsers += userNamesSection.size(); - userNamesSection.clear(); - size = userNames.size(); Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);