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 {
|
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;
|
||||||
@ -115,7 +115,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
return groupNames.toArray(new String[groupNames.size()]);
|
return groupNames.toArray(new String[groupNames.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permissible getPermissible(OfflinePlayer offline) {
|
public Permissible getPermissible(OfflinePlayer offline) {
|
||||||
if (offline == null) return null;
|
if (offline == null) return null;
|
||||||
Permissible perm = null;
|
Permissible perm = null;
|
||||||
@ -130,7 +130,8 @@ 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,
|
||||||
* 0 if the permission is denied by a default.
|
* 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.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() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren