diff options
author | snowleo <schneeleo@gmail.com> | 2011-08-28 14:24:31 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-08-28 14:24:31 +0200 |
commit | a60f040f7e201921c9aaf98d1eb47761d5ac2a09 (patch) | |
tree | f71c39db8929f5c9c670b4c836d5dd015276824d | |
parent | 22c277f9ab38f599ea0bee7798be32b86510943f (diff) | |
download | Essentials-a60f040f7e201921c9aaf98d1eb47761d5ac2a09.tar Essentials-a60f040f7e201921c9aaf98d1eb47761d5ac2a09.tar.gz Essentials-a60f040f7e201921c9aaf98d1eb47761d5ac2a09.tar.lz Essentials-a60f040f7e201921c9aaf98d1eb47761d5ac2a09.tar.xz Essentials-a60f040f7e201921c9aaf98d1eb47761d5ac2a09.zip |
Cleanup
7 files changed, 64 insertions, 101 deletions
diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java index bc9fc2113..82f793ee0 100644 --- a/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissionsHandler.java @@ -7,7 +7,7 @@ import java.util.List; import org.bukkit.entity.Player; -public class BPermissionsHandler implements IPermissionsHandler +public class BPermissionsHandler extends SuperpermsHandler { private final transient WorldPermissionsManager wpm; @@ -33,13 +33,7 @@ public class BPermissionsHandler implements IPermissionsHandler } @Override - public boolean canBuild(Player base, String group) - { - return true; - } - - @Override - public boolean inGroup(Player base, String group) + public boolean inGroup(final Player base, final String group) { final PermissionSet pset = wpm.getPermissionSet(base.getWorld()); if (pset == null) @@ -53,36 +47,4 @@ public class BPermissionsHandler implements IPermissionsHandler } return groups.contains(group); } - - @Override - public boolean hasPermission(Player base, String node) - { - if (base.hasPermission("-" + node)) - { - return false; - } - final String[] parts = node.split("\\."); - final StringBuilder sb = new StringBuilder(); - for (String part : parts) - { - if (base.hasPermission(sb.toString() + "*")) - { - return true; - } - sb.append(part).append("."); - } - return base.hasPermission(node); - } - - @Override - public String getPrefix(Player base) - { - return ""; - } - - @Override - public String getSuffix(Player base) - { - return ""; - } } diff --git a/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java index 1d5ac447d..82d285b1f 100644 --- a/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/ConfigPermissionsHandler.java @@ -13,33 +13,39 @@ public class ConfigPermissionsHandler implements IPermissionsHandler this.ess = ess; } + @Override public String getGroup(final Player base) { return "default"; } + @Override public boolean canBuild(final Player base, final String group) { return true; } + @Override public boolean inGroup(final Player base, final String group) { return false; } + @Override public boolean hasPermission(final Player base, final String node) { final String[] cmds = node.split("\\.", 2); - return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]) - && ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]); + return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]) + && ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]); } + @Override public String getPrefix(final Player base) { return ""; } + @Override public String getSuffix(final Player base) { return ""; diff --git a/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java index d22eb1c3a..0d7b45cb7 100644 --- a/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java @@ -15,33 +15,39 @@ public class Permissions2Handler implements IPermissionsHandler permissionHandler = ((Permissions)permissionsPlugin).getHandler(); } + @Override public String getGroup(final Player base) { final String group = permissionHandler.getGroup(base.getWorld().getName(), base.getName()); return group == null ? "default" : group; } + @Override public boolean canBuild(final Player base, final String group) { return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base)); } + @Override public boolean inGroup(final Player base, final String group) { return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group); } + @Override public boolean hasPermission(final Player base, final String node) { return permissionHandler.permission(base, node); } + @Override public String getPrefix(final Player base) { final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base)); return prefix == null ? "" : prefix; } + @Override public String getSuffix(final Player base) { final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base)); diff --git a/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java index 84318689e..c0ac249a8 100644 --- a/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java @@ -15,31 +15,37 @@ public class Permissions3Handler implements IPermissionsHandler permissionHandler = ((Permissions)permissionsPlugin).getHandler(); } + @Override public String getGroup(final Player base) { return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName()); } + @Override public boolean canBuild(final Player base, final String group) { return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName()); } + @Override public boolean inGroup(final Player base, final String group) { return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group); } + @Override public boolean hasPermission(final Player base, final String node) { return permissionHandler.has(base, node); } + @Override public String getPrefix(final Player base) { return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName()); } + @Override public String getSuffix(final Player base) { return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName()); diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java index fdf998ced..9fd87905e 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsBukkitHandler.java @@ -8,79 +8,51 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -public class PermissionsBukkitHandler implements IPermissionsHandler +public class PermissionsBukkitHandler extends SuperpermsHandler { private final transient PermissionsPlugin plugin; - public PermissionsBukkitHandler(Plugin plugin) + public PermissionsBukkitHandler(final Plugin plugin) { this.plugin = (PermissionsPlugin)plugin; } - - - public String getGroup(Player base) + + @Override + public String getGroup(final Player base) { final PermissionInfo info = plugin.getPlayerInfo(base.getName()); - if (info == null) { + if (info == null) + { return "default"; } final List<Group> groups = info.getGroups(); - if (groups == null || groups.isEmpty()) { + if (groups == null || groups.isEmpty()) + { return "default"; } return groups.get(0).getName(); } - public boolean canBuild(Player base, String group) - { - return true; - } - - public boolean inGroup(Player base, String group) + @Override + public boolean inGroup(final Player base, final String group) { final PermissionInfo info = plugin.getPlayerInfo(base.getName()); - if (info == null) { + if (info == null) + { return false; } final List<Group> groups = info.getGroups(); - if (groups == null || groups.isEmpty()) { - return false; - } - for (Group group1 : groups) - { - if(group1.getName().equalsIgnoreCase(group)) { - return true; - } - } - return false; - } - - public boolean hasPermission(Player base, String node) - { - if (base.hasPermission("-" + node)) + if (groups == null || groups.isEmpty()) { return false; } - final String[] parts = node.split("\\."); - final StringBuilder sb = new StringBuilder(); - for (String part : parts) + for (Group group1 : groups) { - if (base.hasPermission(sb.toString() + "*")) + if (group1.getName().equalsIgnoreCase(group)) { return true; } - sb.append(part).append("."); } - return base.hasPermission(node); - } - - public String getPrefix(Player base) - { - return ""; - } - - public String getSuffix(Player base) - { - return ""; + return false; } } diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java index ed3c2afe6..28b056c0a 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsExHandler.java @@ -15,7 +15,8 @@ public class PermissionsExHandler implements IPermissionsHandler manager = PermissionsEx.getPermissionManager(); } - public String getGroup(Player base) + @Override + public String getGroup(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -25,7 +26,8 @@ public class PermissionsExHandler implements IPermissionsHandler return user.getGroupsNames()[0]; } - public boolean canBuild(Player base, String group) + @Override + public boolean canBuild(final Player base, final String group) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -36,7 +38,8 @@ public class PermissionsExHandler implements IPermissionsHandler return user.getOptionBoolean("build", base.getWorld().getName(), true); } - public boolean inGroup(Player base, String group) + @Override + public boolean inGroup(final Player base, final String group) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -47,12 +50,14 @@ public class PermissionsExHandler implements IPermissionsHandler return user.inGroup(group); } - public boolean hasPermission(Player base, String node) + @Override + public boolean hasPermission(final Player base, final String node) { return manager.has(base.getName(), node, base.getWorld().getName()); } - public String getPrefix(Player base) + @Override + public String getPrefix(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) @@ -62,7 +67,8 @@ public class PermissionsExHandler implements IPermissionsHandler return user.getPrefix(); } - public String getSuffix(Player base) + @Override + public String getSuffix(final Player base) { final PermissionUser user = manager.getUser(base.getName()); if (user == null) diff --git a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java index e31776fe1..60b1c5a3d 100644 --- a/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/SuperpermsHandler.java @@ -5,22 +5,26 @@ import org.bukkit.entity.Player; public class SuperpermsHandler implements IPermissionsHandler { - public String getGroup(Player base) + @Override + public String getGroup(final Player base) { return "default"; } - public boolean canBuild(Player base, String group) + @Override + public boolean canBuild(final Player base, final String group) { - return true; + return hasPermission(base, "essentials.build"); } - public boolean inGroup(Player base, String group) + @Override + public boolean inGroup(final Player base, final String group) { return false; } - public boolean hasPermission(Player base, String node) + @Override + public boolean hasPermission(final Player base, final String node) { if (base.hasPermission("-" + node)) { @@ -39,14 +43,15 @@ public class SuperpermsHandler implements IPermissionsHandler return base.hasPermission(node); } - public String getPrefix(Player base) + @Override + public String getPrefix(final Player base) { return ""; } - public String getSuffix(Player base) + @Override + public String getSuffix(final Player base) { return ""; } } - |