mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-16 22:03:53 +00:00
Cleanup and a few bugfixes
This commit is contained in:
@ -41,14 +41,17 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false; // Permissions are only registered for online players
|
||||
if ( player.hasPermission("*") || player.hasPermission(permission))
|
||||
}
|
||||
if ( player.hasPermission("*") || player.hasPermission(permission)) {
|
||||
return true;
|
||||
}
|
||||
int dotPos = permission.lastIndexOf(".");
|
||||
while (dotPos > -1) {
|
||||
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*"))
|
||||
if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) {
|
||||
return true;
|
||||
}
|
||||
dotPos = permission.lastIndexOf(".", dotPos - 1);
|
||||
}
|
||||
return false;
|
||||
@ -60,22 +63,25 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
public boolean inGroup(String name, String group) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return player.hasPermission(GROUP_PREFIX + group);
|
||||
}
|
||||
|
||||
public String[] getGroups(String name) {
|
||||
Player player = server.getPlayer(name);
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return new String[0];
|
||||
}
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) {
|
||||
String perm = permAttach.getPermission();
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue()))
|
||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
||||
continue;
|
||||
}
|
||||
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,9 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
if (plugin == null) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
if (!checkRealNijiPerms(ignoreBridges))
|
||||
if (!checkRealNijiPerms(ignoreBridges)) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
|
||||
try {
|
||||
api = (Permissions)plugin;
|
||||
@ -129,11 +130,13 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
|
||||
if (!ignoreBridges)
|
||||
if (!ignoreBridges) {
|
||||
return true;
|
||||
}
|
||||
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
|
||||
if (permsCommand == null)
|
||||
if (permsCommand == null) {
|
||||
return false;
|
||||
}
|
||||
return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,9 @@ public class PermissionsExResolver implements PermissionsResolver {
|
||||
public PermissionsExResolver(Server server) throws MissingPluginException {
|
||||
this.server = server;
|
||||
manager = server.getServicesManager().load(PermissionManager.class);
|
||||
if (manager == null)
|
||||
if (manager == null) {
|
||||
throw new MissingPluginException();
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
@ -76,6 +76,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
loadConfig(new File("wepif.yml"));
|
||||
findResolver();
|
||||
}
|
||||
|
||||
public void findResolver() {
|
||||
if (tryPluginPermissionsResolver()) return;
|
||||
if (tryNijiPermissions()) return;
|
||||
@ -132,8 +133,9 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
private boolean tryDinnerPerms() {
|
||||
if (!permsConfig.getBoolean("dinnerperms", true))
|
||||
if (!permsConfig.getBoolean("dinnerperms", true)) {
|
||||
return false;
|
||||
}
|
||||
perms = new DinnerPermsResolver(server);
|
||||
logger.info(name + ": Using the Bukkit Permissions API.");
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user