3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00

Added PermissionsEx support to WEPIF.

Dieser Commit ist enthalten in:
zml2008 2011-08-24 23:56:29 -07:00
Ursprung da6e6da024
Commit 84ed4bf4c3
5 geänderte Dateien mit 73 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -34,7 +34,7 @@
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>dummypermscompat</artifactId>
<version>1.3</version>
<version>1.4</version>
</dependency>
<!-- Bukkit -->

Datei anzeigen

@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.sk89q.bukkit.migration.PermissionsResolverManager.MissingPluginException;
public class NijiPermissionsResolver implements PermissionsResolver {
private Server server;
@ -127,10 +128,6 @@ public class NijiPermissionsResolver implements PermissionsResolver {
private static final long serialVersionUID = 7044832912491608706L;
}
public static class MissingPluginException extends Exception {
private static final long serialVersionUID = 7044832912491608706L;
}
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
if (!ignoreBridges)
return true;

Datei anzeigen

@ -0,0 +1,51 @@
package com.sk89q.bukkit.migration;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser;
import com.sk89q.bukkit.migration.PermissionsResolverManager.MissingPluginException;
public class PermissionsExResolver implements PermissionsResolver {
private final PermissionManager manager;
private final Server server;
public PermissionsExResolver(Server server) throws MissingPluginException {
this.server = server;
manager = server.getServicesManager().load(PermissionManager.class);
if (manager == null)
throw new MissingPluginException();
}
public void load() {
}
public boolean hasPermission(String name, String permission) {
Player player = server.getPlayer(name);
return manager.has(name, permission, player == null ? null : player.getWorld().getName());
}
public boolean hasPermission(String worldName, String name, String permission) {
return manager.has(name, permission, worldName);
}
public boolean inGroup(String player, String group) {
PermissionUser user = manager.getUser(player);
if (user == null) {
return false;
}
return user.inGroup(group);
}
public String[] getGroups(String player) {
PermissionUser user = manager.getUser(player);
if (user == null) {
return new String[0];
}
return user.getGroupsNames();
}
}

Datei anzeigen

@ -68,6 +68,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
public void findResolver() {
if (tryPluginPermissionsResolver()) return;
if (tryNijiPermissions()) return;
if (tryPermissionsEx()) return;
if (tryDinnerPerms()) return;
if (tryFlatFilePermissions()) return;
@ -85,6 +86,16 @@ public class PermissionsResolverManager implements PermissionsResolver {
}
}
private boolean tryPermissionsEx() {
try {
perms = new PermissionsExResolver(server);
logger.info(name + ": PermissionsEx detected! Using PermissionsEx for permissions.");
return true;
} catch (Throwable e) {
return false;
}
}
private boolean tryFlatFilePermissions() {
if (FlatFilePermissionsResolver.filesExists()) {
perms = new FlatFilePermissionsResolver();
@ -185,4 +196,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
return isUpdated;
}
public static class MissingPluginException extends Exception {
private static final long serialVersionUID = 7044832912491608706L;
}
}

Datei anzeigen

@ -44,8 +44,9 @@ public class PermissionsResolverServerListener extends ServerListener {
String name = plugin.getDescription().getName();
if (plugin instanceof PermissionsProvider) {
manager.setPluginPermissionsResolver(plugin);
} else if (name.equalsIgnoreCase("Permissions") &&
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) {
} else if ((name.equalsIgnoreCase("Permissions") &&
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) ||
name.equalsIgnoreCase("PermissionsEx")) {
manager.findResolver();
manager.load();
}
@ -63,7 +64,8 @@ public class PermissionsResolverServerListener extends ServerListener {
if (plugin instanceof PermissionsProvider
|| (name.equalsIgnoreCase("Permissions") &&
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges))) {
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) ||
name.equalsIgnoreCase("PermissionsEx")) {
manager.findResolver();
manager.load();
}