Merge pull request #371 from necrodoom/patch-72

add new commands and others
This commit is contained in:
ElgarL 2013-03-28 05:59:35 -07:00
commit e15a8c50d6
3 changed files with 124 additions and 30 deletions

View file

@ -515,7 +515,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[1]); auxGroup = dataHolder.getGroup(args[1]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[1] + "' Group doesnt exist!");
return false; return false;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -605,7 +605,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[1]); auxGroup = dataHolder.getGroup(args[1]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[1] + "' Group doesnt exist!");
return true; return true;
} }
// Validating permission // Validating permission
@ -643,7 +643,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[1]); auxGroup = dataHolder.getGroup(args[1]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[1] + "' Group doesnt exist!");
return true; return true;
} }
@ -675,7 +675,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup != null) { if (auxGroup != null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group already exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group already exist!");
return true; return true;
} }
// Seems OK // Seems OK
@ -849,6 +849,50 @@ public class GroupManager extends JavaPlugin {
return true; return true;
case manuclearp:
// Validating state of sender
if (dataHolder == null || permissionHandler == null) {
if (!setDefaultWorldHandler(sender))
return true;
}
// Validating arguments
if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/manuclearp <player>)");
return true;
}
if ((validateOnlinePlayer) && ((match = validatePlayer(args[0], sender)) == null)) {
return false;
}
if (match != null) {
auxUser = dataHolder.getUser(match.get(0));
} else {
auxUser = dataHolder.getUser(args[0]);
}
// 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 true;
}
for (auxString : auxUser.getPermissionList()) {
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: '" + auxString + "'.");
}
else
{
auxUser.removePermission(auxString);
}
}
sender.sendMessage(ChatColor.YELLOW + "You removed all permissions from player '" + auxUser.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
if (targetPlayer != null)
BukkitPermissions.updatePermissions(targetPlayer);
return true;
case manulistp: case manulistp:
// Validating state of sender // Validating state of sender
if (dataHolder == null || permissionHandler == null) { if (dataHolder == null || permissionHandler == null) {
@ -995,7 +1039,7 @@ public class GroupManager extends JavaPlugin {
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return false; return false;
} }
// Validating your permissions // Validating your permissions
@ -1069,20 +1113,20 @@ public class GroupManager extends JavaPlugin {
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
// Validating your permissions // Validating your permissions
permissionResult = permissionHandler.checkFullUserPermission(senderUser, auxString); permissionResult = permissionHandler.checkFullUserPermission(senderUser, auxString);
if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) { if (!isConsole && !isOpOverride && (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."); sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
return true; return true;
} }
// Validating permissions of user // Validating permissions of user
permissionResult = permissionHandler.checkGroupOnlyPermission(auxGroup, auxString); permissionResult = permissionHandler.checkGroupOnlyPermission(auxGroup, auxString);
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) { if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
sender.sendMessage(ChatColor.RED + "The group doesn't have direct access to that permission."); sender.sendMessage(ChatColor.YELLOW + "The group doesn't have direct access to that permission.");
return false; return true;
} }
if (!auxGroup.hasSamePermissionNode(auxString)) { if (!auxGroup.hasSamePermissionNode(auxString)) {
sender.sendMessage(ChatColor.RED + "This permission node doesn't match any node."); sender.sendMessage(ChatColor.RED + "This permission node doesn't match any node.");
@ -1097,6 +1141,40 @@ public class GroupManager extends JavaPlugin {
return true; return true;
case mangclearp:
// Validating state of sender
if (dataHolder == null || permissionHandler == null) {
if (!setDefaultWorldHandler(sender))
return true;
}
// Validating arguments
if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Review your arguments count! (/mangclearp <group>)");
return true;
}
auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true;
}
for (auxString : auxGroup.getPermissionList()) {
permissionResult = permissionHandler.checkFullUserPermission(senderUser, auxString);
if (!isConsole && !isOpOverride && (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: '" + auxString + "'.");
}
else
{
auxGroup.removePermission(auxString);
}
}
sender.sendMessage(ChatColor.YELLOW + "You removed all permissions from group '" + auxGroup.getName() + "'.");
BukkitPermissions.updateAllPlayers();
return true;
case manglistp: case manglistp:
// Validating state of sender // Validating state of sender
if (dataHolder == null || permissionHandler == null) { if (dataHolder == null || permissionHandler == null) {
@ -1110,7 +1188,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
// Validating permission // Validating permission
@ -1166,7 +1244,7 @@ public class GroupManager extends JavaPlugin {
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
// Validating permission // Validating permission
@ -1201,12 +1279,12 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
auxGroup2 = dataHolder.getGroup(args[1]); auxGroup2 = dataHolder.getGroup(args[1]);
if (auxGroup2 == null) { if (auxGroup2 == null) {
sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[1] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1240,12 +1318,12 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
auxGroup2 = dataHolder.getGroup(args[1]); auxGroup2 = dataHolder.getGroup(args[1]);
if (auxGroup2 == null) { if (auxGroup2 == null) {
sender.sendMessage(ChatColor.RED + "" + args[1] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[1] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1435,7 +1513,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1473,7 +1551,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1504,7 +1582,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1547,7 +1625,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[0]); auxGroup = dataHolder.getGroup(args[0]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1812,16 +1890,21 @@ public class GroupManager extends JavaPlugin {
} }
// WORKING // WORKING
auxString = ""; auxString = "";
String auxString2 = "";
for (Group g : dataHolder.getGroupList()) { for (Group g : dataHolder.getGroupList()) {
auxString += g.getName() + ", "; auxString += g.getName() + ", ";
} }
for (Group g : getGlobalGroups().getGroupList()) { for (Group g : getGlobalGroups().getGroupList()) {
auxString += g.getName() + ", "; auxString2 += g.getName() + ", ";
} }
if (auxString.lastIndexOf(",") > 0) { if (auxString.lastIndexOf(",") > 0) {
auxString = auxString.substring(0, auxString.lastIndexOf(",")); auxString = auxString.substring(0, auxString.lastIndexOf(","));
} }
sender.sendMessage(ChatColor.YELLOW + " Groups Available: " + ChatColor.WHITE + auxString); if (auxString2.lastIndexOf(",") > 0) {
auxString2 = auxString.substring(0, auxString.lastIndexOf(","));
}
sender.sendMessage(ChatColor.YELLOW + "Groups Available: " + ChatColor.WHITE + auxString);
sender.sendMessage(ChatColor.YELLOW + "GlobalGroups Available: " + ChatColor.WHITE + auxString2);
return true; return true;
@ -1846,7 +1929,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[1]); auxGroup = dataHolder.getGroup(args[1]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1866,11 +1949,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit.");
return true; return true;
} }
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { if (!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."); sender.sendMessage(ChatColor.RED + "You can't modify a player using groups with different heritage line.");
return true; return true;
} }
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { if (!permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName())) {
sender.sendMessage(ChatColor.RED + "The new group must be a higher rank."); sender.sendMessage(ChatColor.RED + "The new group must be a higher rank.");
return true; return true;
} }
@ -1902,7 +1985,7 @@ public class GroupManager extends JavaPlugin {
} }
auxGroup = dataHolder.getGroup(args[1]); auxGroup = dataHolder.getGroup(args[1]);
if (auxGroup == null) { if (auxGroup == null) {
sender.sendMessage(ChatColor.RED + "" + args[0] + " Group doesnt exist!"); sender.sendMessage(ChatColor.RED + "'" + args[0] + "' Group doesnt exist!");
return true; return true;
} }
if (auxGroup.isGlobal()) { if (auxGroup.isGlobal()) {
@ -1922,11 +2005,11 @@ public class GroupManager extends JavaPlugin {
sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit."); sender.sendMessage(ChatColor.RED + "You can't modify a player involving a group that you don't inherit.");
return true; return true;
} }
if (!isConsole && !isOpOverride && (!permissionHandler.hasGroupInInheritance(auxUser.getGroup(), auxGroup.getName()) && !permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { if (!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."); sender.sendMessage(ChatColor.RED + "You can't modify a player using groups with different inheritage line.");
return true; return true;
} }
if (!isConsole && !isOpOverride && (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName()))) { if (permissionHandler.hasGroupInInheritance(auxGroup, auxUser.getGroupName())) {
sender.sendMessage(ChatColor.RED + "The new group must be a lower rank."); sender.sendMessage(ChatColor.RED + "The new group must be a lower rank.");
return true; return true;
} }

View file

@ -19,10 +19,12 @@ public enum GroupManagerPermissions {
mangdel, mangdel,
manuaddp, manuaddp,
manudelp, manudelp,
manuclearp,
manulistp, manulistp,
manucheckp, manucheckp,
mangaddp, mangaddp,
mangdelp, mangdelp,
mangclearp,
manglistp, manglistp,
mangcheckp, mangcheckp,
mangaddi, mangaddi,

View file

@ -33,13 +33,17 @@ commands:
usage: /<command> <group> usage: /<command> <group>
permissions: groupmanager.mangdel permissions: groupmanager.mangdel
manuaddp: manuaddp:
description: Add permissions diretly to the player. description: Add permissions directly to the player.
usage: /<command> <player> <permissions> usage: /<command> <player> <permissions>
permissions: groupmanager.manuaddp permissions: groupmanager.manuaddp
manudelp: manudelp:
description: Removes permissions diretly from the player. description: Removes permissions directly from the player.
usage: /<command> <player> <permissions> usage: /<command> <player> <permissions>
permissions: groupmanager.manudelp permissions: groupmanager.manudelp
manuclearp:
description: Removes all permissions of a player.
usage: /<command> <player>
permissions: groupmanager.manuclearp
manulistp: manulistp:
description: List all permissionss from a player. description: List all permissionss from a player.
usage: /<command> <player> usage: /<command> <player>
@ -56,6 +60,10 @@ commands:
description: Removes permissions from a group. description: Removes permissions from a group.
usage: /<command> <group> <permissions> usage: /<command> <group> <permissions>
permissions: groupmanager.mangdelp permissions: groupmanager.mangdelp
mangclearp:
description: Removes all permissions of a group.
usage: /<command> <group> <permissions>
permissions: groupmanager.mangdelp
manglistp: manglistp:
description: Lists all permissionss from a group. description: Lists all permissionss from a group.
usage: /<command> <group> usage: /<command> <group>
@ -133,6 +141,7 @@ commands:
usage: /<command> [world] usage: /<command> [world]
permissions: groupmanager.manload permissions: groupmanager.manload
listgroups: listgroups:
aliases: [manlistg]
description: List the groups available. description: List the groups available.
usage: /<command> usage: /<command>
permissions: groupmanager.listgroups permissions: groupmanager.listgroups