Faster UUID migration.
This commit is contained in:
parent
f3d301ddc9
commit
44fb29561e
|
|
@ -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())
|
||||||
|
|
|
||||||
|
|
@ -51,46 +51,41 @@ 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(uuid != null)
|
||||||
{
|
{
|
||||||
if(player.getName() != null && player.getName().equalsIgnoreCase(name))
|
GriefPrevention.AddLogEntry(name + " --> " + uuid.toString());
|
||||||
{
|
names.remove(i--);
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
if(uuid != null)
|
|
||||||
{
|
|
||||||
GriefPrevention.AddLogEntry(name + " --> " + uuid.toString());
|
|
||||||
lookupCache.put(name, uuid);
|
|
||||||
lookupCache.put(name.toLowerCase(), uuid);
|
|
||||||
names.remove(i--);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user