mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-11 17:15:07 +02:00
Delay uuidconversion for 10s and show warning.
UUID conversion should now better handle offline conversion.
This commit is contained in:
@@ -102,6 +102,10 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
{
|
{
|
||||||
convertLegacyFile();
|
convertLegacyFile();
|
||||||
}
|
}
|
||||||
|
else if (altFileExists())
|
||||||
|
{
|
||||||
|
convertAltFile();
|
||||||
|
}
|
||||||
else if (templateName != null)
|
else if (templateName != null)
|
||||||
{
|
{
|
||||||
LOGGER.log(Level.INFO, tl("creatingConfigFromTemplate", configFile.toString()));
|
LOGGER.log(Level.INFO, tl("creatingConfigFromTemplate", configFile.toString()));
|
||||||
@@ -194,6 +198,16 @@ public class EssentialsConf extends YamlConfiguration
|
|||||||
LOGGER.log(Level.SEVERE, "Unable to import legacy config file.");
|
LOGGER.log(Level.SEVERE, "Unable to import legacy config file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean altFileExists()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void convertAltFile()
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, "Unable to import alt config file.");
|
||||||
|
}
|
||||||
|
|
||||||
private void createFromTemplate()
|
private void createFromTemplate()
|
||||||
{
|
{
|
||||||
InputStream istr = null;
|
InputStream istr = null;
|
||||||
|
@@ -501,6 +501,58 @@ public class EssentialsUpgrade
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||||
|
if (!userdir.exists())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int countFiles = 0;
|
||||||
|
int countReqFiles = 0;
|
||||||
|
for (String string : userdir.list())
|
||||||
|
{
|
||||||
|
if (!string.endsWith(".yml") || string.length() < 5)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
countFiles++;
|
||||||
|
|
||||||
|
final String name = string.substring(0, string.length() - 4);
|
||||||
|
UUID uuid = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
uuid = UUID.fromString(name);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
countReqFiles++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countFiles > 100)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countReqFiles < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ess.getLogger().info("#### Starting Essentials UUID userdata conversion in a few seconds. ####");
|
||||||
|
ess.getLogger().info("We recommend you take a backup of your server before upgrading from the old username system.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(10000);
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex)
|
||||||
|
{
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
|
||||||
uuidFileConvert(ess);
|
uuidFileConvert(ess);
|
||||||
|
|
||||||
doneFile.setProperty("uuidFileChange", true);
|
doneFile.setProperty("uuidFileChange", true);
|
||||||
@@ -598,7 +650,7 @@ public class EssentialsUpgrade
|
|||||||
}
|
}
|
||||||
ess.getUserMap().getUUIDMap().forceWriteUUIDMap();
|
ess.getUserMap().getUUIDMap().forceWriteUUIDMap();
|
||||||
|
|
||||||
ess.getLogger().info("Completed Essentials UUID userdata conversion. Attempted to convert " + countFiles + " users.");
|
ess.getLogger().info("Converted " + countFiles + "/" + countFiles + ". Conversion complete.");
|
||||||
ess.getLogger().info("Converted via cache: " + countEssCache + " :: Converted via lookup: " + countBukkit + " :: Failed to convert: " + countFails);
|
ess.getLogger().info("Converted via cache: " + countEssCache + " :: Converted via lookup: " + countBukkit + " :: Failed to convert: " + countFails);
|
||||||
ess.getLogger().info("To rerun the conversion type /essentials uuidconvert");
|
ess.getLogger().info("To rerun the conversion type /essentials uuidconvert");
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -23,14 +25,14 @@ public class EssentialsUserConf extends EssentialsConf
|
|||||||
@Override
|
@Override
|
||||||
public boolean legacyFileExists()
|
public boolean legacyFileExists()
|
||||||
{
|
{
|
||||||
File file = new File(configFile.getParentFile(), username + ".yml");
|
final File file = new File(configFile.getParentFile(), username + ".yml");
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void convertLegacyFile()
|
public void convertLegacyFile()
|
||||||
{
|
{
|
||||||
File file = new File(configFile.getParentFile(), username + ".yml");
|
final File file = new File(configFile.getParentFile(), username + ".yml");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files.move(file, new File(configFile.getParentFile(), uuid + ".yml"));
|
Files.move(file, new File(configFile.getParentFile(), uuid + ".yml"));
|
||||||
@@ -42,4 +44,33 @@ public class EssentialsUserConf extends EssentialsConf
|
|||||||
|
|
||||||
setProperty("lastAccountName", username);
|
setProperty("lastAccountName", username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getAltFile()
|
||||||
|
{
|
||||||
|
final UUID fn = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username.toLowerCase(Locale.ENGLISH)).getBytes(Charsets.UTF_8));
|
||||||
|
return new File(configFile.getParentFile(), fn.toString() + ".yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean altFileExists()
|
||||||
|
{
|
||||||
|
if (username.equals(username.toLowerCase()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return getAltFile().exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void convertAltFile()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Files.move(getAltFile(), new File(configFile.getParentFile(), uuid + ".yml"));
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().log(Level.WARNING, "Failed to migrate user: " + username, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import com.earth2me.essentials.UserMap;
|
|||||||
import com.earth2me.essentials.metrics.Metrics;
|
import com.earth2me.essentials.metrics.Metrics;
|
||||||
import com.earth2me.essentials.utils.DateUtil;
|
import com.earth2me.essentials.utils.DateUtil;
|
||||||
import com.earth2me.essentials.utils.NumberUtil;
|
import com.earth2me.essentials.utils.NumberUtil;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -63,6 +64,10 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
run_uuidconvert(server, sender, commandLabel, args);
|
run_uuidconvert(server, sender, commandLabel, args);
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("uuidtest"))
|
||||||
|
{
|
||||||
|
run_uuidtest(server, sender, commandLabel, args);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
run_reload(server, sender, commandLabel, args);
|
run_reload(server, sender, commandLabel, args);
|
||||||
@@ -325,4 +330,32 @@ public class Commandessentials extends EssentialsCommand
|
|||||||
EssentialsUpgrade.uuidFileConvert(ess);
|
EssentialsUpgrade.uuidFileConvert(ess);
|
||||||
sender.sendMessage("UUID conversion complete, check your server log for more information.");
|
sender.sendMessage("UUID conversion complete, check your server log for more information.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void run_uuidtest(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
throw new Exception("/<command> uuidtest <name>");
|
||||||
|
}
|
||||||
|
String name = args[1];
|
||||||
|
sender.sendMessage("Looking up UUID for " + name);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (player.getName().equalsIgnoreCase(name))
|
||||||
|
{
|
||||||
|
sender.sendMessage("Online player: " + player.getUniqueId().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
org.bukkit.OfflinePlayer player = ess.getServer().getOfflinePlayer(name);
|
||||||
|
UUID bukkituuid = player.getUniqueId();
|
||||||
|
sender.sendMessage("Bukkit Lookup: " + bukkituuid.toString());
|
||||||
|
|
||||||
|
UUID npcuuid = UUID.nameUUIDFromBytes(("NPC:" + name).getBytes(Charsets.UTF_8));
|
||||||
|
sender.sendMessage("NPC UUID: " + npcuuid.toString());
|
||||||
|
|
||||||
|
UUID offlineuuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||||
|
sender.sendMessage("Offline Mode UUID: " + offlineuuid.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,8 @@ public class Commandseen extends EssentialsCommand
|
|||||||
seenIP(server, sender, args[0]);
|
seenIP(server, sender, args[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (FormatUtil.validIP(args[0]) && (server.getIPBans().contains(args[0]))) {
|
else if (FormatUtil.validIP(args[0]) && (server.getIPBans().contains(args[0])))
|
||||||
|
{
|
||||||
sender.sendMessage(tl("isIpBanned", args[0]));
|
sender.sendMessage(tl("isIpBanned", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,6 +74,11 @@ public class Commandseen extends EssentialsCommand
|
|||||||
user.setDisplayNick();
|
user.setDisplayNick();
|
||||||
sender.sendMessage(tl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));
|
sender.sendMessage(tl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));
|
||||||
|
|
||||||
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().info("UUID: " + user.getBase().getUniqueId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
||||||
if (history != null && history.size() > 1)
|
if (history != null && history.size() > 1)
|
||||||
{
|
{
|
||||||
@@ -118,6 +124,11 @@ public class Commandseen extends EssentialsCommand
|
|||||||
sender.sendMessage(tl("userUnknown", user.getName()));
|
sender.sendMessage(tl("userUnknown", user.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ess.getSettings().isDebug())
|
||||||
|
{
|
||||||
|
ess.getLogger().info("UUID: " + user.getBase().getUniqueId().toString());
|
||||||
|
}
|
||||||
|
|
||||||
List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
|
||||||
if (history != null && history.size() > 1)
|
if (history != null && history.size() > 1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user