Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Merge pull request #302 from DarkArc/hotfix/groupmanager
Made GroupManager a DinnerPerms based resolver
Dieser Commit ist enthalten in:
Commit
a5647921ca
@ -25,11 +25,10 @@ import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.permissions.Permissible;
|
||||||
|
|
||||||
public class GroupManagerResolver implements PermissionsResolver {
|
public class GroupManagerResolver extends DinnerPermsResolver {
|
||||||
private final WorldsHolder worldsHolder;
|
private final WorldsHolder worldsHolder;
|
||||||
private final Server server;
|
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||||
try {
|
try {
|
||||||
@ -46,7 +45,7 @@ public class GroupManagerResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GroupManagerResolver(Server server, WorldsHolder worldsHolder) {
|
public GroupManagerResolver(Server server, WorldsHolder worldsHolder) {
|
||||||
this.server = server;
|
super(server);
|
||||||
this.worldsHolder = worldsHolder;
|
this.worldsHolder = worldsHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,57 +54,24 @@ public class GroupManagerResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnjoPermissionsHandler getPermissionHandler(String name, String worldName) {
|
/*
|
||||||
if (name == null || name.isEmpty()) {
|
* True if the string is null or empty
|
||||||
return null;
|
*/
|
||||||
}
|
private boolean nameNotSafe(String perm) {
|
||||||
if (worldName == null || worldName.isEmpty()) {
|
return perm == null || perm.isEmpty();
|
||||||
Player player = server.getPlayerExact(name);
|
}
|
||||||
if (player == null) {
|
|
||||||
return null;
|
private AnjoPermissionsHandler getPermissionHandler(World world) {
|
||||||
}
|
if (world != null) {
|
||||||
World world = player.getWorld();
|
|
||||||
if (world == null) {
|
|
||||||
return worldsHolder.getDefaultWorld().getPermissionsHandler();
|
|
||||||
}
|
|
||||||
return worldsHolder.getWorldPermissions(world.getName());
|
return worldsHolder.getWorldPermissions(world.getName());
|
||||||
} else {
|
} else {
|
||||||
return worldsHolder.getWorldPermissions(worldName);
|
return worldsHolder.getDefaultWorld().getPermissionsHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(String name, String permission) {
|
|
||||||
return hasPermission(null, name, permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(String worldName, String name, String permission) {
|
|
||||||
if (permission == null || permission.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, worldName);
|
|
||||||
if (permissionHandler == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return permissionHandler.permission(name, permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean inGroup(String name, String group) {
|
|
||||||
if (group == null || group.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, null);
|
|
||||||
if (permissionHandler == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return permissionHandler.inGroup(name, group);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getGroups(String name) {
|
public String[] getGroups(String name) {
|
||||||
AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, null);
|
AnjoPermissionsHandler permissionHandler = getPermissionHandler(null);
|
||||||
if (permissionHandler == null) {
|
if (permissionHandler == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
@ -114,17 +80,43 @@ public class GroupManagerResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||||
return hasPermission(player.getName(), permission);
|
if (nameNotSafe(permission)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissible permissible = getPermissible(player);
|
||||||
|
if (permissible == null) {
|
||||||
|
return getPermissionHandler(player.getPlayer().getWorld()).permission(player.getName(), permission);
|
||||||
|
} else {
|
||||||
|
return permissible.hasPermission(permission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||||
return hasPermission(worldName, player.getName(), permission);
|
if (nameNotSafe(permission)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = player.getName();
|
||||||
|
World world = worldName != null ? server.getWorld(worldName) : player.getPlayer().getWorld();
|
||||||
|
|
||||||
|
AnjoPermissionsHandler permissionHandler = getPermissionHandler(world);
|
||||||
|
return permissionHandler != null && permissionHandler.permission(name, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean inGroup(OfflinePlayer player, String group) {
|
public boolean inGroup(OfflinePlayer player, String group) {
|
||||||
return inGroup(player.getName(), group);
|
if (super.inGroup(player, group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nameNotSafe(group)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnjoPermissionsHandler permissionHandler = getPermissionHandler(null);
|
||||||
|
return permissionHandler != null && permissionHandler.inGroup(player.getName(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren