org.spongepowered.api.service.permission.SubjectData Java Examples
The following examples show how to use
org.spongepowered.api.service.permission.SubjectData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtectionManager.java From FlexibleLogin with MIT License | 6 votes |
public void unprotect(Player player) { //notify BungeeCord plugins for the login channel.sendTo(player, buf -> buf.writeUTF(LOGIN_ACTION)); ProtectionData data = protections.remove(player.getUniqueId()); if (data == null) { return; } //teleport if (config.getGeneral().getTeleport().isEnabled()) { safeTeleport(player, data.getOldLocation()); } //restore permissions SubjectData subjectData = player.getTransientSubjectData(); Map<Set<Context>, Map<String, Boolean>> oldPermissions = data.getPermissions(); for (Entry<Set<Context>, Map<String, Boolean>> permission : oldPermissions.entrySet()) { Set<Context> context = permission.getKey(); for (Entry<String, Boolean> perm : permission.getValue().entrySet()) { subjectData.setPermission(context, perm.getKey(), Tristate.fromBoolean(perm.getValue())); } } }
Example #2
Source File: ProtectionManager.java From FlexibleLogin with MIT License | 6 votes |
public void protect(Player player) { SubjectData subjectData = player.getTransientSubjectData(); Map<Set<Context>, Map<String, Boolean>> permissions = Collections.emptyMap(); if (config.getGeneral().isProtectPermissions()) { permissions = subjectData.getAllPermissions(); subjectData.clearPermissions(); } protections.put(player.getUniqueId(), new ProtectionData(player.getLocation(), permissions)); TeleportConfig teleportConfig = config.getGeneral().getTeleport(); if (teleportConfig.isEnabled()) { teleportConfig.getSpawnLocation().ifPresent(worldLocation -> safeTeleport(player, worldLocation)); } else { Location<World> oldLoc = player.getLocation(); //sometimes players stuck in a wall safeTeleport(player, oldLoc); } }
Example #3
Source File: LoanListener.java From EconomyLite with MIT License | 6 votes |
@Listener public void onLoanChange(LoanBalanceChangeEvent event) { UUID uuid = event.getUser(); for (Player player : Sponge.getServer().getOnlinePlayers()) { if (player.getUniqueId().equals(uuid)) { if (event.getNewBalance() == 0) { // Remove the debtor permissions module.getPermissions().forEach((perm, val) -> { player.getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, perm, Tristate.fromBoolean(!val)); }); } else { // Add the debtor permissions module.getPermissions().forEach((perm, val) -> { player.getSubjectData().setPermission(SubjectData.GLOBAL_CONTEXT, perm, Tristate.fromBoolean(val)); }); } } } }
Example #4
Source File: DataStore.java From GriefPrevention with MIT License | 6 votes |
private void setOptionDefaultPermissions() { GriefPreventionPlugin.instance.executor.execute(() -> { final Set<Context> contexts = new HashSet<>(); SubjectData globalSubjectData = GriefPreventionPlugin.GLOBAL_SUBJECT.getTransientSubjectData(); for (Map.Entry<String, Double> optionEntry : GPOptions.DEFAULT_OPTIONS.entrySet()) { globalSubjectData.setOption(contexts, optionEntry.getKey(), Double.toString(optionEntry.getValue())); } // Check for default option overrides globalSubjectData = GriefPreventionPlugin.GLOBAL_SUBJECT.getSubjectData(); for (String option : GPOptions.DEFAULT_OPTIONS.keySet()) { final String optionValue = globalSubjectData.getOptions(contexts).get(option); if (optionValue != null) { Double doubleValue = null; try { doubleValue = Double.parseDouble(optionValue); } catch (NumberFormatException e) { continue; } GPOptions.DEFAULT_OPTIONS.put(option, doubleValue); } } }); }
Example #5
Source File: VirtualChestPermissionManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 5 votes |
public CompletableFuture<?> clearIgnored(Player player, UUID actionUUID) { SubjectData data = player.getTransientSubjectData(); Set<Context> contexts = Collections.singleton(new Context(CONTEXT_KEY, actionUUID.toString())); return this.clear(data, contexts) .thenRun(() -> this.logIgnoredPermissionsCleared(actionUUID, player.getName())); }
Example #6
Source File: VirtualChestPermissionManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 5 votes |
public CompletableFuture<?> setIgnored(Player player, UUID actionUUID, Collection<String> permissions) { SubjectData data = player.getTransientSubjectData(); Set<Context> contexts = Collections.singleton(new Context(CONTEXT_KEY, actionUUID.toString())); return this.clear(data, contexts) .thenCompose(succeed -> CompletableFuture.allOf(this.set(data, contexts, permissions))) .thenRun(() -> this.logIgnoredPermissionsAdded(permissions, actionUUID, player.getName())); }
Example #7
Source File: VirtualChestPermissionManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void accumulateContexts(Subject subject, Set<Context> accumulator) { this.plugin.getVirtualChestActions().getActivatedActions(subject.getIdentifier()).forEach(actionUUID -> { SubjectData data = subject.getTransientSubjectData(); Context context = new Context(CONTEXT_KEY, actionUUID.toString()); Map<String, Boolean> permissions = data.getPermissions(Collections.singleton(context)); this.logger.debug("Ignored {} permission(s) for action {} (context):", permissions.size(), actionUUID); permissions.forEach((permission, state) -> this.logger.debug("- {} ({})", permission, state)); accumulator.add(context); }); }
Example #8
Source File: LPSubjectDataUpdateEvent.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData getUpdatedData() { return this.subjectData.sponge(); }
Example #9
Source File: VirtualChestPermissionManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 4 votes |
private CompletableFuture<Boolean> clear(SubjectData data, Set<Context> contexts) { return SpongeUnimplemented.clearPermissions(this.plugin, data, contexts); }
Example #10
Source File: VirtualChestPermissionManager.java From VirtualChest with GNU Lesser General Public License v3.0 | 4 votes |
private CompletableFuture<Boolean> set(SubjectData data, Set<Context> contexts, String permission) { return SpongeUnimplemented.setPermission(this.plugin, data, contexts, permission); }
Example #11
Source File: CommandSource.java From Web-API with MIT License | 4 votes |
@Override public SubjectData getTransientSubjectData() { return null; }
Example #12
Source File: CommandSource.java From Web-API with MIT License | 4 votes |
@Override public SubjectData getSubjectData() { return null; }
Example #13
Source File: SubjectProxy.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData getTransientSubjectData() { return new SubjectDataProxy(this.service, this.ref, false); }
Example #14
Source File: SubjectProxy.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData getSubjectData() { return new SubjectDataProxy(this.service, this.ref, true); }
Example #15
Source File: ForwardingSource.java From ChatUI with MIT License | 4 votes |
@Override public SubjectData getSubjectData() { return this.actualSource.getSubjectData(); }
Example #16
Source File: PermissionHolderSubjectData.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData sponge() { return ProxyFactory.toSponge(this); }
Example #17
Source File: CalculatedSubjectData.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData sponge() { return ProxyFactory.toSponge(this); }
Example #18
Source File: ProxyFactory.java From LuckPerms with MIT License | 4 votes |
public static SubjectData toSponge(LPSubjectData luckPerms) { LPSubject parentSubject = luckPerms.getParentSubject(); return IS_API_7 ? new me.lucko.luckperms.sponge.service.proxy.api7.SubjectDataProxy(parentSubject.getService(), parentSubject.toReference(), luckPerms.getType() == DataType.NORMAL) : new me.lucko.luckperms.sponge.service.proxy.api6.SubjectDataProxy(parentSubject.getService(), parentSubject.toReference(), luckPerms.getType() == DataType.NORMAL); }
Example #19
Source File: SubjectProxy.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData getTransientSubjectData() { return new SubjectDataProxy(this.service, this.ref, false); }
Example #20
Source File: SubjectProxy.java From LuckPerms with MIT License | 4 votes |
@Override public SubjectData getSubjectData() { return new SubjectDataProxy(this.service, this.ref, true); }
Example #21
Source File: ForwardingSource.java From ChatUI with MIT License | 4 votes |
@Override public SubjectData getTransientSubjectData() { return this.actualSource.getTransientSubjectData(); }
Example #22
Source File: LPSubjectData.java From LuckPerms with MIT License | votes |
SubjectData sponge();