Faster UUID migration.

This commit is contained in:
ryanhamshire 2015-01-31 13:05:51 -08:00
parent f3d301ddc9
commit 44fb29561e
2 changed files with 22 additions and 27 deletions

View File

@ -160,7 +160,7 @@ public class FlatFileDataStore extends DataStore
//if corrected casing and a record already exists using the correct casing, skip this one //if corrected casing and a record already exists using the correct casing, skip this one
String correctedCasing = UUIDFetcher.correctedNames.get(currentFilename); String correctedCasing = UUIDFetcher.correctedNames.get(currentFilename);
if(correctedCasing != null) if(correctedCasing != null && !currentFilename.equals(correctedCasing))
{ {
File correctedCasingFile = new File(playerDataFolder.getPath() + File.separator + correctedCasing); File correctedCasingFile = new File(playerDataFolder.getPath() + File.separator + correctedCasing);
if(correctedCasingFile.exists()) if(correctedCasingFile.exists())

View File

@ -51,47 +51,42 @@ class UUIDFetcher {
GriefPrevention.AddLogEntry("UUID conversion process started. Please be patient - this may take a while."); GriefPrevention.AddLogEntry("UUID conversion process started. Please be patient - this may take a while.");
//try to get correct casing from local data GriefPrevention.AddLogEntry("Mining your local world data to save calls to Mojang...");
OfflinePlayer [] players = GriefPrevention.instance.getServer().getOfflinePlayers(); OfflinePlayer [] players = GriefPrevention.instance.getServer().getOfflinePlayers();
for(OfflinePlayer player : players)
{
if(player.getName() != null && player.getUniqueId() != null)
{
lookupCache.put(player.getName(), player.getUniqueId());
lookupCache.put(player.getName().toLowerCase(), player.getUniqueId());
correctedNames.put(player.getName().toLowerCase(), player.getName());
}
}
//try to get correct casing from local data
GriefPrevention.AddLogEntry("Checking local server data to get correct casing for player names..."); GriefPrevention.AddLogEntry("Checking local server data to get correct casing for player names...");
for(int i = 0; i < names.size(); i++) for(int i = 0; i < names.size(); i++)
{ {
String name = names.get(i); String name = names.get(i);
for(OfflinePlayer player : players) String correctCasingName = correctedNames.get(name);
if(correctCasingName != null && !name.equals(correctCasingName))
{ {
if(player.getName() != null && player.getName().equalsIgnoreCase(name)) GriefPrevention.AddLogEntry(name + " --> " + correctCasingName);
{ names.set(i, correctCasingName);
if(!player.getName().equals(name))
{
GriefPrevention.AddLogEntry(name + " --> " + player.getName());
correctedNames.put(name, player.getName());
names.set(i, player.getName());
}
break;
}
} }
} }
//look for local data first //look for local uuid's first
GriefPrevention.AddLogEntry("Checking local server data for UUIDs already seen..."); GriefPrevention.AddLogEntry("Checking local server data for UUIDs already seen...");
for(int i = 0; i < names.size(); i++) for(int i = 0; i < names.size(); i++)
{ {
String name = names.get(i); String name = names.get(i);
for(OfflinePlayer player : players) UUID uuid = lookupCache.get(name);
{
if(player.getName() != null && player.getName().equalsIgnoreCase(name))
{
UUID uuid = player.getUniqueId();
if(uuid != null) if(uuid != null)
{ {
GriefPrevention.AddLogEntry(name + " --> " + uuid.toString()); GriefPrevention.AddLogEntry(name + " --> " + uuid.toString());
lookupCache.put(name, uuid);
lookupCache.put(name.toLowerCase(), uuid);
names.remove(i--); names.remove(i--);
} }
break;
}
}
} }
//for online mode, call Mojang to resolve the rest //for online mode, call Mojang to resolve the rest