From aae586f79ac177734eefac9e786dc5fc50dabb43 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Mon, 14 Apr 2014 23:40:04 +0100 Subject: Fix overloadedWorldHolder so it correctly calls the new WorldHolder code when the user is not overloaded. --- .../src/org/anjocaido/groupmanager/data/DataUnit.java | 6 +++--- .../src/org/anjocaido/groupmanager/data/User.java | 18 ++++++++---------- .../groupmanager/dataholder/OverloadedWorldHolder.java | 8 ++------ .../groupmanager/dataholder/WorldDataHolder.java | 8 ++++---- 4 files changed, 17 insertions(+), 23 deletions(-) (limited to 'EssentialsGroupManager') diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java index 36c26bb1d..90fd28e8d 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/DataUnit.java @@ -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; diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java index e6d11274f..38663ba7d 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java @@ -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); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java index d91630a70..6b494b03c 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java @@ -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); } /** diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 75d8ed570..14a9a052d 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -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()); } } -- cgit v1.2.3