Search in sources :

Example 1 with SpongePermissionService

use of org.spongepowered.common.service.server.permission.SpongePermissionService in project SpongeCommon by SpongePowered.

the class DedicatedPlayerListMixin method impl$checkForPlayerLimitBypassPermission.

@Inject(method = "canBypassPlayerLimit", at = @At("HEAD"), cancellable = true)
private void impl$checkForPlayerLimitBypassPermission(final GameProfile profile, final CallbackInfoReturnable<Boolean> ci) {
    final PermissionService permissionService = Sponge.server().serviceProvider().permissionService();
    Subject subject = permissionService.userSubjects().subject(profile.getId().toString()).orElse(null);
    if (subject == null) {
        subject = permissionService.userSubjects().defaults();
    }
    final Tristate tristate = subject.permissionValue(LoginPermissions.BYPASS_PLAYER_LIMIT_PERMISSION);
    // if we are still using the default permission service
    if (tristate == Tristate.UNDEFINED && permissionService instanceof SpongePermissionService) {
        return;
    }
    ci.setReturnValue(tristate.asBoolean());
}
Also used : SpongePermissionService(org.spongepowered.common.service.server.permission.SpongePermissionService) PermissionService(org.spongepowered.api.service.permission.PermissionService) Tristate(org.spongepowered.api.util.Tristate) SpongePermissionService(org.spongepowered.common.service.server.permission.SpongePermissionService) Subject(org.spongepowered.api.service.permission.Subject) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PermissionService (org.spongepowered.api.service.permission.PermissionService)1 Subject (org.spongepowered.api.service.permission.Subject)1 Tristate (org.spongepowered.api.util.Tristate)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1 SpongePermissionService (org.spongepowered.common.service.server.permission.SpongePermissionService)1