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:
Ursprung
da6e6da024
Commit
84ed4bf4c3
2
pom.xml
2
pom.xml
@ -34,7 +34,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>dummypermscompat</artifactId>
|
<artifactId>dummypermscompat</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Bukkit -->
|
<!-- Bukkit -->
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
import com.sk89q.bukkit.migration.PermissionsResolverManager.MissingPluginException;
|
||||||
|
|
||||||
public class NijiPermissionsResolver implements PermissionsResolver {
|
public class NijiPermissionsResolver implements PermissionsResolver {
|
||||||
private Server server;
|
private Server server;
|
||||||
@ -126,10 +127,6 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
public static class PluginAccessException extends Exception {
|
public static class PluginAccessException extends Exception {
|
||||||
private static final long serialVersionUID = 7044832912491608706L;
|
private static final long serialVersionUID = 7044832912491608706L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MissingPluginException extends Exception {
|
|
||||||
private static final long serialVersionUID = 7044832912491608706L;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
|
public static boolean checkRealNijiPerms(boolean ignoreBridges) {
|
||||||
if (!ignoreBridges)
|
if (!ignoreBridges)
|
||||||
|
51
src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java
Normale Datei
51
src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java
Normale Datei
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -68,6 +68,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
public void findResolver() {
|
public void findResolver() {
|
||||||
if (tryPluginPermissionsResolver()) return;
|
if (tryPluginPermissionsResolver()) return;
|
||||||
if (tryNijiPermissions()) return;
|
if (tryNijiPermissions()) return;
|
||||||
|
if (tryPermissionsEx()) return;
|
||||||
if (tryDinnerPerms()) return;
|
if (tryDinnerPerms()) return;
|
||||||
if (tryFlatFilePermissions()) 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() {
|
private boolean tryFlatFilePermissions() {
|
||||||
if (FlatFilePermissionsResolver.filesExists()) {
|
if (FlatFilePermissionsResolver.filesExists()) {
|
||||||
perms = new FlatFilePermissionsResolver();
|
perms = new FlatFilePermissionsResolver();
|
||||||
@ -184,5 +195,9 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
return isUpdated;
|
return isUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class MissingPluginException extends Exception {
|
||||||
|
private static final long serialVersionUID = 7044832912491608706L;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,9 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
String name = plugin.getDescription().getName();
|
String name = plugin.getDescription().getName();
|
||||||
if (plugin instanceof PermissionsProvider) {
|
if (plugin instanceof PermissionsProvider) {
|
||||||
manager.setPluginPermissionsResolver(plugin);
|
manager.setPluginPermissionsResolver(plugin);
|
||||||
} else if (name.equalsIgnoreCase("Permissions") &&
|
} else if ((name.equalsIgnoreCase("Permissions") &&
|
||||||
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) {
|
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) ||
|
||||||
|
name.equalsIgnoreCase("PermissionsEx")) {
|
||||||
manager.findResolver();
|
manager.findResolver();
|
||||||
manager.load();
|
manager.load();
|
||||||
}
|
}
|
||||||
@ -63,7 +64,8 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
|
|
||||||
if (plugin instanceof PermissionsProvider
|
if (plugin instanceof PermissionsProvider
|
||||||
|| (name.equalsIgnoreCase("Permissions") &&
|
|| (name.equalsIgnoreCase("Permissions") &&
|
||||||
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges))) {
|
NijiPermissionsResolver.checkRealNijiPerms(manager.ignoreNijiPermsBridges)) ||
|
||||||
|
name.equalsIgnoreCase("PermissionsEx")) {
|
||||||
manager.findResolver();
|
manager.findResolver();
|
||||||
manager.load();
|
manager.load();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren