Potentially fixes rename issues

#2450
This commit is contained in:
Jesse Boyd 2019-11-12 20:48:33 +00:00
parent 765a021ecd
commit c23086259d
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -161,19 +161,19 @@ public abstract class UUIDHandlerImplementation {
}); });
} }
try { try {
UUID offline = this.uuidMap.put(name, uuid); UUID existing = this.uuidMap.put(name, uuid);
if (offline != null) { if (existing != null) {
if (!offline.equals(uuid)) { if (!existing.equals(uuid)) {
Set<Plot> plots = PlotSquared.get().getPlots(offline); Set<Plot> plots = PlotSquared.get().getPlots(existing);
if (!plots.isEmpty()) { if (!plots.isEmpty()) {
for (Plot plot : plots) { for (Plot plot : plots) {
plot.owner = uuid; plot.owner = uuid;
} }
replace(offline, uuid, name.value); replace(existing, uuid, name.value);
} }
return true; return true;
} else { } else {
StringWrapper oName = this.uuidMap.inverse().get(offline); StringWrapper oName = this.uuidMap.inverse().get(existing);
if (!oName.equals(name)) { if (!oName.equals(name)) {
this.uuidMap.remove(name); this.uuidMap.remove(name);
this.uuidMap.put(name, uuid); this.uuidMap.put(name, uuid);
@ -191,6 +191,13 @@ public abstract class UUIDHandlerImplementation {
PlotPlayer player = getPlayer(uuid); PlotPlayer player = getPlayer(uuid);
if (player == null || player.getName().equalsIgnoreCase(name.value)) { if (player == null || player.getName().equalsIgnoreCase(name.value)) {
rename(uuid, name); rename(uuid, name);
return false;
}
StringWrapper newName = new StringWrapper(player.getName());
UUID newUUID = player.getUUID();
if (newUUID.equals(uuid) && !newName.equals(oldName)) {
inverse.remove(uuid);
this.uuidMap.put(newName, newUUID);
} }
return false; return false;
} }