mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-02 17:09:58 +01:00
Cleanup
This commit is contained in:
parent
22c277f9ab
commit
a60f040f7e
@ -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 "";
|
||||
}
|
||||
}
|
||||
|
@ -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 "";
|
||||
|
@ -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));
|
||||
|
@ -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());
|
||||
|
@ -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()) {
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (Group group1 : groups)
|
||||
{
|
||||
if(group1.getName().equalsIgnoreCase(group)) {
|
||||
if (group1.getName().equalsIgnoreCase(group))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public String getPrefix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getSuffix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user