geforkt von Mirrors/FastAsyncWorldEdit
Update PEX WEPIF resolver to use superperms where possible
Dieser Commit ist enthalten in:
Ursprung
89e9829f28
Commit
43b8c2cd9b
@ -32,8 +32,8 @@ import java.util.List;
|
||||
|
||||
public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
private static final String GROUP_PREFIX = "group.";
|
||||
private final Server server;
|
||||
public static final String GROUP_PREFIX = "group.";
|
||||
protected final Server server;
|
||||
|
||||
public DinnerPermsResolver(Server server) {
|
||||
this.server = server;
|
||||
@ -130,7 +130,8 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
|
||||
/**
|
||||
* Checks the permission from dinnerperms
|
||||
* @param perms Permissible to check for
|
||||
*
|
||||
* @param perms Permissible to check for
|
||||
* @param permission The permission to check
|
||||
* @return -1 if the permission is explicitly denied, 1 if the permission is allowed,
|
||||
* 0 if the permission is denied by a default.
|
||||
|
@ -23,13 +23,12 @@ import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
|
||||
public class PermissionsExResolver implements PermissionsResolver {
|
||||
public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
private final PermissionManager manager;
|
||||
private final Server server;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
try {
|
||||
@ -46,42 +45,21 @@ public class PermissionsExResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public PermissionsExResolver(Server server, PermissionManager manager) {
|
||||
this.server = server;
|
||||
super(server);
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
}
|
||||
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
Player player = server.getPlayerExact(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();
|
||||
}
|
||||
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
return manager.has(player.getName(), permission, onlinePlayer == null ? null : onlinePlayer.getWorld().getName());
|
||||
Permissible permissible = getPermissible(player);
|
||||
if (permissible == null) {
|
||||
return manager.has(player.getName(), permission, null);
|
||||
} else {
|
||||
return permissible.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
@ -89,11 +67,23 @@ public class PermissionsExResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
return inGroup(player.getName(), group);
|
||||
if (getPermissible(player) == null) {
|
||||
return manager.getUser(player.getName()).inGroup(group);
|
||||
} else {
|
||||
return hasPermission(player, GROUP_PREFIX + group);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
return getGroups(player.getName());
|
||||
if (getPermissible(player) == null) {
|
||||
PermissionUser user = manager.getUser(player.getName());
|
||||
if (user == null) {
|
||||
return new String[0];
|
||||
}
|
||||
return user.getGroupsNames();
|
||||
} else {
|
||||
return super.getGroups(player);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDetectionMessage() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren