mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
Don't allow old UUID's to accidentally overwrite current UUID for user mapping.
Add some extra logging and uuid debug.
This commit is contained in:
parent
3887fdd47d
commit
2215b0f53f
@ -646,7 +646,7 @@ public class EssentialsUpgrade
|
||||
conf.forceSave();
|
||||
config = new EssentialsUserConf(name, uuid, new File(userdir, uuid + ".yml"));
|
||||
config.convertLegacyFile();
|
||||
ess.getUserMap().trackUUID(uuid, name);
|
||||
ess.getUserMap().trackUUID(uuid, name, false);
|
||||
continue;
|
||||
}
|
||||
countFails++;
|
||||
|
@ -841,7 +841,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
this.lastAccountName = lastAccountName;
|
||||
config.setProperty("lastAccountName", lastAccountName);
|
||||
config.save();
|
||||
ess.getUserMap().trackUUID(getConfigUUID(), lastAccountName);
|
||||
ess.getUserMap().trackUUID(getConfigUUID(), lastAccountName, true);
|
||||
}
|
||||
|
||||
public void setNPC(boolean set)
|
||||
|
@ -99,7 +99,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
ess.getLogger().info("Importing user " + name + " to usermap.");
|
||||
User user = new User(new OfflinePlayer(sanitizedName, ess.getServer()), ess);
|
||||
trackUUID(user.getBase().getUniqueId(), user.getName());
|
||||
trackUUID(user.getBase().getUniqueId(), user.getName(), true);
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
@ -126,7 +126,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
}
|
||||
}
|
||||
|
||||
public void trackUUID(final UUID uuid, final String name)
|
||||
public void trackUUID(final UUID uuid, final String name, boolean replace)
|
||||
{
|
||||
if (uuid != null)
|
||||
{
|
||||
@ -134,11 +134,27 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
if (name != null && name.length() > 0)
|
||||
{
|
||||
final String keyName = StringUtil.safeString(name);
|
||||
if (!names.containsKey(keyName) || !names.get(keyName).equals(uuid))
|
||||
if (!names.containsKey(keyName))
|
||||
{
|
||||
names.put(keyName, uuid);
|
||||
uuidMap.writeUUIDMap();
|
||||
}
|
||||
else if (!names.get(keyName).equals(uuid))
|
||||
{
|
||||
if (replace)
|
||||
{
|
||||
ess.getLogger().info("Found new UUID for " + name + ". Replacing " + names.get(keyName).toString() + " with " + uuid.toString());
|
||||
names.put(keyName, uuid);
|
||||
uuidMap.writeUUIDMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().info("Found old UUID for " + name + ". Not adding to usermap.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,7 +167,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
if (player != null)
|
||||
{
|
||||
final User user = new User(player, ess);
|
||||
trackUUID(uuid, user.getName());
|
||||
trackUUID(uuid, user.getName(), true);
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -162,7 +178,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
player = new OfflinePlayer(uuid, ess.getServer());
|
||||
final User user = new User(player, ess);
|
||||
((OfflinePlayer)player).setName(user.getLastAccountName());
|
||||
trackUUID(uuid, user.getName());
|
||||
trackUUID(uuid, user.getName(), false);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class Economy
|
||||
npcConfig.setProperty("lastAccountName", name);
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.forceSave();
|
||||
ess.getUserMap().trackUUID(npcUUID, name);
|
||||
ess.getUserMap().trackUUID(npcUUID, name, true);
|
||||
}
|
||||
|
||||
private static void deleteNPC(String name)
|
||||
|
@ -355,15 +355,27 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
sender.sendMessage("Online player: " + player.getUniqueId().toString());
|
||||
onlineUUID = player.getUniqueId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UUID essUUID = ess.getUserMap().getUser(name).getConfigUUID();
|
||||
|
||||
org.bukkit.OfflinePlayer player = ess.getServer().getOfflinePlayer(name);
|
||||
UUID bukkituuid = player.getUniqueId();
|
||||
sender.sendMessage("Bukkit Lookup: " + bukkituuid.toString());
|
||||
|
||||
if (onlineUUID != null && onlineUUID != bukkituuid)
|
||||
{
|
||||
sender.sendMessage("Online player: " + onlineUUID.toString());
|
||||
}
|
||||
|
||||
if (essUUID != null && essUUID != bukkituuid)
|
||||
{
|
||||
sender.sendMessage("Essentials config: " + essUUID.toString());
|
||||
}
|
||||
|
||||
UUID npcuuid = UUID.nameUUIDFromBytes(("NPC:" + name).getBytes(Charsets.UTF_8));
|
||||
sender.sendMessage("NPC UUID: " + npcuuid.toString());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user