1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-08-20 21:31:36 +02:00

Fabric fix compat with fake players

https://github.com/lucko/fabric-permissions-api/issues/3
This commit is contained in:
Luck
2021-04-07 20:56:51 +01:00
parent 82488140ee
commit c533446ab0

View File

@@ -110,6 +110,10 @@ public abstract class ServerPlayerEntityMixin implements MixinUser {
if (permission == null) { if (permission == null) {
throw new NullPointerException("permission"); throw new NullPointerException("permission");
} }
if (this.luckperms$user == null || this.luckperms$queryOptions == null) {
// "fake" players will have our mixin, but won't have been initialised.
return Tristate.UNDEFINED;
}
return hasPermission(permission, this.luckperms$queryOptions.getQueryOptions()); return hasPermission(permission, this.luckperms$queryOptions.getQueryOptions());
} }
@@ -123,8 +127,9 @@ public abstract class ServerPlayerEntityMixin implements MixinUser {
} }
final User user = this.luckperms$user; final User user = this.luckperms$user;
if (user == null) { if (user == null || this.luckperms$queryOptions == null) {
throw new IllegalStateException("Permissions have not been initialised for this player yet."); // "fake" players will have our mixin, but won't have been initialised.
return Tristate.UNDEFINED;
} }
PermissionCache data = user.getCachedData().getPermissionData(queryOptions); PermissionCache data = user.getCachedData().getPermissionData(queryOptions);