use of me.lucko.luckperms.api.Tristate in project LuckPerms by lucko.
the class BungeePermissionCheckListener method onOtherPermissionCheck.
@EventHandler(priority = EventPriority.HIGHEST)
public void onOtherPermissionCheck(PermissionCheckEvent e) {
if (e.getSender() instanceof ProxiedPlayer) {
return;
}
Objects.requireNonNull(e.getPermission(), "permission");
Objects.requireNonNull(e.getSender(), "sender");
String permission = e.getPermission();
Tristate result = Tristate.fromBoolean(e.hasPermission());
String name = "internal/" + e.getSender().getName();
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
this.plugin.getPermissionVault().offer(permission);
}
use of me.lucko.luckperms.api.Tristate 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.Tristate 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.Tristate in project LuckPerms by lucko.
the class DefaultsProcessor method hasPermission.
@Override
public Tristate hasPermission(String permission) {
Tristate t = getTypeDefaults().getPermissionValue(this.contexts, permission);
if (t != Tristate.UNDEFINED) {
return t;
}
t = this.service.getRootDefaults().getPermissionValue(this.contexts, permission);
if (t != Tristate.UNDEFINED) {
return t;
}
return Tristate.UNDEFINED;
}
use of me.lucko.luckperms.api.Tristate in project LuckPerms by lucko.
the class DefaultsProcessor method hasPermission.
@Override
public Tristate hasPermission(String permission) {
Tristate t = this.plugin.getDefaultPermissionMap().lookupDefaultPermission(permission, this.isOp);
if (t != Tristate.UNDEFINED) {
return t;
}
PermissionDefault def = PermissionDefault.fromPermission(this.plugin.getPermissionMap().get(permission));
return def == null ? Tristate.UNDEFINED : Tristate.fromBoolean(def.getValue(this.isOp));
}
Aggregations