Remove all .* setgroup and setperm node

This commit is contained in:
Michel Roux 2012-05-09 19:55:59 +02:00
parent 645d93b800
commit be092bd7f1
2 changed files with 0 additions and 64 deletions

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import net.crystalyx.bukkit.simplyperms.imports.ImportDB;
@ -233,7 +232,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("setperm")) {
if (!checkPerm(sender, "group.setperm")) return true;
if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm");
if (!checkPerm(sender, "group.setperm", Arrays.asList(split[3].split(",")))) return true;
String group = split[2];
String perm = split[3];
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
@ -261,7 +259,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("unsetperm")) {
if (!checkPerm(sender, "group.unsetperm")) return true;
if (split.length != 4) return usage(sender, command, "group unsetperm");
if (!checkPerm(sender, "group.unsetperm", Arrays.asList(split[3].split(",")))) return true;
String group = split[2].toLowerCase();
String perm = split[3];
@ -320,7 +317,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("setgroup")) {
if (!checkPerm(sender, "player.setgroup")) return true;
if (split.length != 4) return usage(sender, command, "player setgroup");
if (!checkPerm(sender, "player.setgroup", Arrays.asList(split[3].split(",")))) return true;
String player = split[2].toLowerCase();
String[] groups = split[3].split(",");
@ -336,7 +332,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("addgroup")) {
if (!checkPerm(sender, "player.addgroup")) return true;
if (split.length != 4) return usage(sender, command, "player addgroup");
if (!checkPerm(sender, "player.addgroup", Arrays.asList(split[3]))) return true;
String player = split[2].toLowerCase();
String group = split[3];
@ -353,7 +348,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("removegroup")) {
if (!checkPerm(sender, "player.removegroup")) return true;
if (split.length != 4) return usage(sender, command, "player removegroup");
if (!checkPerm(sender, "player.removegroup", Arrays.asList(split[3]))) return true;
String player = split[2].toLowerCase();
String group = split[3];
@ -385,7 +379,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("setperm")) {
if (!checkPerm(sender, "player.setperm")) return true;
if (split.length != 4 && split.length != 5) return usage(sender, command, "player setperm");
if (!checkPerm(sender, "player.setperm", Arrays.asList(split[3].split(",")))) return true;
String player = split[2].toLowerCase();
String perm = split[3];
boolean value = (split.length != 5) || Boolean.parseBoolean(split[4]);
@ -404,7 +397,6 @@ public class SimplyCommands implements CommandExecutor {
} else if (subcommand.equals("unsetperm")) {
if (!checkPerm(sender, "player.unsetperm")) return true;
if (split.length != 4) return usage(sender, command, "player unsetperm");
if (!checkPerm(sender, "player.unsetperm", Arrays.asList(split[3].split(",")))) return true;
String player = split[2].toLowerCase();
String perm = split[3];
@ -439,41 +431,6 @@ public class SimplyCommands implements CommandExecutor {
return ok;
}
private boolean checkPerm(CommandSender sender, String node, List<String> subnodes) {
boolean ok = sender.hasPermission("permissions." + node + ".*");
for (String subnode : subnodes) {
String testnode = "";
for (String sub : subnode.split(".")) {
testnode += sub;
if (sender.isPermissionSet("permissions." + node + "." + testnode)) {
if (ok && !sender.hasPermission("permissions." + node + "." + testnode)) {
ok = false;
break;
}
else if (!ok && sender.hasPermission("permissions." + node + "." + testnode)) {
ok = true;
break;
}
}
else if (sender.isPermissionSet("permissions." + node + "." + testnode + ".*")) {
if (ok && !sender.hasPermission("permissions." + node + "." + testnode + ".*")) {
ok = false;
break;
}
else if (!ok && sender.hasPermission("permissions." + node + "." + testnode + ".*")) {
ok = true;
break;
}
}
}
if (!ok) break;
}
if (!ok) {
sender.sendMessage(ChatColor.RED + "You do not have permissions to do that.");
}
return ok;
}
private boolean usage(CommandSender sender, Command command) {
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + ChatColor.RED + "====]");
for (String line : command.getUsage().split("\\n")) {

View File

@ -60,9 +60,7 @@ permissions:
permissions.group.list: true
permissions.group.players: true
permissions.group.setperm: true
permissions.group.setperm.*: true
permissions.group.unsetperm: true
permissions.group.unsetperm.*: true
permissions.group.help:
description: Allows viewing of usage for /permissions group.
permissions.group.list:
@ -71,54 +69,35 @@ permissions:
description: Allows use of /permissions group players.
permissions.group.setperm:
description: Allows use of /permissions group setperm.
permissions.group.setperm.*:
description: Allows set all permissions node for this group.
permissions.group.unsetperm:
description: Allows use of /permissions group unsetperm.
permissions.group.unsetperm.*:
description: Allows unset all permissions node for this group.
permissions.player.*:
description: Allows use of all /permissions player commands.
children:
permissions.player.help: true
permissions.player.groups: true
permissions.player.setgroup: true
permissions.player.setgroup.*: true
permissions.player.addgroup: true
permissions.player.addgroup.*: true
permissions.player.removegroup: true
permissions.player.removegroup.*: true
permissions.player.remove: true
permissions.player.setperm: true
permissions.player.setperm.*: true
permissions.player.unsetperm: true
permissions.player.unsetperm.*: true
permissions.player.help:
description: Allows viewing of usage for /permissions player.
permissions.player.groups:
description: Allows use of /permissions player groups.
permissions.player.setgroup:
description: Allows use of /permissions player setgroup.
permissions.player.setgroup.*:
description: Allows set all groups for this player.
permissions.player.addgroup:
description: Allows use of /permissions player addgroup.
permissions.player.addgroup.*:
description: Allows add all groups for this player.
permissions.player.removegroup:
description: Allows use of /permissions player removegroup.
permissions.player.removegroup.*:
description: Allows remove all groups for this player.
permissions.player.remove:
description: Allows use of /permissions player remove.
permissions.player.setperm:
description: Allows use of /permissions player setperm.
permissions.player.setperm.*:
description: Allows set all permissions node for this player.
permissions.player.unsetperm:
description: Allows use of /permissions player unsetperm.
permissions.player.unsetperm.*:
description: Allows unset all permissions node for this player.
permissions.allow.*:
description: Allows player to do everything.
children: