net.luckperms.api.context.ContextConsumer Java Examples
The following examples show how to use
net.luckperms.api.context.ContextConsumer.
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: ClaimContextCalculator.java From GriefDefender with MIT License | 6 votes |
@Override public void calculate(@NonNull Player player, @NonNull ContextConsumer contextSet) { final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(player.getWorld(), player.getUniqueId()); if (playerData == null) { return; } if (playerData.ignoreActiveContexts) { playerData.ignoreActiveContexts = false; return; } GDClaim sourceClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(playerData, player.getLocation()); if (sourceClaim != null) { if (playerData == null || playerData.canIgnoreClaim(sourceClaim)) { return; } if (sourceClaim.parent != null && sourceClaim.getData().doesInheritParent()) { contextSet.accept(sourceClaim.parent.getContext().getKey(), sourceClaim.parent.getContext().getValue()); } else { contextSet.accept(sourceClaim.getContext().getKey(), sourceClaim.getContext().getValue()); } contextSet.accept("server", GriefDefenderPlugin.getInstance().getPermissionProvider().getServerName()); } }
Example #2
Source File: WorldCalculator.java From LuckPerms with MIT License | 6 votes |
@Override public void calculate(@NonNull Subject subject, @NonNull ContextConsumer consumer) { CommandSource source = subject.getCommandSource().orElse(null); if (source == null || !(source instanceof Player)) { return; } Player p = ((Player) source); Set<String> seen = new HashSet<>(); String world = p.getWorld().getName().toLowerCase(); while (seen.add(world)) { consumer.accept(DefaultContextKeys.WORLD_KEY, world); world = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(world, world).toLowerCase(); } }
Example #3
Source File: LuckPermsHook.java From DiscordSRV with GNU General Public License v3.0 | 6 votes |
@Override public void calculate(@NonNull Player target, @NonNull ContextConsumer consumer) { String userId = DiscordSRV.getPlugin().getAccountLinkManager().getDiscordId(target.getUniqueId()); consumer.accept(CONTEXT_LINKED, Boolean.toString(userId != null)); if (userId == null) { return; } Guild mainGuild = DiscordSRV.getPlugin().getMainGuild(); if (mainGuild == null) { return; } Member member = mainGuild.getMemberById(userId); if (member == null) { return; } consumer.accept(CONTEXT_BOOSTING, Boolean.toString(member.getTimeBoosted() != null)); for (Role role : member.getRoles()) { consumer.accept(CONTEXT_ROLE, role.getName()); } }
Example #4
Source File: WorldCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set<String> seen = new HashSet<>(); String world = subject.getWorld().getName().toLowerCase(); // seems like world names can sometimes be the empty string // see: https://github.com/lucko/LuckPerms/issues/2119 while (Context.isValidValue(world) && seen.add(world)) { consumer.accept(DefaultContextKeys.WORLD_KEY, world); world = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(world, world).toLowerCase(); } }
Example #5
Source File: RedisBungeeCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull ContextConsumer consumer) { RedisBungeeAPI redisBungee = RedisBungee.getApi(); if (redisBungee != null) { consumer.accept(PROXY_KEY, redisBungee.getServerId()); } }
Example #6
Source File: BackendServerCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull ProxiedPlayer subject, @NonNull ContextConsumer consumer) { Set<String> seen = new HashSet<>(); String server = getServer(subject); while (server != null && seen.add(server)) { consumer.accept(DefaultContextKeys.WORLD_KEY, server); server = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(server, server).toLowerCase(); } }
Example #7
Source File: WorldCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set<String> seen = new HashSet<>(); String world = subject.getLevel().getName().toLowerCase(); while (seen.add(world)) { consumer.accept(DefaultContextKeys.WORLD_KEY, world); world = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(world, world).toLowerCase(); } }
Example #8
Source File: BackendServerCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set<String> seen = new HashSet<>(); String server = getServer(subject); while (server != null && seen.add(server)) { consumer.accept(DefaultContextKeys.WORLD_KEY, server); server = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(server, server).toLowerCase(); } }
Example #9
Source File: LPStaticContextsCalculator.java From LuckPerms with MIT License | 5 votes |
@Override public void calculate(@NonNull ContextConsumer consumer) { String server = this.config.get(ConfigKeys.SERVER); if (!server.equals("global")) { consumer.accept(DefaultContextKeys.SERVER_KEY, server); } consumer.accept(this.config.getContextsFile().getStaticContexts()); }
Example #10
Source File: ContextCalculatorProxy.java From LuckPerms with MIT License | 4 votes |
@Override public void calculate(@NonNull Subject subject, @NonNull ContextConsumer consumer) { this.delegate.accumulateContexts(subject, new ForwardingContextSet(consumer)); }
Example #11
Source File: ContextCalculatorProxy.java From LuckPerms with MIT License | 4 votes |
private ForwardingContextSet(ContextConsumer consumer) { this.consumer = consumer; }