diff options
Diffstat (limited to 'EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java')
-rw-r--r-- | EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java | 438 |
1 files changed, 256 insertions, 182 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index 14006bf75..6e75b3a8a 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -56,7 +56,7 @@ public class GroupManager extends JavaPlugin { private Runnable commiter; private ScheduledThreadPoolExecutor scheduler; private Map<String, ArrayList<User>> overloadedUsers = new HashMap<String, ArrayList<User>>(); - private Map<CommandSender, String> selectedWorlds = new HashMap<CommandSender, String>(); + private Map<String, String> selectedWorlds = new HashMap<String, String>(); private WorldsHolder worldsHolder; private boolean validateOnlinePlayer = true; @@ -142,7 +142,7 @@ public class GroupManager extends JavaPlugin { * reset local variables. */ overloadedUsers = new HashMap<String, ArrayList<User>>(); - selectedWorlds = new HashMap<CommandSender, String>(); + selectedWorlds = new HashMap<String, String>(); lastError = ""; /* @@ -393,7 +393,8 @@ public class GroupManager extends JavaPlugin { // PREVENT GM COMMANDS BEING USED ON COMMANDBLOCKS if (sender instanceof BlockCommandSender && !isAllowCommandBlocks) { Block block = ((BlockCommandSender)sender).getBlock(); - GroupManager.logger.warning(ChatColor.RED + "GM Commands can not be called from the CommandBlock at location: " + ChatColor.GREEN + block.getWorld().getName() + " - " + block.getX() + ", " + block.getY() + ", " + block.getZ()); + GroupManager.logger.warning(ChatColor.RED + "GM Commands can not be called from CommandBlocks"); + GroupManager.logger.warning(ChatColor.RED + "Location: " + ChatColor.GREEN + block.getWorld().getName() + ", " + block.getX() + ", " + block.getY() + ", " + block.getZ()); return true; } @@ -410,11 +411,10 @@ public class GroupManager extends JavaPlugin { senderGroup = senderUser.getGroup(); isOpOverride = (isOpOverride && (senderPlayer.isOp() || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager.op"))); - System.out.println("[PLAYER_COMMAND] " + senderPlayer.getName() + ": /" + commandLabel + " " + Tasks.join(args, " ")); if (isOpOverride || worldsHolder.getWorldPermissions(senderPlayer).has(senderPlayer, "groupmanager." + cmd.getName())) { playerCanDo = true; } - } else if ((sender instanceof ConsoleCommandSender) || (sender instanceof RemoteConsoleCommandSender)) { + } else if ((sender instanceof ConsoleCommandSender) || (sender instanceof RemoteConsoleCommandSender) || (sender instanceof BlockCommandSender)) { if (!lastError.isEmpty() && !commandLabel.equalsIgnoreCase("manload")) { sender.sendMessage(ChatColor.RED + "All commands are locked due to an error. " + ChatColor.BOLD + "" + ChatColor.UNDERLINE + "Check the log" + ChatColor.RESET + "" + ChatColor.RED + " and then try a '/manload'."); @@ -432,7 +432,7 @@ public class GroupManager extends JavaPlugin { dataHolder = worldsHolder.getWorldData(senderPlayer); } - String selectedWorld = selectedWorlds.get(sender); + String selectedWorld = selectedWorlds.get(sender.getName()); if (selectedWorld != null) { dataHolder = worldsHolder.getWorldData(selectedWorld); } @@ -488,8 +488,8 @@ public class GroupManager extends JavaPlugin { // Validating arguments if ((args.length != 2) && (args.length != 3)) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <group> | optional [world])"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manuadd <player> <group> | optional [world])"); + return true; } // Select the relevant world (if specified) @@ -515,7 +515,7 @@ public class GroupManager extends JavaPlugin { } auxGroup = dataHolder.getGroup(args[1]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not found!"); + sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); return false; } if (auxGroup.isGlobal()) { @@ -526,15 +526,15 @@ public class GroupManager extends JavaPlugin { // Validating permissions if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify a player with the same permissions as you, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); - return false; + return true; } // Seems OK @@ -552,8 +552,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manudel <player>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -567,7 +567,7 @@ public class GroupManager extends JavaPlugin { // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } // Seems OK dataHolder.removeUser(auxUser.getName()); @@ -591,8 +591,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manuaddsub <player> <group>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -605,13 +605,13 @@ public class GroupManager extends JavaPlugin { } auxGroup = dataHolder.getGroup(args[1]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not found!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); + return true; } // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } // Seems OK if (auxUser.addSubGroup(auxGroup)) @@ -630,7 +630,7 @@ public class GroupManager extends JavaPlugin { // Validating arguments if (args.length != 2) { sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manudelsub <user> <group>)"); - return false; + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -643,14 +643,14 @@ public class GroupManager extends JavaPlugin { } auxGroup = dataHolder.getGroup(args[1]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not found!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); + return true; } // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } // Seems OK auxUser.removeSubGroup(auxGroup); @@ -670,13 +670,13 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangadd <group>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup != null) { - sender.sendMessage(ChatColor.RED + "Group already exists!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group already exist!"); + return true; } // Seems OK auxGroup = dataHolder.createGroup(args[0]); @@ -692,13 +692,13 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group>)"); + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangdel <group>)"); return false; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not exists!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } // Seems OK dataHolder.removeGroup(auxGroup.getName()); @@ -716,9 +716,16 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manuaddp <player> <permission>)"); + return true; } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); + } + if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; } @@ -731,41 +738,52 @@ public class GroupManager extends JavaPlugin { // Validating your permissions if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same group than you, or higher."); - return false; + return true; } permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]); if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { sender.sendMessage(ChatColor.RED + "You can't add a permission you don't have."); - return false; + return true; } // Validating permissions of user permissionResult = permissionHandler.checkUserOnlyPermission(auxUser, args[1]); - if (args[1].startsWith("+")) { + if (auxString.startsWith("+")) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { sender.sendMessage(ChatColor.RED + "The user already has direct access to that permission."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } - } else if (args[1].startsWith("-")) { + } else if (auxString.startsWith("-")) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { sender.sendMessage(ChatColor.RED + "The user already has an exception for this node."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { - sender.sendMessage(ChatColor.RED + "The user already has a matching node "); + sender.sendMessage(ChatColor.RED + "The user already has a matching node."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } } else { - if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND)) { + if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { + // Warn only while still allowing you to add the node. + sender.sendMessage(ChatColor.RED + "The user already has an exception for this node."); + sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); + } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND)) { sender.sendMessage(ChatColor.RED + "The user already has direct access to that permission."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + if (permissionResult.accessLevel.equalsIgnoreCase(args[1])) + { + return true; + } + } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { + // Warn only while still allowing you to add the node. + sender.sendMessage(ChatColor.RED + "The user already has a matching Negated node."); + sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); } } // Seems OK - auxUser.addPermission(args[1]); - sender.sendMessage(ChatColor.YELLOW + "You added '" + args[1] + "' to player '" + auxUser.getName() + "' permissions."); + auxUser.addPermission(auxString); + sender.sendMessage(ChatColor.YELLOW + "You added '" + auxString + "' to player '" + auxUser.getName() + "' permissions."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) @@ -781,9 +799,16 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manudelp <player> <permission>)"); + return true; + } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); } + if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; } @@ -796,27 +821,27 @@ public class GroupManager extends JavaPlugin { // Validating your permissions if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same group as you, or higher."); - return false; + return true; } - permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]); + permissionResult = permissionHandler.checkFullUserPermission(senderUser, auxString); if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { sender.sendMessage(ChatColor.RED + "You can't remove a permission you don't have."); - return false; + return true; } // Validating permissions of user - permissionResult = permissionHandler.checkUserOnlyPermission(auxUser, args[1]); + permissionResult = permissionHandler.checkUserOnlyPermission(auxUser, auxString); if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) { sender.sendMessage(ChatColor.RED + "The user doesn't have direct access to that permission."); - return false; + return true; } - if (!auxUser.hasSamePermissionNode(args[1])) { + if (!auxUser.hasSamePermissionNode(auxString)) { sender.sendMessage(ChatColor.RED + "This permission node doesn't match any node."); sender.sendMessage(ChatColor.RED + "But might match node: " + permissionResult.accessLevel); - return false; + return true; } // Seems OK - auxUser.removePermission(args[1]); - sender.sendMessage(ChatColor.YELLOW + "You removed '" + args[1] + "' from player '" + auxUser.getName() + "' permissions."); + auxUser.removePermission(auxString); + sender.sendMessage(ChatColor.YELLOW + "You removed '" + auxString + "' from player '" + auxUser.getName() + "' permissions."); targetPlayer = this.getServer().getPlayer(auxUser.getName()); if (targetPlayer != null) @@ -832,8 +857,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if ((args.length == 0) || (args.length > 2)) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> (+))"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manulistp <player> (+))"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { @@ -897,8 +922,14 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manucheckp <player> <permission>)"); + return true; + } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { @@ -912,24 +943,24 @@ public class GroupManager extends JavaPlugin { } targetPlayer = this.getServer().getPlayer(auxUser.getName()); // Validating permission - permissionResult = permissionHandler.checkFullGMPermission(auxUser, args[1], false); + permissionResult = permissionHandler.checkFullGMPermission(auxUser, auxString, false); if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) { // No permissions found in GM so fall through and check Bukkit. - sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission"); + sender.sendMessage(ChatColor.YELLOW + "The player doesn't have access to that permission"); } else { // This permission was found in groupmanager. if (permissionResult.owner instanceof User) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { - sender.sendMessage(ChatColor.RED + "The user has directly a negation node for that permission."); + sender.sendMessage(ChatColor.YELLOW + "The user has directly a negation node for that permission."); } else { sender.sendMessage(ChatColor.YELLOW + "The user has directly this permission."); } sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel); } else if (permissionResult.owner instanceof Group) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { - sender.sendMessage(ChatColor.RED + "The user inherits a negation permission from group: " + permissionResult.owner.getName()); + sender.sendMessage(ChatColor.YELLOW + "The user inherits a negation permission from group: " + permissionResult.owner.getName()); } else { sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName()); } @@ -952,48 +983,67 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangaaddp <group> <permission>)"); + return true; + } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); } + auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); return false; } // Validating your permissions permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]); if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { sender.sendMessage(ChatColor.RED + "You can't add a permission you don't have."); - return false; + return true; } // Validating permissions of user permissionResult = permissionHandler.checkGroupOnlyPermission(auxGroup, args[1]); - if (args[1].startsWith("+")) { + if (auxString.startsWith("+")) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { sender.sendMessage(ChatColor.RED + "The group already has direct access to that permission."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } - } else if (args[1].startsWith("-")) { + } else if (auxString.startsWith("-")) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { sender.sendMessage(ChatColor.RED + "The group already has an exception for this node."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { sender.sendMessage(ChatColor.RED + "The group already has a matching node."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + return true; } } else { - if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND)) { + if (permissionResult.resultType.equals(PermissionCheckResult.Type.EXCEPTION)) { + // Warn only while still allowing you to add the node. + sender.sendMessage(ChatColor.RED + "The group already has an exception for this node."); + sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); + } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.FOUND)) { sender.sendMessage(ChatColor.RED + "The group already has direct access to that permission."); sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); - return false; + // Abort adding if the node is a direct match. + if (permissionResult.accessLevel.equalsIgnoreCase(args[1])) + { + return true; + } + } else if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { + // Warn only while still allowing you to add the node. + sender.sendMessage(ChatColor.RED + "The group already has a matching Negated node."); + sender.sendMessage(ChatColor.RED + "Node: " + permissionResult.accessLevel); } } // Seems OK - auxGroup.addPermission(args[1]); - sender.sendMessage(ChatColor.YELLOW + "You added '" + args[1] + "' to group '" + auxGroup.getName() + "' permissions."); + auxGroup.addPermission(auxString); + sender.sendMessage(ChatColor.YELLOW + "You added '" + auxString + "' to group '" + auxGroup.getName() + "' permissions."); BukkitPermissions.updateAllPlayers(); @@ -1007,34 +1057,41 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangdelp <group> <permission>)"); + return true; } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); + } + auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } // Validating your permissions - permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]); + permissionResult = permissionHandler.checkFullUserPermission(senderUser, auxString); if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have."); - return false; + return true; } // Validating permissions of user - permissionResult = permissionHandler.checkGroupOnlyPermission(auxGroup, args[1]); + permissionResult = permissionHandler.checkGroupOnlyPermission(auxGroup, auxString); if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) { sender.sendMessage(ChatColor.RED + "The group doesn't have direct access to that permission."); return false; } - if (!auxGroup.hasSamePermissionNode(args[1])) { + if (!auxGroup.hasSamePermissionNode(auxString)) { sender.sendMessage(ChatColor.RED + "This permission node doesn't match any node."); sender.sendMessage(ChatColor.RED + "But might match node: " + permissionResult.accessLevel); - return false; + return true; } // Seems OK - auxGroup.removePermission(args[1]); - sender.sendMessage(ChatColor.YELLOW + "You removed '" + args[1] + "' from group '" + auxGroup.getName() + "' permissions."); + auxGroup.removePermission(auxString); + sender.sendMessage(ChatColor.YELLOW + "You removed '" + auxString + "' from group '" + auxGroup.getName() + "' permissions."); BukkitPermissions.updateAllPlayers(); @@ -1048,13 +1105,13 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manglistp <group>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } // Validating permission @@ -1097,25 +1154,32 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <permission>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangcheckp <group> <permission>)"); + return true; + } + + auxString = args[1]; + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); } + auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } // Validating permission - permissionResult = permissionHandler.checkGroupPermissionWithInheritance(auxGroup, args[1]); + permissionResult = permissionHandler.checkGroupPermissionWithInheritance(auxGroup, auxString); if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) { - sender.sendMessage(ChatColor.RED + "The group doesn't have access to that permission"); - return false; + sender.sendMessage(ChatColor.YELLOW + "The group doesn't have access to that permission"); + return true; } // Seems OK // auxString = permissionHandler.checkUserOnlyPermission(auxUser, args[1]); if (permissionResult.owner instanceof Group) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) { - sender.sendMessage(ChatColor.RED + "The group inherits the negation permission from group: " + permissionResult.owner.getName()); + sender.sendMessage(ChatColor.YELLOW + "The group inherits the negation permission from group: " + permissionResult.owner.getName()); } else { sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName()); } @@ -1132,28 +1196,28 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group1> <group2>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangaddi <group1> <group2>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group 1 does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } auxGroup2 = dataHolder.getGroup(args[1]); if (auxGroup2 == null) { - sender.sendMessage(ChatColor.RED + "Group 2 does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance."); - return false; + return true; } // Validating permission if (permissionHandler.hasGroupInInheritance(auxGroup, auxGroup2.getName())) { sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " already inherits " + auxGroup2.getName() + " (might not be directly)"); - return false; + return true; } // Seems OK auxGroup.addInherits(auxGroup2); @@ -1171,32 +1235,32 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group1> <group2>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangdeli <group1> <group2>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group 1 does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } auxGroup2 = dataHolder.getGroup(args[1]); if (auxGroup2 == null) { - sender.sendMessage(ChatColor.RED + "Group 2 does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support inheritance."); - return false; + return true; } // Validating permission if (!permissionHandler.hasGroupInInheritance(auxGroup, auxGroup2.getName())) { sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + "."); - return false; + return true; } if (!auxGroup.getInherits().contains(auxGroup2.getName())) { sender.sendMessage(ChatColor.RED + "Group " + auxGroup.getName() + " does not inherits " + auxGroup2.getName() + " directly."); - return false; + return true; } // Seems OK auxGroup.removeInherits(auxGroup2.getName()); @@ -1214,8 +1278,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length < 3) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <user> <variable> <value>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manuaddv <user> <variable> <value>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1235,6 +1299,10 @@ public class GroupManager extends JavaPlugin { auxString += " "; } } + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); + } auxUser.getVariables().addVar(args[1], Variables.parseVariableValue(auxString)); sender.sendMessage(ChatColor.YELLOW + "Variable " + ChatColor.GOLD + args[1] + ChatColor.YELLOW + ":'" + ChatColor.GREEN + auxString + ChatColor.YELLOW + "' added to the user " + auxUser.getName()); @@ -1248,8 +1316,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <user> <variable>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manudelv <user> <variable>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1263,6 +1331,7 @@ public class GroupManager extends JavaPlugin { // Validating permission if (!auxUser.getVariables().hasVar(args[1])) { sender.sendMessage(ChatColor.RED + "The user doesn't have directly that variable!"); + return true; } // Seems OK auxUser.getVariables().removeVar(args[1]); @@ -1278,8 +1347,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <user>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manulistv <user>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1313,8 +1382,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <user> <variable>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manucheckv <user> <variable>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1337,8 +1406,8 @@ public class GroupManager extends JavaPlugin { continue; } if (auxGroup2 == null) { - sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!"); - return false; + sender.sendMessage(ChatColor.YELLOW + "The user doesn't have access to that variable!"); + return true; } } // Seems OK @@ -1361,17 +1430,17 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length < 3) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <variable> <value>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangaddv <group> <variable> <value>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes."); - return false; + return true; } // Validating permission // Seems OK @@ -1382,6 +1451,10 @@ public class GroupManager extends JavaPlugin { auxString += " "; } } + if (auxString.startsWith("'") && auxString.endsWith("'")) + { + auxString = auxString.substring(1, auxString.length() - 1); + } auxGroup.getVariables().addVar(args[1], Variables.parseVariableValue(auxString)); sender.sendMessage(ChatColor.YELLOW + "Variable " + ChatColor.GOLD + args[1] + ChatColor.YELLOW + ":'" + ChatColor.GREEN + auxString + ChatColor.YELLOW + "' added to the group " + auxGroup.getName()); @@ -1395,21 +1468,22 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <variable>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangdelv <group> <variable>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes."); - return false; + return true; } // Validating permission if (!auxGroup.getVariables().hasVar(args[1])) { sender.sendMessage(ChatColor.RED + "The group doesn't have directly that variable!"); + return true; } // Seems OK auxGroup.getVariables().removeVar(args[1]); @@ -1425,17 +1499,17 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manglistv <group>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes."); - return false; + return true; } // Validating permission // Seems OK @@ -1468,17 +1542,17 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <group> <variable>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangcheckv <group> <variable>)"); + return true; } auxGroup = dataHolder.getGroup(args[0]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "The specified group does not exist!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "GlobalGroups do NOT support Info Nodes."); - return false; + return true; } // Validating permission auxGroup2 = permissionHandler.nextGroupWithVariable(auxGroup, args[1]); @@ -1501,8 +1575,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manwhois <player>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1541,8 +1615,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/tempadd <player>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1555,7 +1629,7 @@ public class GroupManager extends JavaPlugin { // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "Can't modify player with same permissions than you, or higher."); - return false; + return true; } // Seems OK if (overloadedUsers.get(dataHolder.getName().toLowerCase()) == null) { @@ -1563,7 +1637,7 @@ public class GroupManager extends JavaPlugin { } dataHolder.overloadUser(auxUser.getName()); overloadedUsers.get(dataHolder.getName().toLowerCase()).add(dataHolder.getUser(auxUser.getName())); - sender.sendMessage(ChatColor.YELLOW + "Player overloaded!"); + sender.sendMessage(ChatColor.YELLOW + "Player set to overload mode!"); return true; @@ -1575,8 +1649,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/tempdel <player>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1589,7 +1663,7 @@ public class GroupManager extends JavaPlugin { // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } // Seems OK if (overloadedUsers.get(dataHolder.getName().toLowerCase()) == null) { @@ -1599,7 +1673,7 @@ public class GroupManager extends JavaPlugin { if (overloadedUsers.get(dataHolder.getName().toLowerCase()).contains(auxUser)) { overloadedUsers.get(dataHolder.getName().toLowerCase()).remove(auxUser); } - sender.sendMessage(ChatColor.YELLOW + "You removed that player's overload. He's back to normal!"); + sender.sendMessage(ChatColor.YELLOW + "Player overload mode is now disabled."); return true; @@ -1759,8 +1833,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manpromote <player> <group>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1772,33 +1846,33 @@ public class GroupManager extends JavaPlugin { } auxGroup = dataHolder.getGroup(args[1]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not found!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "Players may not be members of GlobalGroups directly."); - return false; + return true; } // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player using groups with different heritage line."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { sender.sendMessage(ChatColor.RED + "The new group must be a higher rank."); - return false; + return true; } // Seems OK auxUser.setGroup(auxGroup); @@ -1815,8 +1889,8 @@ public class GroupManager extends JavaPlugin { } // Validating arguments if (args.length != 2) { - sender.sendMessage(ChatColor.RED + "Review your arguments count! (/<command> <player> <group>)"); - return false; + sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mandemote <player> <group>)"); + return true; } if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) { return false; @@ -1828,33 +1902,33 @@ public class GroupManager extends JavaPlugin { } auxGroup = dataHolder.getGroup(args[1]); if (auxGroup == null) { - sender.sendMessage(ChatColor.RED + "Group not found!"); - return false; + sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); + return true; } if (auxGroup.isGlobal()) { sender.sendMessage(ChatColor.RED + "Players may not be members of GlobalGroups directly."); - return false; + return true; } // Validating permission if (!isConsole && !isOpOverride && (senderGroup != null ? permissionHandler.inGroup(auxUser.getName(), senderGroup.getName()) : false)) { sender.sendMessage(ChatColor.RED + "You can't modify a player with same permissions as you, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, senderGroup.getName()))) { sender.sendMessage(ChatColor.RED + "The destination group can't be the same as yours, or higher."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.inGroup(senderUser.getName(), auxUser.getGroupName()) || !permissionHandler.inGroup(senderUser.getName(), auxGroup.getName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); - return false; + return true; } if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { sender.sendMessage(ChatColor.RED + "You can't modify a player using groups with different inheritage line."); - return false; + return true; } if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { sender.sendMessage(ChatColor.RED + "The new group must be a lower rank."); - return false; + return true; } // Seems OK auxUser.setGroup(auxGroup); @@ -1881,7 +1955,7 @@ public class GroupManager extends JavaPlugin { } return true; case manworld: - auxString = selectedWorlds.get(sender); + auxString = selectedWorlds.get(sender.getName()); if (auxString != null) { sender.sendMessage(ChatColor.YELLOW + "You have the world '" + dataHolder.getName() + "' in your selection."); } else { @@ -1924,7 +1998,7 @@ public class GroupManager extends JavaPlugin { } dataHolder = worldsHolder.getWorldData(auxString); permissionHandler = dataHolder.getPermissionsHandler(); - selectedWorlds.put(sender, dataHolder.getName()); + selectedWorlds.put(sender.getName(), dataHolder.getName()); sender.sendMessage(ChatColor.YELLOW + "You have selected world '" + dataHolder.getName() + "'."); return true; @@ -1934,7 +2008,7 @@ public class GroupManager extends JavaPlugin { sender.sendMessage(ChatColor.RED + "Review your arguments count!"); return false; } - selectedWorlds.remove(sender); + selectedWorlds.remove(sender.getName()); sender.sendMessage(ChatColor.YELLOW + "You have removed your world selection. Working with current world(if possible)."); return true; @@ -1980,7 +2054,7 @@ public class GroupManager extends JavaPlugin { } } sender.sendMessage(ChatColor.RED + "You are not allowed to use that command."); - return false; + return true; } /** @@ -1992,7 +2066,7 @@ public class GroupManager extends JavaPlugin { permissionHandler = dataHolder.getPermissionsHandler(); if ((dataHolder != null) && (permissionHandler != null)) { - selectedWorlds.put(sender, dataHolder.getName()); + selectedWorlds.put(sender.getName(), dataHolder.getName()); sender.sendMessage(ChatColor.RED + "Couldn't retrieve your world. Default world '" + worldsHolder.getDefaultWorld().getName() + "' selected."); return true; } |