Fix overloadedWorldHolder so it correctly calls the new WorldHolder code when the user is not overloaded.

This commit is contained in:
ElgarL 2014-04-14 23:40:04 +01:00 committed by KHobbits
parent 32f49350cf
commit aae586f79a
4 changed files with 17 additions and 23 deletions

View File

@ -100,14 +100,14 @@ public abstract class DataUnit {
public String getLastName() { public String getLastName() {
if (uUID.length() < 36) if (uUID.length() < 36)
return uUID; return this.uUID;
return lastName; return this.lastName;
} }
public void setLastName(String lastName) { public void setLastName(String lastName) {
if (!this.lastName.equals(lastName)) { if (!lastName.equals(this.lastName)) {
this.lastName = lastName; this.lastName = lastName;
changed = true; changed = true;

View File

@ -69,10 +69,10 @@ public class User extends DataUnit implements Cloneable {
*/ */
public User clone(WorldDataHolder dataSource) { public User clone(WorldDataHolder dataSource) {
if (dataSource.isUserDeclared(this.getLastName())) { if (dataSource.isUserDeclared(this.getUUID())) {
return null; return null;
} }
User clone = dataSource.createUser(this.getLastName()); User clone = dataSource.createUser(this.getUUID());
if (dataSource.getGroup(group) == null) { if (dataSource.getGroup(group) == null) {
clone.setGroup(dataSource.getDefaultGroup()); clone.setGroup(dataSource.getDefaultGroup());
} else { } else {
@ -86,17 +86,14 @@ public class User extends DataUnit implements Cloneable {
return clone; return clone;
} }
public User clone(String uUID) { public User clone(String uUID, String CurrentName) {
User clone = this.getDataSource().createUser(uUID); User clone = this.getDataSource().createUser(uUID);
if (this.getDataSource().getGroup(group) == null) { clone.setLastName(CurrentName);
clone.setGroup(this.getDataSource().getDefaultGroup());
} else {
clone.setGroup(this.getDataSource().getGroup(this.getGroupName()));
}
clone.setLastName(this.getLastName()); // Set the group silently.
clone.setGroup(this.getDataSource().getGroup(this.getGroupName()), false);
for (String perm : this.getPermissionList()) { for (String perm : this.getPermissionList()) {
clone.addPermission(perm); clone.addPermission(perm);
@ -181,6 +178,7 @@ public class User extends DataUnit implements Cloneable {
if (notify) if (notify)
GroupManager.notify(this.getLastName(), String.format(" moved to the group %s in %s.", group.getName(), this.getDataSource().getName())); GroupManager.notify(this.getLastName(), String.format(" moved to the group %s in %s.", group.getName(), this.getDataSource().getName()));
if (updatePerms)
GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED); GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED);
} }
} }

View File

@ -49,12 +49,8 @@ public class OverloadedWorldHolder extends WorldDataHolder {
return overloadedUsers.get(userNameLowered); return overloadedUsers.get(userNameLowered);
} }
//END CODE //END CODE
if (getUsers().containsKey(userNameLowered)) {
return getUsers().get(userNameLowered); return super.getUser(userName);
}
User newUser = createUser(userName);
setUsersChanged(true);
return newUser;
} }
/** /**

View File

@ -119,9 +119,10 @@ public class WorldDataHolder {
// Search for a LastName match // Search for a LastName match
for (User user : getUserList()) { for (User user : getUserList()) {
if (user.getLastName().equalsIgnoreCase(userId)) if (user.getLastName().equalsIgnoreCase(userId)) {
return user; return user;
} }
}
} }
@ -157,14 +158,13 @@ public class WorldDataHolder {
if (usr.getLastName().equalsIgnoreCase(currentName)) { if (usr.getLastName().equalsIgnoreCase(currentName)) {
// Clone this user so we can set it's uUID // Clone this user so we can set it's uUID
user = usr.clone(uUID); user = usr.clone(uUID, currentName);
// Delete it and replace with the new clone. // Delete it and replace with the new clone.
this.removeUser(usr.getUUID()); this.removeUser(usr.getUUID());
user.setLastName(currentName);
this.addUser(user); this.addUser(user);
return user; return getUsers().get(uUID.toLowerCase());
} }
} }