use of org.spongepowered.common.service.permission.SpongePermissionService in project SpongeCommon by SpongePowered.
the class MixinDedicatedPlayerList method onBypassPlayerLimit.
@Inject(method = "bypassesPlayerLimit", at = @At("HEAD"), cancellable = true)
private void onBypassPlayerLimit(GameProfile profile, CallbackInfoReturnable<Boolean> ci) {
final PermissionService permissionService = Sponge.getServiceManager().provideUnchecked(PermissionService.class);
final Subject subject = permissionService.getUserSubjects().getSubject(profile.getId().toString()).orElse(permissionService.getDefaults());
final Tristate tristate = subject.getPermissionValue(SubjectData.GLOBAL_CONTEXT, 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());
}
use of org.spongepowered.common.service.permission.SpongePermissionService in project SpongeCommon by SpongePowered.
the class MixinServerCommandManager method registerDefaultPermissions.
private void registerDefaultPermissions(Game game, MinecraftCommandWrapper cmd) {
Optional<PermissionService> perms = game.getServiceManager().provide(PermissionService.class);
if (perms.isPresent()) {
PermissionService service = perms.get();
int opLevel = cmd.getPermissionLevel();
if (opLevel == -1) {
return;
}
if (service instanceof SpongePermissionService) {
((SpongePermissionService) service).getGroupForOpLevel(opLevel).getTransientSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, cmd.getCommandPermission(), Tristate.TRUE);
} else if (opLevel == 0) {
service.getDefaults().getTransientSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, cmd.getCommandPermission(), Tristate.TRUE);
}
}
}
use of org.spongepowered.common.service.permission.SpongePermissionService in project SpongeVanilla by SpongePowered.
the class SpongeVanilla method initialize.
public void initialize() {
this.registry.init();
if (!this.game.getServiceManager().provide(PermissionService.class).isPresent()) {
SpongePermissionService service = new SpongePermissionService(this.game);
this.game.getServiceManager().setProvider(this, PermissionService.class, service);
}
SpongeCraftingRecipeRegistry.getInstance().disableRegistrations();
SpongeImpl.postState(GameState.INITIALIZATION, SpongeEventFactory.createGameInitializationEvent(Sponge.getCauseStackManager().getCurrentCause()));
this.registry.postInit();
SpongeImpl.postState(GameState.POST_INITIALIZATION, SpongeEventFactory.createGamePostInitializationEvent(Sponge.getCauseStackManager().getCurrentCause()));
this.logger.info("Successfully loaded and initialized plugins.");
SpongeImpl.postState(GameState.LOAD_COMPLETE, SpongeEventFactory.createGameLoadCompleteEvent(Sponge.getCauseStackManager().getCurrentCause()));
}
use of org.spongepowered.common.service.permission.SpongePermissionService in project SpongeForge by SpongePowered.
the class SpongeMod method onInitialization.
@Subscribe
public void onInitialization(FMLInitializationEvent event) {
try {
SpongeImpl.getRegistry().init();
if (!this.game.getServiceManager().provide(PermissionService.class).isPresent()) {
final SpongePermissionService service = new SpongePermissionService(this.game);
this.game.getServiceManager().setProvider(this, PermissionService.class, service);
}
} catch (Throwable t) {
this.controller.errorOccurred(this, t);
}
}
Aggregations