use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.
the class BungeePermissionCheckListener method onPlayerTristateCheck.
@EventHandler
public void onPlayerTristateCheck(TristateCheckEvent e) {
if (!(e.getSender() instanceof ProxiedPlayer)) {
return;
}
Objects.requireNonNull(e.getPermission(), "permission");
Objects.requireNonNull(e.getSender(), "sender");
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user == null) {
e.setResult(Tristate.UNDEFINED);
return;
}
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
// just use the result provided by the proxy when the event was created
return;
}
e.setResult(result);
}
use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.
the class BungeePermissionCheckListener method onPlayerPermissionCheck.
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPermissionCheck(PermissionCheckEvent e) {
if (!(e.getSender() instanceof ProxiedPlayer)) {
return;
}
Objects.requireNonNull(e.getPermission(), "permission");
Objects.requireNonNull(e.getSender(), "sender");
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user == null) {
e.setHasPermission(false);
return;
}
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
// just use the result provided by the proxy when the event was created
return;
}
e.setHasPermission(result.asBoolean());
}
use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.
the class CalculatedSubject method getOption.
@Override
public Optional<String> getOption(ImmutableContextSet contexts, String key) {
Contexts lookupContexts = Contexts.of(contexts, Contexts.global().getSettings());
Map<String, String> meta = this.cachedData.getMetaData(lookupContexts).getMeta();
return Optional.ofNullable(meta.get(key));
}
Aggregations