summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
diff options
context:
space:
mode:
authorElgarL <ElgarL@Palmergames.com>2014-04-14 22:19:14 +0100
committerKHobbits <rob@khobbits.co.uk>2014-05-04 12:50:17 +0100
commit9739784e7501c906dec19bb169e762a5313df213 (patch)
treee86e4da79a758ff5d33067c3a364eee719fab46d /EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
parenta0e93af758b8f31e30b86b4062734e82492f8491 (diff)
downloadEssentials-9739784e7501c906dec19bb169e762a5313df213.tar
Essentials-9739784e7501c906dec19bb169e762a5313df213.tar.gz
Essentials-9739784e7501c906dec19bb169e762a5313df213.tar.lz
Essentials-9739784e7501c906dec19bb169e762a5313df213.tar.xz
Essentials-9739784e7501c906dec19bb169e762a5313df213.zip
v2.1: - Update for CraftBukkit 1.7.8-R0.1(3050). - Add UUID support. Plugins can still query by player name but a UUID is faster and preferable.
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java45
1 files changed, 40 insertions, 5 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
index adec183cd..61efdc3de 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/data/User.java
@@ -51,7 +51,7 @@ public class User extends DataUnit implements Cloneable {
@Override
public User clone() {
- User clone = new User(getDataSource(), this.getName());
+ User clone = new User(getDataSource(), this.getLastName());
clone.group = this.group;
for (String perm : this.getPermissionList()) {
clone.addPermission(perm);
@@ -69,10 +69,10 @@ public class User extends DataUnit implements Cloneable {
*/
public User clone(WorldDataHolder dataSource) {
- if (dataSource.isUserDeclared(this.getName())) {
+ if (dataSource.isUserDeclared(this.getLastName())) {
return null;
}
- User clone = dataSource.createUser(this.getName());
+ User clone = dataSource.createUser(this.getLastName());
if (dataSource.getGroup(group) == null) {
clone.setGroup(dataSource.getDefaultGroup());
} else {
@@ -85,6 +85,28 @@ public class User extends DataUnit implements Cloneable {
clone.flagAsChanged();
return clone;
}
+
+ public User clone(String uUID) {
+
+ 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(this.getLastName());
+
+ for (String perm : this.getPermissionList()) {
+ clone.addPermission(perm);
+ }
+
+ clone.variables = this.variables.clone(this);
+ clone.flagAsChanged();
+
+ return clone;
+ }
public Group getGroup() {
@@ -107,6 +129,19 @@ public class User extends DataUnit implements Cloneable {
}
return group;
}
+
+ /**
+ * Place holder to let people know to stop using this method.
+ *
+ * @deprecated use {@link getLastName()} and {@link getUUID()}.
+ * @return a string containing the players last known name.
+ */
+ @Deprecated
+ public String getName() {
+
+ return this.getLastName();
+
+ }
/**
@@ -144,7 +179,7 @@ public class User extends DataUnit implements Cloneable {
boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName)));
if (notify)
- GroupManager.notify(this.getName(), 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()));
GroupManager.getGMEventHandler().callEvent(this, Action.USER_GROUP_CHANGED);
}
@@ -269,7 +304,7 @@ public class User extends DataUnit implements Cloneable {
public Player getBukkitPlayer() {
if (bukkitPlayer == null) {
- bukkitPlayer = Bukkit.getPlayer(this.getName());
+ bukkitPlayer = Bukkit.getPlayer(this.getLastName());
}
return bukkitPlayer;
}