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

Update PEX WEPIF resolver to use superperms where possible

Dieser Commit ist enthalten in:
zml 2013-08-31 23:00:49 -07:00
Ursprung 89e9829f28
Commit 43b8c2cd9b
2 geänderte Dateien mit 28 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -32,8 +32,8 @@ import java.util.List;
public class DinnerPermsResolver implements PermissionsResolver { public class DinnerPermsResolver implements PermissionsResolver {
private static final String GROUP_PREFIX = "group."; public static final String GROUP_PREFIX = "group.";
private final Server server; protected final Server server;
public DinnerPermsResolver(Server server) { public DinnerPermsResolver(Server server) {
this.server = server; this.server = server;
@ -130,6 +130,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
/** /**
* Checks the permission from dinnerperms * Checks the permission from dinnerperms
*
* @param perms Permissible to check for * @param perms Permissible to check for
* @param permission The permission to check * @param permission The permission to check
* @return -1 if the permission is explicitly denied, 1 if the permission is allowed, * @return -1 if the permission is explicitly denied, 1 if the permission is allowed,

Datei anzeigen

@ -23,13 +23,12 @@ import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import ru.tehkode.permissions.PermissionManager; import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.PermissionUser;
public class PermissionsExResolver implements PermissionsResolver { public class PermissionsExResolver extends DinnerPermsResolver {
private final PermissionManager manager; private final PermissionManager manager;
private final Server server;
public static PermissionsResolver factory(Server server, YAMLProcessor config) { public static PermissionsResolver factory(Server server, YAMLProcessor config) {
try { try {
@ -46,42 +45,21 @@ public class PermissionsExResolver implements PermissionsResolver {
} }
public PermissionsExResolver(Server server, PermissionManager manager) { public PermissionsExResolver(Server server, PermissionManager manager) {
this.server = server; super(server);
this.manager = manager; 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) { public boolean hasPermission(String worldName, String name, String permission) {
return manager.has(name, permission, worldName); 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) { public boolean hasPermission(OfflinePlayer player, String permission) {
Player onlinePlayer = player.getPlayer(); Permissible permissible = getPermissible(player);
return manager.has(player.getName(), permission, onlinePlayer == null ? null : onlinePlayer.getWorld().getName()); if (permissible == null) {
return manager.has(player.getName(), permission, null);
} else {
return permissible.hasPermission(permission);
}
} }
public boolean hasPermission(String worldName, OfflinePlayer player, String 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) { 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) { 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() { public String getDetectionMessage() {