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() {
if (uUID.length() < 36)
return uUID;
return this.uUID;
return lastName;
return this.lastName;
}
public void setLastName(String lastName) {
if (!this.lastName.equals(lastName)) {
if (!lastName.equals(this.lastName)) {
this.lastName = lastName;
changed = true;

View File

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

View File

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

View File

@ -119,8 +119,9 @@ public class WorldDataHolder {
// Search for a LastName match
for (User user : getUserList()) {
if (user.getLastName().equalsIgnoreCase(userId))
if (user.getLastName().equalsIgnoreCase(userId)) {
return user;
}
}
}
@ -157,14 +158,13 @@ public class WorldDataHolder {
if (usr.getLastName().equalsIgnoreCase(currentName)) {
// 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.
this.removeUser(usr.getUUID());
user.setLastName(currentName);
this.addUser(user);
return user;
return getUsers().get(uUID.toLowerCase());
}
}