diff options
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager')
4 files changed, 43 insertions, 50 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index ac8404956..b2059a9bc 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -417,7 +417,7 @@ public class GroupManager extends JavaPlugin { return true; } - senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getName()); + senderUser = worldsHolder.getWorldData(senderPlayer).getUser(senderPlayer.getUniqueId().toString()); senderGroup = senderUser.getGroup(); isOpOverride = (isOpOverride && (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager.op"))); @@ -534,7 +534,7 @@ public class GroupManager extends JavaPlugin { } // Validating permissions - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify a player with the same permissions as you, or higher."); return true; } @@ -542,7 +542,7 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); return true; } - if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getLastName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getLastName(), auxGroup.getName()))) { + if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getUUID(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getUUID(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); return true; } @@ -575,7 +575,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -619,7 +619,7 @@ public class GroupManager extends JavaPlugin { return true; } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -627,7 +627,7 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "The sub-group can't be the same as yours, or higher."); return true; } - if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getLastName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getLastName(), auxGroup.getName()))) { + if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getUUID(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getUUID(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); return true; } @@ -666,7 +666,7 @@ public class GroupManager extends JavaPlugin { } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -749,7 +749,7 @@ public class GroupManager extends JavaPlugin { } // Validating your permissions - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher."); return true; } @@ -807,7 +807,7 @@ public class GroupManager extends JavaPlugin { { auxString = args[i].replace("'", ""); - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same group as you, or higher."); continue; } @@ -861,7 +861,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating your permissions - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same group as you, or higher."); return true; } @@ -1660,7 +1660,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher."); return true; } @@ -1669,7 +1669,7 @@ public class GroupManager extends JavaPlugin { overloadedUsers.put(dataHolder.getName().toLowerCase(), new ArrayList<User>()); } dataHolder.overloadUser(auxUser.getLastName()); - overloadedUsers.get(dataHolder.getName().toLowerCase()).add(dataHolder.getUser(auxUser.getLastName())); + overloadedUsers.get(dataHolder.getName().toLowerCase()).add(dataHolder.getUser(auxUser.getUUID())); sender.sendMessage(ChatColor.YELLOW + "Player set to overload mode!"); return true; @@ -1694,7 +1694,7 @@ public class GroupManager extends JavaPlugin { auxUser = dataHolder.getUser(args[0]); } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -1892,7 +1892,7 @@ public class GroupManager extends JavaPlugin { return true; } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -1900,7 +1900,7 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); return true; } - if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getLastName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getLastName(), auxGroup.getName()))) { + if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getUUID(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getUUID(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); return true; } @@ -1948,7 +1948,7 @@ public class GroupManager extends JavaPlugin { return true; } // Validating permission - if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getLastName(), senderGroup.getName()) : false)) { + if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getUUID(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); return true; } @@ -1956,7 +1956,7 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); return true; } - if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getLastName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getLastName(), auxGroup.getName()))) { + if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getUUID(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getUUID(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); return true; } @@ -2208,18 +2208,18 @@ public class GroupManager extends JavaPlugin { if (players.isEmpty()) { // Check for an offline player (exact match). if (Arrays.asList(this.getServer().getOfflinePlayers()).contains(Bukkit.getOfflinePlayer(playerName))) { - match.add(playerName); + match.add(Bukkit.getOfflinePlayer(playerName).getUniqueId().toString()); } else { // look for partial matches for (OfflinePlayer offline : this.getServer().getOfflinePlayers()) { if (offline.getName().toLowerCase().startsWith(playerName.toLowerCase())) - match.add(offline.getName()); + match.add(offline.getUniqueId().toString()); } } } else { for (Player player : players) { - match.add(player.getName()); + match.add(player.getUniqueId().toString()); } } diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index 4a1d6506a..1e1ae96c3 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -108,8 +108,10 @@ public class WorldDataHolder { } /** - * Search for a user. If it doesn't exist, create a new one with default - * group. + * Search for a user. If it doesn't exist, create a new one with default group. + * + * If this is called passing a player name with mantogglevalidate off + * it can return the wrong user object (offline/online UUID match). * * @param userId the UUID String or name of the user * @return class that manage that user permission @@ -162,28 +164,19 @@ public class WorldDataHolder { } // Search for a LastName match + user = getUsers().get(currentName.toLowerCase()); - if (nameToUUIDLookup.containsKey(currentName)) { + if ((user != null) && user.getLastName().equalsIgnoreCase(currentName) && user.getUUID().equalsIgnoreCase(user.getLastName())) { - for (String uid : getUUIDLookup(currentName)) { - - User usr = getUsers().get(uid); - - if (usr.getLastName().equalsIgnoreCase(currentName) && usr.getUUID().equalsIgnoreCase(usr.getLastName())) { - - // Clone this user so we can set it's uUID - user = usr.clone(uUID, currentName); - - // Delete it and replace with the new clone. - this.removeUser(usr.getUUID()); - this.addUser(user); - - return getUsers().get(uUID.toLowerCase()); - } - - } - } + // Clone this user so we can set it's uUID + User usr = user.clone(uUID, currentName); + + // Delete it and replace with the new clone. + this.removeUser(user.getUUID()); + this.addUser(usr); + return getUsers().get(uUID.toLowerCase()); + } // No user account found so create a new one. User newUser = createUser(uUID); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index d8d12d836..12b6d4e7e 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -67,7 +67,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { @Override public boolean permission(Player player, String permission) { - return checkUserPermission(ph.getUser(player.getName()).updatePlayer(player), permission); + return checkUserPermission(ph.getUser(player.getUniqueId().toString()).updatePlayer(player), permission); } /** diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java index a4f68864f..dc2197c91 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java @@ -147,21 +147,21 @@ public class BukkitPermissions { return;
}
- String name = player.getName();
+ String uuid = player.getUniqueId().toString();
// Reset the User objects player reference.
- User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(name);
+ User user = plugin.getWorldsHolder().getWorldData(player.getWorld().getName()).getUser(uuid);
if (user != null)
user.updatePlayer(player);
PermissionAttachment attachment;
// Find the players current attachment, or add a new one.
- if (this.attachments.containsKey(name)) {
- attachment = this.attachments.get(name);
+ if (this.attachments.containsKey(uuid)) {
+ attachment = this.attachments.get(uuid);
} else {
attachment = player.addAttachment(plugin);
- this.attachments.put(name, attachment);
+ this.attachments.put(uuid, attachment);
}
if (world == null) {
@@ -170,7 +170,7 @@ public class BukkitPermissions { // Add all permissions for this player (GM only)
// child nodes will be calculated by Bukkit.
- List<String> playerPermArray = new ArrayList<String>(plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getAllPlayersPermissions(name, false));
+ List<String> playerPermArray = new ArrayList<String>(plugin.getWorldsHolder().getWorldData(world).getPermissionsHandler().getAllPlayersPermissions(uuid, false));
LinkedHashMap<String, Boolean> newPerms = new LinkedHashMap<String, Boolean>();
// Sort the perm list by parent/child, so it will push to superperms
@@ -190,7 +190,7 @@ public class BukkitPermissions { */
if (!Bukkit.getServer().getOnlineMode()
&& (newPerms.containsKey("groupmanager.noofflineperms") && (newPerms.get("groupmanager.noofflineperms") == true))) {
- removeAttachment(name);
+ removeAttachment(uuid);
return;
}
@@ -219,7 +219,7 @@ public class BukkitPermissions { e.printStackTrace();
}
- GroupManager.logger.finest("Attachment updated for: " + name);
+ GroupManager.logger.finest("Attachment updated for: " + player.getName());
}
/**
|