mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-01 00:10:32 +01:00
Add progress status and /ess uuidconvert command for manual conversion.
This commit is contained in:
parent
65b1821196
commit
87f90e9bdd
@ -500,17 +500,43 @@ public class EssentialsUpgrade
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uuidFileConvert(ess);
|
||||||
|
|
||||||
|
doneFile.setProperty("uuidFileChange", true);
|
||||||
|
doneFile.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void uuidFileConvert(IEssentials ess)
|
||||||
|
{
|
||||||
|
ess.getLogger().info("Starting Essentials UUID userdata conversion");
|
||||||
|
|
||||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||||
if (!userdir.exists())
|
if (!userdir.exists())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int countFiles = 0;
|
||||||
|
int countFails = 0;
|
||||||
|
|
||||||
|
ess.getLogger().info("Found " + userdir.list().length + " files to convert...");
|
||||||
|
|
||||||
for (String string : userdir.list())
|
for (String string : userdir.list())
|
||||||
{
|
{
|
||||||
if (!string.endsWith(".yml"))
|
if (!string.endsWith(".yml"))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int showProgress = countFiles % 1000;
|
||||||
|
|
||||||
|
if (showProgress == 0)
|
||||||
|
{
|
||||||
|
ess.getLogger().info("Converted " + countFiles + "/" + userdir.list().length);
|
||||||
|
}
|
||||||
|
|
||||||
|
countFiles++;
|
||||||
|
|
||||||
final String name = string.substring(0, string.length() - 4);
|
final String name = string.substring(0, string.length() - 4);
|
||||||
EssentialsUserConf config;
|
EssentialsUserConf config;
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
@ -528,9 +554,12 @@ public class EssentialsUpgrade
|
|||||||
|
|
||||||
String uuidString = conf.getString("uuid", null);
|
String uuidString = conf.getString("uuid", null);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uuid = UUID.fromString(uuidString);
|
uuid = UUID.fromString(uuidString);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch (Exception ex2)
|
catch (Exception ex2)
|
||||||
{
|
{
|
||||||
@ -538,21 +567,34 @@ public class EssentialsUpgrade
|
|||||||
uuid = player.getUniqueId();
|
uuid = player.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uuid != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (uuid == null && conf.getBoolean("npc", false))
|
if (uuid == null && conf.getBoolean("npc", false))
|
||||||
{
|
{
|
||||||
uuid = UUID.randomUUID();
|
uuid = UUID.randomUUID();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (uuid != null)
|
if (uuid != null)
|
||||||
{
|
{
|
||||||
config = new EssentialsUserConf(name, uuid, new File(userdir, uuid + ".yml"));
|
config = new EssentialsUserConf(name, uuid, new File(userdir, uuid + ".yml"));
|
||||||
config.convertLegacyFile();
|
config.convertLegacyFile();
|
||||||
ess.getUserMap().trackUUID(uuid, name);
|
ess.getUserMap().trackUUID(uuid, name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
countFails++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
doneFile.setProperty("uuidFileChange", true);
|
ess.getLogger().info("Completed Essentials UUID userdata conversion.");
|
||||||
doneFile.save();
|
ess.getLogger().info("Attempted to convert " + countFiles + " users. Failed to convert: " + countFails);
|
||||||
|
ess.getLogger().info("To rerun the conversion type /essentials uuidconvert");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeSettings()
|
public void beforeSettings()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
|
import com.earth2me.essentials.EssentialsUpgrade;
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.UserMap;
|
import com.earth2me.essentials.UserMap;
|
||||||
@ -58,6 +59,10 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
run_cleanup(server, sender, commandLabel, args);
|
run_cleanup(server, sender, commandLabel, args);
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("uuidconvert"))
|
||||||
|
{
|
||||||
|
run_uuidconvert(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
run_reload(server, sender, commandLabel, args);
|
run_reload(server, sender, commandLabel, args);
|
||||||
@ -313,4 +318,11 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void run_uuidconvert(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
sender.sendMessage("Starting Essentials UUID userdata conversion, this may lag the server.");
|
||||||
|
EssentialsUpgrade.uuidFileConvert(ess);
|
||||||
|
sender.sendMessage("UUID conversion complete, check your server log for more information.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user