Slightly change how flag permissions are handled (#3201)

This commit is contained in:
dordsor21
2021-08-14 14:13:01 +01:00
committed by GitHub
parent b841a7c03b
commit da4ae9f4f5
15 changed files with 223 additions and 16 deletions

View File

@ -92,6 +92,16 @@ public class BukkitPermissionHandler implements PermissionHandler {
return player != null && player.hasPermission(permission);
}
@Override
public boolean hasKeyedPermission(
final @Nullable String world,
final @NonNull String stub,
final @NonNull String key
) {
final Player player = this.playerReference.get();
return player != null && (player.hasPermission(stub + "." + key) || player.hasPermission(stub + ".*"));
}
}
}

View File

@ -117,6 +117,26 @@ public class VaultPermissionHandler implements PermissionHandler {
return permissions.playerHas(world, offlinePlayer, permission);
}
@Override
public boolean hasKeyedPermission(
final @Nullable String world,
final @NonNull String stub,
final @NonNull String key
) {
if (permissions == null) {
return false;
}
if (world == null && offlinePlayer instanceof BukkitPlayer) {
return permissions.playerHas(
((BukkitPlayer) offlinePlayer).getPlatformPlayer(),
stub + ".*"
) || permissions.playerHas(((BukkitPlayer) offlinePlayer).getPlatformPlayer(), stub + "." + key);
}
return permissions.playerHas(world, offlinePlayer, stub + ".*") || permissions.playerHas(world, offlinePlayer,
stub + "." + key
);
}
}
}

View File

@ -82,4 +82,14 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
return this.permissionProfile.hasPermission(world, permission);
}
@Override
public boolean hasKeyedPermission(
final @Nullable String world,
final @NonNull String stub,
final @NonNull String key
) {
return this.permissionProfile.hasPermission(world, stub + "." + key) || this.permissionProfile.hasPermission(world,
stub + ".*");
}
}