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
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

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);