mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Fixed formatting!
This commit is contained in:
parent
7118f8850d
commit
7861e93497
@ -124,7 +124,7 @@ public interface DatabaseManager {
|
|||||||
|
|
||||||
public boolean saveUserUUID(String userName, UUID uuid);
|
public boolean saveUserUUID(String userName, UUID uuid);
|
||||||
|
|
||||||
public boolean saveUserUUIDs(Map<String, UUID> user_info);
|
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
* Retrieve the type of database in use. Custom databases should return CUSTOM.
|
||||||
|
@ -540,8 +540,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveUserUUIDs(Map<String, UUID> user_data) {
|
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
@ -552,16 +551,16 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
while (((line = in.readLine()) != null) && !user_data.isEmpty()) {
|
while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
if (user_data.containsKey(character[0])) {
|
if (fetchedUUIDs.containsKey(character[0])) {
|
||||||
if (character.length < 42) {
|
if (character.length < 42) {
|
||||||
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!");
|
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!");
|
||||||
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||||
return false;
|
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");
|
writer.append(line).append("\r\n");
|
||||||
|
@ -621,7 +621,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
// Problem, nothing was returned
|
// Problem, nothing was returned
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveUserUUIDs(Map<String,UUID> player_info) {
|
public boolean saveUserUUIDs(Map<String, UUID> fetchedUUIDs) {
|
||||||
if (!checkConnected()) {
|
if (!checkConnected()) {
|
||||||
// return false
|
// return false
|
||||||
return false;
|
return false;
|
||||||
@ -633,7 +633,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
|
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
|
||||||
|
|
||||||
for (Map.Entry<String,UUID> entry : player_info.entrySet()) {
|
for (Map.Entry<String, UUID> entry : fetchedUUIDs.entrySet()) {
|
||||||
statement.setString(1, entry.getValue().toString());
|
statement.setString(1, entry.getValue().toString());
|
||||||
statement.setString(2, entry.getKey());
|
statement.setString(2, entry.getKey());
|
||||||
|
|
||||||
@ -1051,11 +1051,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
resultSet = statement.executeQuery("SELECT `user` FROM `" + tablePrefix + "users`");
|
resultSet = statement.executeQuery("SELECT `user` FROM `" + tablePrefix + "users`");
|
||||||
|
|
||||||
while(resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
names.add(resultSet.getString("user"));
|
names.add(resultSet.getString("user"));
|
||||||
}
|
}
|
||||||
|
|
||||||
new UUIDUpdateAsyncTask(mcMMO.p,names).runTaskAsynchronously(mcMMO.p);
|
new UUIDUpdateAsyncTask(mcMMO.p, names).runTaskAsynchronously(mcMMO.p);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size);
|
plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size);
|
||||||
|
|
||||||
List<String> userNamesSection;
|
List<String> userNamesSection;
|
||||||
Map<String,UUID> fetchedUUIDs = new HashMap<String,UUID>();
|
Map<String, UUID> fetchedUUIDs = new HashMap<String, UUID>();
|
||||||
|
|
||||||
while (size != 0) {
|
while (size != 0) {
|
||||||
if (size > MAX_LOOKUP) {
|
if (size > MAX_LOOKUP) {
|
||||||
@ -51,7 +51,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call());
|
fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
plugin.getLogger().severe("Unable to fetch UUIDs!");
|
plugin.getLogger().severe("Unable to fetch UUIDs!");
|
||||||
@ -59,9 +59,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkedUsers += userNamesSection.size();
|
checkedUsers += userNamesSection.size();
|
||||||
|
|
||||||
userNamesSection.clear();
|
userNamesSection.clear();
|
||||||
|
|
||||||
size = userNames.size();
|
size = userNames.size();
|
||||||
|
|
||||||
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
|
||||||
|
Loading…
Reference in New Issue
Block a user