Include meta lookup events in verbose output
This commit is contained in:
parent
9d4ccd33e1
commit
5e0b8ebdf6
@ -32,9 +32,9 @@ import me.lucko.luckperms.api.LookupSetting;
|
|||||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
import me.lucko.luckperms.bukkit.processors.ChildProcessor;
|
import me.lucko.luckperms.bukkit.processors.ChildProcessor;
|
||||||
import me.lucko.luckperms.bukkit.processors.DefaultsProcessor;
|
import me.lucko.luckperms.bukkit.processors.DefaultsProcessor;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
@ -50,7 +50,7 @@ public class BukkitCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
|
@ -33,7 +33,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
@ -136,7 +136,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
return ts != Tristate.UNDEFINED || Permission.DEFAULT_PERMISSION.getValue(isOp());
|
return ts != Tristate.UNDEFINED || Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
if (ts != Tristate.UNDEFINED) {
|
if (ts != Tristate.UNDEFINED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK);
|
||||||
return ts != Tristate.UNDEFINED ? ts.asBoolean() : Permission.DEFAULT_PERMISSION.getValue(isOp());
|
return ts != Tristate.UNDEFINED ? ts.asBoolean() : Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK);
|
||||||
if (ts != Tristate.UNDEFINED) {
|
if (ts != Tristate.UNDEFINED) {
|
||||||
return ts.asBoolean();
|
return ts.asBoolean();
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import me.lucko.luckperms.api.Tristate;
|
|||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.bukkit.model.dummy.DummyPermissibleBase;
|
import me.lucko.luckperms.bukkit.model.dummy.DummyPermissibleBase;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
@ -70,8 +70,8 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
recalculatePermissions();
|
recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCheck(CheckOrigin origin, String permission, boolean result) {
|
private void logCheck(PermissionCheckEvent.Origin origin, String permission, boolean result) {
|
||||||
this.plugin.getVerboseHandler().offerCheckData(origin, this.name, ContextSet.empty(), permission, Tristate.fromBoolean(result));
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(origin, this.name, ContextSet.empty(), permission, Tristate.fromBoolean(result));
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ import me.lucko.luckperms.common.model.PermissionHolder;
|
|||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
User user = this.permissionHook.lookupUser(uuid);
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getPrefix();
|
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getUserChatPrefix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
User user = this.permissionHook.lookupUser(uuid);
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getSuffix();
|
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getUserChatSuffix: %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
User user = this.permissionHook.lookupUser(uuid);
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getMeta().get(key);
|
String ret = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), key, ret);
|
logMsg("#getUserMeta: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), key, ret);
|
||||||
}
|
}
|
||||||
@ -157,7 +158,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getPrefix();
|
String ret = metaData.getPrefix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@ -173,7 +174,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getSuffix();
|
String ret = metaData.getSuffix(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
|
||||||
}
|
}
|
||||||
@ -210,7 +211,7 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
}
|
}
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
Contexts contexts = this.permissionHook.contextForLookup(null, world);
|
||||||
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
MetaCache metaData = group.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getMeta().get(key);
|
String ret = metaData.getMetaValue(key, MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
|
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ import me.lucko.luckperms.common.model.Group;
|
|||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
@ -162,7 +163,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Contexts contexts = contextForLookup(user, world);
|
Contexts contexts = contextForLookup(user, world);
|
||||||
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
|
Tristate result = permissionData.getPermissionValue(permission, PermissionCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#userHasPermission: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), permission, result);
|
logMsg("#userHasPermission: %s - %s - %s - %s", user.getPlainDisplayName(), contexts.getContexts().toMultimap(), permission, result);
|
||||||
}
|
}
|
||||||
@ -245,6 +246,8 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
value = group.getPlainDisplayName();
|
value = group.getPlainDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.plugin.getVerboseHandler().offerMetaCheckEvent(MetaCheckEvent.Origin.THIRD_PARTY_API, user.getPlainDisplayName(), ContextSet.empty(), "primarygroup", value);
|
||||||
|
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#userGetPrimaryGroup: %s - %s - %s", user.getPlainDisplayName(), world, value);
|
logMsg("#userGetPrimaryGroup: %s - %s - %s", user.getPlainDisplayName(), world, value);
|
||||||
}
|
}
|
||||||
@ -265,7 +268,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
Contexts contexts = contextForLookup(null, world);
|
Contexts contexts = contextForLookup(null, world);
|
||||||
PermissionCache permissionData = group.getCachedData().getPermissionData(contexts);
|
PermissionCache permissionData = group.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
|
Tristate result = permissionData.getPermissionValue(permission, PermissionCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
if (log()) {
|
if (log()) {
|
||||||
logMsg("#groupHasPermission: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), permission, result);
|
logMsg("#groupHasPermission: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), permission, result);
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,9 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||||
@ -46,7 +46,7 @@ public class BungeeCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
|
@ -32,7 +32,6 @@ import me.lucko.luckperms.bungee.LPBungeePlugin;
|
|||||||
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
import me.lucko.luckperms.bungee.event.TristateCheckEvent;
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
import net.md_5.bungee.api.event.PermissionCheckEvent;
|
||||||
@ -67,7 +66,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
||||||
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK);
|
||||||
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
||||||
return; // just use the result provided by the proxy when the event was created
|
return; // just use the result provided by the proxy when the event was created
|
||||||
}
|
}
|
||||||
@ -93,7 +92,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
|
||||||
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
|
||||||
return; // just use the result provided by the proxy when the event was created
|
return; // just use the result provided by the proxy when the event was created
|
||||||
}
|
}
|
||||||
@ -114,7 +113,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
Tristate result = Tristate.fromBoolean(e.hasPermission());
|
Tristate result = Tristate.fromBoolean(e.hasPermission());
|
||||||
String name = "internal/" + e.getSender().getName();
|
String name = "internal/" + e.getSender().getName();
|
||||||
|
|
||||||
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ public class BungeePermissionCheckListener implements Listener {
|
|||||||
Tristate result = e.getResult();
|
Tristate result = e.getResult();
|
||||||
String name = "internal/" + e.getSender().getName();
|
String name = "internal/" + e.getSender().getName();
|
||||||
|
|
||||||
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, result);
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(me.lucko.luckperms.common.verbose.event.PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, result);
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ import me.lucko.luckperms.common.caching.type.MetaCache;
|
|||||||
import me.lucko.luckperms.common.caching.type.PermissionCache;
|
import me.lucko.luckperms.common.caching.type.PermissionCache;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
|
import me.lucko.luckperms.common.metastacking.SimpleMetaStack;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ public abstract class AbstractCachedData implements CachedData {
|
|||||||
/**
|
/**
|
||||||
* The plugin instance
|
* The plugin instance
|
||||||
*/
|
*/
|
||||||
protected final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cache used for {@link PermissionCache} instances.
|
* The cache used for {@link PermissionCache} instances.
|
||||||
@ -80,13 +79,17 @@ public abstract class AbstractCachedData implements CachedData {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LuckPermsPlugin getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link PermissionCalculatorMetadata} instance for the given {@link Contexts}.
|
* Returns a {@link CacheMetadata} instance for the given {@link Contexts}.
|
||||||
*
|
*
|
||||||
* @param contexts the contexts the permission calculator is for
|
* @param contexts the contexts the cache is for
|
||||||
* @return the metadata instance
|
* @return the metadata instance
|
||||||
*/
|
*/
|
||||||
protected abstract PermissionCalculatorMetadata getMetadataForContexts(Contexts contexts);
|
protected abstract CacheMetadata getMetadataForContexts(Contexts contexts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link CalculatorFactory} used to build {@link PermissionCalculator}s.
|
* Gets the {@link CalculatorFactory} used to build {@link PermissionCalculator}s.
|
||||||
@ -146,7 +149,7 @@ public abstract class AbstractCachedData implements CachedData {
|
|||||||
Objects.requireNonNull(contexts, "contexts");
|
Objects.requireNonNull(contexts, "contexts");
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
PermissionCalculatorMetadata metadata = getMetadataForContexts(contexts);
|
CacheMetadata metadata = getMetadataForContexts(contexts);
|
||||||
data = new PermissionCache(contexts, metadata, getCalculatorFactory());
|
data = new PermissionCache(contexts, metadata, getCalculatorFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +173,8 @@ public abstract class AbstractCachedData implements CachedData {
|
|||||||
Objects.requireNonNull(contexts, "contexts");
|
Objects.requireNonNull(contexts, "contexts");
|
||||||
|
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = new MetaCache(contexts);
|
CacheMetadata metadata = getMetadataForContexts(contexts.getContexts());
|
||||||
|
data = new MetaCache(contexts, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaAccumulator accumulator = newAccumulator(contexts);
|
MetaAccumulator accumulator = newAccumulator(contexts);
|
||||||
|
@ -23,27 +23,29 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.calculators;
|
package me.lucko.luckperms.common.caching;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.caching.CachedDataContainer;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata about a given {@link PermissionCalculator}.
|
* Metadata about a given {@link CachedDataContainer}.
|
||||||
*/
|
*/
|
||||||
public class PermissionCalculatorMetadata {
|
public class CacheMetadata {
|
||||||
|
|
||||||
public static PermissionCalculatorMetadata of(HolderType holderType, String objectName, ContextSet context) {
|
|
||||||
return new PermissionCalculatorMetadata(holderType, objectName, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the object which owns the permission calculator
|
* The cached data instance which creates this container
|
||||||
|
*/
|
||||||
|
private final AbstractCachedData parentContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the object which owns the cache
|
||||||
*/
|
*/
|
||||||
private final HolderType holderType;
|
private final HolderType holderType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the object which owns the permission calculator
|
* The name of the object which owns the cache
|
||||||
*/
|
*/
|
||||||
private final String objectName;
|
private final String objectName;
|
||||||
|
|
||||||
@ -52,12 +54,17 @@ public class PermissionCalculatorMetadata {
|
|||||||
*/
|
*/
|
||||||
private final ContextSet context;
|
private final ContextSet context;
|
||||||
|
|
||||||
private PermissionCalculatorMetadata(HolderType holderType, String objectName, ContextSet context) {
|
public CacheMetadata(AbstractCachedData parentContainer, HolderType holderType, String objectName, ContextSet context) {
|
||||||
|
this.parentContainer = parentContainer;
|
||||||
this.holderType = holderType;
|
this.holderType = holderType;
|
||||||
this.objectName = objectName;
|
this.objectName = objectName;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbstractCachedData getParentContainer() {
|
||||||
|
return this.parentContainer;
|
||||||
|
}
|
||||||
|
|
||||||
public HolderType getHolderType() {
|
public HolderType getHolderType() {
|
||||||
return this.holderType;
|
return this.holderType;
|
||||||
}
|
}
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.common.caching;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.caching.GroupData;
|
import me.lucko.luckperms.api.caching.GroupData;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class GroupCachedData extends HolderCachedData<Group> implements GroupDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PermissionCalculatorMetadata getMetadataForContexts(Contexts contexts) {
|
protected CacheMetadata getMetadataForContexts(Contexts contexts) {
|
||||||
return PermissionCalculatorMetadata.of(HolderType.GROUP, this.holder.getPlainDisplayName(), contexts.getContexts());
|
return new CacheMetadata(this, HolderType.GROUP, this.holder.getPlainDisplayName(), contexts.getContexts());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,22 +51,22 @@ public abstract class HolderCachedData<T extends PermissionHolder> extends Abstr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CalculatorFactory getCalculatorFactory() {
|
protected CalculatorFactory getCalculatorFactory() {
|
||||||
return this.plugin.getCalculatorFactory();
|
return getPlugin().getCalculatorFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MetaContexts getDefaultMetaContexts(Contexts contexts) {
|
protected MetaContexts getDefaultMetaContexts(Contexts contexts) {
|
||||||
return this.plugin.getContextManager().formMetaContexts(contexts);
|
return getPlugin().getContextManager().formMetaContexts(contexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Boolean> resolvePermissions() {
|
protected Map<String, Boolean> resolvePermissions() {
|
||||||
return this.holder.exportPermissions(true, this.plugin.getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND));
|
return this.holder.exportPermissions(true, getPlugin().getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Boolean> resolvePermissions(Contexts contexts) {
|
protected Map<String, Boolean> resolvePermissions(Contexts contexts) {
|
||||||
return this.holder.exportPermissions(contexts, true, this.plugin.getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND));
|
return this.holder.exportPermissions(contexts, true, getPlugin().getConfiguration().get(ConfigKeys.APPLYING_SHORTHAND));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.common.caching;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.caching.UserData;
|
import me.lucko.luckperms.api.caching.UserData;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class UserCachedData extends HolderCachedData<User> implements UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PermissionCalculatorMetadata getMetadataForContexts(Contexts contexts) {
|
protected CacheMetadata getMetadataForContexts(Contexts contexts) {
|
||||||
return PermissionCalculatorMetadata.of(HolderType.USER, this.holder.getPlainDisplayName(), contexts.getContexts());
|
return new CacheMetadata(this, HolderType.USER, this.holder.getPlainDisplayName(), contexts.getContexts());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,11 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.caching.MetaContexts;
|
import me.lucko.luckperms.api.caching.MetaContexts;
|
||||||
import me.lucko.luckperms.api.caching.MetaData;
|
import me.lucko.luckperms.api.caching.MetaData;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.metastacking.MetaStack;
|
import me.lucko.luckperms.common.metastacking.MetaStack;
|
||||||
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -52,6 +56,11 @@ public class MetaCache implements MetaData {
|
|||||||
*/
|
*/
|
||||||
private final MetaContexts metaContexts;
|
private final MetaContexts metaContexts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata for this cache
|
||||||
|
*/
|
||||||
|
private final CacheMetadata metadata;
|
||||||
|
|
||||||
private ListMultimap<String, String> metaMultimap = ImmutableListMultimap.of();
|
private ListMultimap<String, String> metaMultimap = ImmutableListMultimap.of();
|
||||||
private Map<String, String> meta = ImmutableMap.of();
|
private Map<String, String> meta = ImmutableMap.of();
|
||||||
private SortedMap<Integer, String> prefixes = ImmutableSortedMap.of();
|
private SortedMap<Integer, String> prefixes = ImmutableSortedMap.of();
|
||||||
@ -59,8 +68,9 @@ public class MetaCache implements MetaData {
|
|||||||
private MetaStack prefixStack = null;
|
private MetaStack prefixStack = null;
|
||||||
private MetaStack suffixStack = null;
|
private MetaStack suffixStack = null;
|
||||||
|
|
||||||
public MetaCache(MetaContexts metaContexts) {
|
public MetaCache(MetaContexts metaContexts, CacheMetadata metadata) {
|
||||||
this.metaContexts = metaContexts;
|
this.metaContexts = metaContexts;
|
||||||
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMeta(MetaAccumulator meta) {
|
public void loadMeta(MetaAccumulator meta) {
|
||||||
@ -90,14 +100,34 @@ public class MetaCache implements MetaData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrefix() {
|
public String getPrefix() {
|
||||||
|
return getPrefix(MetaCheckEvent.Origin.LUCKPERMS_API);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix(MetaCheckEvent.Origin origin) {
|
||||||
MetaStack prefixStack = this.prefixStack;
|
MetaStack prefixStack = this.prefixStack;
|
||||||
return prefixStack == null ? null : prefixStack.toFormattedString();
|
String value = prefixStack == null ? null : prefixStack.toFormattedString();
|
||||||
|
|
||||||
|
// log this meta lookup to the verbose handler
|
||||||
|
VerboseHandler verboseHandler = this.metadata.getParentContainer().getPlugin().getVerboseHandler();
|
||||||
|
verboseHandler.offerMetaCheckEvent(origin, this.metadata.getObjectName(), this.metadata.getContext(), NodeTypes.PREFIX_KEY, String.valueOf(value));
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSuffix() {
|
public String getSuffix() {
|
||||||
|
return getSuffix(MetaCheckEvent.Origin.LUCKPERMS_API);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuffix(MetaCheckEvent.Origin origin) {
|
||||||
MetaStack suffixStack = this.suffixStack;
|
MetaStack suffixStack = this.suffixStack;
|
||||||
return suffixStack == null ? null : suffixStack.toFormattedString();
|
String value = suffixStack == null ? null : suffixStack.toFormattedString();
|
||||||
|
|
||||||
|
// log this meta lookup to the verbose handler
|
||||||
|
VerboseHandler verboseHandler = this.metadata.getParentContainer().getPlugin().getVerboseHandler();
|
||||||
|
verboseHandler.offerMetaCheckEvent(origin, this.metadata.getObjectName(), this.metadata.getContext(), NodeTypes.SUFFIX_KEY, String.valueOf(value));
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,6 +160,16 @@ public class MetaCache implements MetaData {
|
|||||||
return this.meta;
|
return this.meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMetaValue(String key, MetaCheckEvent.Origin origin) {
|
||||||
|
String value = this.meta.get(key);
|
||||||
|
|
||||||
|
// log this meta lookup to the verbose handler
|
||||||
|
VerboseHandler verboseHandler = this.metadata.getParentContainer().getPlugin().getVerboseHandler();
|
||||||
|
verboseHandler.offerMetaCheckEvent(origin, this.metadata.getObjectName(), this.metadata.getContext(), key, String.valueOf(value));
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull SortedMap<Integer, String> getPrefixes() {
|
public @NonNull SortedMap<Integer, String> getPrefixes() {
|
||||||
return this.prefixes;
|
return this.prefixes;
|
||||||
|
@ -28,10 +28,10 @@ package me.lucko.luckperms.common.caching.type;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.caching.PermissionData;
|
import me.lucko.luckperms.api.caching.PermissionData;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class PermissionCache implements PermissionData {
|
|||||||
*/
|
*/
|
||||||
private final PermissionCalculator calculator;
|
private final PermissionCalculator calculator;
|
||||||
|
|
||||||
public PermissionCache(Contexts contexts, PermissionCalculatorMetadata metadata, CalculatorFactory calculatorFactory) {
|
public PermissionCache(Contexts contexts, CacheMetadata metadata, CalculatorFactory calculatorFactory) {
|
||||||
this.contexts = contexts;
|
this.contexts = contexts;
|
||||||
this.permissions = new ConcurrentHashMap<>();
|
this.permissions = new ConcurrentHashMap<>();
|
||||||
this.permissionsUnmodifiable = Collections.unmodifiableMap(this.permissions);
|
this.permissionsUnmodifiable = Collections.unmodifiableMap(this.permissions);
|
||||||
@ -107,10 +107,10 @@ public class PermissionCache implements PermissionData {
|
|||||||
if (permission == null) {
|
if (permission == null) {
|
||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
return this.calculator.getPermissionValue(permission, CheckOrigin.API);
|
return this.calculator.getPermissionValue(permission, PermissionCheckEvent.Origin.LUCKPERMS_API);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tristate getPermissionValue(String permission, CheckOrigin origin) {
|
public Tristate getPermissionValue(String permission, PermissionCheckEvent.Origin origin) {
|
||||||
if (permission == null) {
|
if (permission == null) {
|
||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
@ -121,4 +121,5 @@ public class PermissionCache implements PermissionData {
|
|||||||
public @NonNull Contexts getContexts() {
|
public @NonNull Contexts getContexts() {
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package me.lucko.luckperms.common.calculators;
|
package me.lucko.luckperms.common.calculators;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a calculator instance given a set of contexts
|
* Creates a calculator instance given a set of contexts
|
||||||
@ -39,6 +40,6 @@ public interface CalculatorFactory {
|
|||||||
* @param metadata the calculator metadata
|
* @param metadata the calculator metadata
|
||||||
* @return a permission calculator instance
|
* @return a permission calculator instance
|
||||||
*/
|
*/
|
||||||
PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata);
|
PermissionCalculator build(Contexts contexts, CacheMetadata metadata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,10 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public class PermissionCalculator implements CacheLoader<String, Tristate> {
|
|||||||
/**
|
/**
|
||||||
* Info about the nature of this calculator.
|
* Info about the nature of this calculator.
|
||||||
*/
|
*/
|
||||||
private final PermissionCalculatorMetadata metadata;
|
private final CacheMetadata metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The processors which back this calculator
|
* The processors which back this calculator
|
||||||
@ -65,7 +66,7 @@ public class PermissionCalculator implements CacheLoader<String, Tristate> {
|
|||||||
*/
|
*/
|
||||||
private final LoadingCache<String, Tristate> lookupCache = Caffeine.newBuilder().build(this);
|
private final LoadingCache<String, Tristate> lookupCache = Caffeine.newBuilder().build(this);
|
||||||
|
|
||||||
public PermissionCalculator(LuckPermsPlugin plugin, PermissionCalculatorMetadata metadata, ImmutableList<PermissionProcessor> processors) {
|
public PermissionCalculator(LuckPermsPlugin plugin, CacheMetadata metadata, ImmutableList<PermissionProcessor> processors) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
this.processors = processors;
|
this.processors = processors;
|
||||||
@ -80,7 +81,7 @@ public class PermissionCalculator implements CacheLoader<String, Tristate> {
|
|||||||
* @param origin marks where this check originated from
|
* @param origin marks where this check originated from
|
||||||
* @return the result
|
* @return the result
|
||||||
*/
|
*/
|
||||||
public Tristate getPermissionValue(String permission, CheckOrigin origin) {
|
public Tristate getPermissionValue(String permission, PermissionCheckEvent.Origin origin) {
|
||||||
// convert the permission to lowercase, as all values in the backing map are also lowercase.
|
// convert the permission to lowercase, as all values in the backing map are also lowercase.
|
||||||
// this allows fast case insensitive lookups
|
// this allows fast case insensitive lookups
|
||||||
permission = permission.toLowerCase();
|
permission = permission.toLowerCase();
|
||||||
@ -89,7 +90,7 @@ public class PermissionCalculator implements CacheLoader<String, Tristate> {
|
|||||||
Tristate result = this.lookupCache.get(permission);
|
Tristate result = this.lookupCache.get(permission);
|
||||||
|
|
||||||
// log this permission lookup to the verbose handler
|
// log this permission lookup to the verbose handler
|
||||||
this.plugin.getVerboseHandler().offerCheckData(origin, this.metadata.getObjectName(), this.metadata.getContext(), permission, result);
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(origin, this.metadata.getObjectName(), this.metadata.getContext(), permission, result);
|
||||||
|
|
||||||
// return the result
|
// return the result
|
||||||
return result;
|
return result;
|
||||||
|
@ -37,7 +37,7 @@ import me.lucko.luckperms.common.model.User;
|
|||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -299,7 +299,7 @@ public final class ArgumentPermissions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PermissionCache permissionData = user.getCachedData().getPermissionData(Contexts.of(contextSet, Contexts.global().getSettings()));
|
PermissionCache permissionData = user.getCachedData().getPermissionData(Contexts.of(contextSet, Contexts.global().getSettings()));
|
||||||
return !permissionData.getPermissionValue(NodeFactory.groupNode(targetGroupName), CheckOrigin.INTERNAL).asBoolean();
|
return !permissionData.getPermissionValue(NodeFactory.groupNode(targetGroupName), PermissionCheckEvent.Origin.INTERNAL).asBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArgumentPermissions() {}
|
private ArgumentPermissions() {}
|
||||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
import me.lucko.luckperms.common.utils.Uuids;
|
import me.lucko.luckperms.common.utils.Uuids;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -70,7 +70,7 @@ public class CheckCommand extends SingleCommand {
|
|||||||
return CommandResult.STATE_ERROR;
|
return CommandResult.STATE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate tristate = user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts())).getPermissionValue(permission, CheckOrigin.INTERNAL);
|
Tristate tristate = user.getCachedData().getPermissionData(plugin.getContextForUser(user).orElse(plugin.getContextManager().getStaticContexts())).getPermissionValue(permission, PermissionCheckEvent.Origin.INTERNAL);
|
||||||
Message.CHECK_RESULT.send(sender, user.getFormattedDisplayName(), permission, MessageUtils.formatTristate(tristate));
|
Message.CHECK_RESULT.send(sender, user.getFormattedDisplayName(), permission, MessageUtils.formatTristate(tristate));
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import me.lucko.luckperms.common.utils.Predicates;
|
|||||||
import me.lucko.luckperms.common.utils.gson.GsonProvider;
|
import me.lucko.luckperms.common.utils.gson.GsonProvider;
|
||||||
import me.lucko.luckperms.common.utils.gson.JArray;
|
import me.lucko.luckperms.common.utils.gson.JArray;
|
||||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
import me.lucko.luckperms.common.web.Pastebin;
|
import me.lucko.luckperms.common.web.Pastebin;
|
||||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||||
|
|
||||||
@ -239,8 +240,8 @@ public class DebugCommand extends SingleCommand {
|
|||||||
|
|
||||||
private static JObject serializeMetaData(MetaCache metaData) {
|
private static JObject serializeMetaData(MetaCache metaData) {
|
||||||
return new JObject()
|
return new JObject()
|
||||||
.add("prefix", metaData.getPrefix())
|
.add("prefix", metaData.getPrefix(MetaCheckEvent.Origin.INTERNAL))
|
||||||
.add("suffix", metaData.getSuffix())
|
.add("suffix", metaData.getSuffix(MetaCheckEvent.Origin.INTERNAL))
|
||||||
.add("prefixes", () -> {
|
.add("prefixes", () -> {
|
||||||
JArray prefixes = new JArray();
|
JArray prefixes = new JArray();
|
||||||
for (Map.Entry<Integer, String> entry : metaData.getPrefixes().entrySet()) {
|
for (Map.Entry<Integer, String> entry : metaData.getPrefixes().entrySet()) {
|
||||||
|
@ -29,8 +29,8 @@ import com.google.common.collect.ListMultimap;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.caching.MetaData;
|
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
|
import me.lucko.luckperms.common.caching.type.MetaCache;
|
||||||
import me.lucko.luckperms.common.command.CommandResult;
|
import me.lucko.luckperms.common.command.CommandResult;
|
||||||
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
import me.lucko.luckperms.common.command.abstraction.SubCommand;
|
||||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||||
@ -44,6 +44,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
|||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.DurationFormatter;
|
import me.lucko.luckperms.common.utils.DurationFormatter;
|
||||||
import me.lucko.luckperms.common.utils.Predicates;
|
import me.lucko.luckperms.common.utils.Predicates;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -110,12 +111,14 @@ public class UserInfo extends SubCommand<User> {
|
|||||||
.collect(Collectors.joining(" "));
|
.collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData data = user.getCachedData().getMetaData(contexts);
|
MetaCache data = user.getCachedData().getMetaData(contexts);
|
||||||
if (data.getPrefix() != null) {
|
String prefixValue = data.getPrefix(MetaCheckEvent.Origin.INTERNAL);
|
||||||
prefix = "&f\"" + data.getPrefix() + "&f\"";
|
if (prefixValue != null) {
|
||||||
|
prefix = "&f\"" + prefixValue + "&f\"";
|
||||||
}
|
}
|
||||||
if (data.getSuffix() != null) {
|
String sussexValue = data.getSuffix(MetaCheckEvent.Origin.INTERNAL);
|
||||||
suffix = "&f\"" + data.getSuffix() + "&f\"";
|
if (sussexValue != null) {
|
||||||
|
suffix = "&f\"" + sussexValue + "&f\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
ListMultimap<String, String> metaMap = data.getMetaMultimap();
|
ListMultimap<String, String> metaMap = data.getMetaMultimap();
|
||||||
|
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.caching.type.PermissionCache;
|
|||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -150,7 +150,7 @@ public class TreeView {
|
|||||||
checks = new JObject();
|
checks = new JObject();
|
||||||
for (Map.Entry<Integer, String> node : this.view.getNodeEndings()) {
|
for (Map.Entry<Integer, String> node : this.view.getNodeEndings()) {
|
||||||
String permission = prefix + node.getValue();
|
String permission = prefix + node.getValue();
|
||||||
checks.add(permission, checker.getPermissionValue(permission, CheckOrigin.INTERNAL).name().toLowerCase());
|
checks.add(permission, checker.getPermissionValue(permission, PermissionCheckEvent.Origin.INTERNAL).name().toLowerCase());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
checks = null;
|
checks = null;
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of LuckPerms, licensed under the MIT License.
|
|
||||||
*
|
|
||||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.lucko.luckperms.common.verbose;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the origin of a permission check
|
|
||||||
*/
|
|
||||||
public enum CheckOrigin {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by a 'hasPermission' check on the platform
|
|
||||||
*/
|
|
||||||
PLATFORM_PERMISSION_CHECK,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by a 'hasPermissionSet' type check on the platform
|
|
||||||
*/
|
|
||||||
PLATFORM_LOOKUP_CHECK,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by an API call
|
|
||||||
*/
|
|
||||||
API,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the check was caused by a LuckPerms internal
|
|
||||||
*/
|
|
||||||
INTERNAL
|
|
||||||
|
|
||||||
}
|
|
@ -28,6 +28,9 @@ package me.lucko.luckperms.common.verbose;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.utils.Scripting;
|
import me.lucko.luckperms.common.utils.Scripting;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.VerboseEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -137,7 +140,7 @@ public final class VerboseFilter {
|
|||||||
* @param data the check data
|
* @param data the check data
|
||||||
* @return if the check data passes the filter
|
* @return if the check data passes the filter
|
||||||
*/
|
*/
|
||||||
public boolean evaluate(CheckData data) {
|
public boolean evaluate(VerboseEvent data) {
|
||||||
if (this.expression.isEmpty()) {
|
if (this.expression.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -201,10 +204,10 @@ public final class VerboseFilter {
|
|||||||
/**
|
/**
|
||||||
* Returns the value of this token when part of an evaluated expression
|
* Returns the value of this token when part of an evaluated expression
|
||||||
*
|
*
|
||||||
* @param data the data which an expression is being formed for
|
* @param event the data which an expression is being formed for
|
||||||
* @return the value to be used as part of the evaluated expression
|
* @return the value to be used as part of the evaluated expression
|
||||||
*/
|
*/
|
||||||
String forExpression(CheckData data);
|
String forExpression(VerboseEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a 'dummy' value for this token in order to build a test
|
* Returns a 'dummy' value for this token in order to build a test
|
||||||
@ -235,7 +238,7 @@ public final class VerboseFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String forExpression(CheckData data) {
|
public String forExpression(VerboseEvent event) {
|
||||||
return this.string;
|
return this.string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +260,7 @@ public final class VerboseFilter {
|
|||||||
*
|
*
|
||||||
* The check data will be deemed a "match" if:
|
* The check data will be deemed a "match" if:
|
||||||
* - the target of the check is equal to the value of the token
|
* - the target of the check is equal to the value of the token
|
||||||
* - the permission being checked for starts with the value of the token
|
* - the permission/meta key being checked for starts with the value of the token
|
||||||
* - the result of the check is equal to the value of the token
|
* - the result of the check is equal to the value of the token
|
||||||
*/
|
*/
|
||||||
private static final class VariableToken implements Token {
|
private static final class VariableToken implements Token {
|
||||||
@ -268,12 +271,27 @@ public final class VerboseFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String forExpression(CheckData data) {
|
public String forExpression(VerboseEvent event) {
|
||||||
return Boolean.toString(
|
if (event instanceof PermissionCheckEvent) {
|
||||||
data.getCheckTarget().equalsIgnoreCase(this.value) ||
|
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
|
||||||
data.getPermission().toLowerCase().startsWith(this.value.toLowerCase()) ||
|
return Boolean.toString(
|
||||||
data.getResult().name().equalsIgnoreCase(this.value)
|
permissionEvent.getCheckTarget().equalsIgnoreCase(this.value) ||
|
||||||
);
|
permissionEvent.getPermission().toLowerCase().startsWith(this.value.toLowerCase()) ||
|
||||||
|
permissionEvent.getResult().name().equalsIgnoreCase(this.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event instanceof MetaCheckEvent) {
|
||||||
|
MetaCheckEvent metaEvent = (MetaCheckEvent) event;
|
||||||
|
return Boolean.toString(
|
||||||
|
metaEvent.getCheckTarget().equalsIgnoreCase(this.value) ||
|
||||||
|
metaEvent.getKey().toLowerCase().startsWith(this.value.toLowerCase()) ||
|
||||||
|
metaEvent.getResult().equalsIgnoreCase(this.value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Unknown event type: " + event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,9 @@ import me.lucko.luckperms.api.context.ContextSet;
|
|||||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
import me.lucko.luckperms.common.utils.RepeatingTask;
|
import me.lucko.luckperms.common.utils.RepeatingTask;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.VerboseEvent;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
@ -39,15 +42,15 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts {@link CheckData} and passes it onto registered {@link VerboseListener}s.
|
* Accepts {@link VerboseEvent}s and passes them onto registered {@link VerboseListener}s.
|
||||||
*/
|
*/
|
||||||
public class VerboseHandler extends RepeatingTask {
|
public class VerboseHandler extends RepeatingTask {
|
||||||
|
|
||||||
// the listeners currently registered
|
// the listeners currently registered
|
||||||
private final Map<UUID, VerboseListener> listeners;
|
private final Map<UUID, VerboseListener> listeners;
|
||||||
|
|
||||||
// a queue of check data
|
// a queue of events
|
||||||
private final Queue<CheckData> queue;
|
private final Queue<VerboseEvent> queue;
|
||||||
|
|
||||||
// if there are any listeners currently registered
|
// if there are any listeners currently registered
|
||||||
private boolean listening = false;
|
private boolean listening = false;
|
||||||
@ -59,18 +62,18 @@ public class VerboseHandler extends RepeatingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offers check data to the handler, to be eventually passed onto listeners.
|
* Offers permission check data to the handler, to be eventually passed onto listeners.
|
||||||
*
|
*
|
||||||
* <p>The check data is added to a queue to be processed later, to avoid blocking
|
* <p>The check data is added to a queue to be processed later, to avoid blocking
|
||||||
* the main thread each time a permission check is made.</p>
|
* the main thread each time a permission check is made.</p>
|
||||||
*
|
*
|
||||||
* @param checkOrigin the origin of the check
|
* @param origin the origin of the check
|
||||||
* @param checkTarget the target of the permission check
|
* @param checkTarget the target of the permission check
|
||||||
* @param checkContext the contexts where the check occurred
|
* @param checkContext the contexts where the check occurred
|
||||||
* @param permission the permission which was checked for
|
* @param permission the permission which was checked for
|
||||||
* @param result the result of the permission check
|
* @param result the result of the permission check
|
||||||
*/
|
*/
|
||||||
public void offerCheckData(CheckOrigin checkOrigin, String checkTarget, ContextSet checkContext, String permission, Tristate result) {
|
public void offerPermissionCheckEvent(PermissionCheckEvent.Origin origin, String checkTarget, ContextSet checkContext, String permission, Tristate result) {
|
||||||
// don't bother even processing the check if there are no listeners registered
|
// don't bother even processing the check if there are no listeners registered
|
||||||
if (!this.listening) {
|
if (!this.listening) {
|
||||||
return;
|
return;
|
||||||
@ -80,7 +83,32 @@ public class VerboseHandler extends RepeatingTask {
|
|||||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||||
|
|
||||||
// add the check data to a queue to be processed later.
|
// add the check data to a queue to be processed later.
|
||||||
this.queue.offer(new CheckData(checkOrigin, checkTarget, checkContext.makeImmutable(), trace, permission, result));
|
this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkContext.makeImmutable(), trace, permission, result));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offers meta check data to the handler, to be eventually passed onto listeners.
|
||||||
|
*
|
||||||
|
* <p>The check data is added to a queue to be processed later, to avoid blocking
|
||||||
|
* the main thread each time a meta check is made.</p>
|
||||||
|
*
|
||||||
|
* @param origin the origin of the check
|
||||||
|
* @param checkTarget the target of the meta check
|
||||||
|
* @param checkContext the contexts where the check occurred
|
||||||
|
* @param key the meta key which was checked for
|
||||||
|
* @param result the result of the meta check
|
||||||
|
*/
|
||||||
|
public void offerMetaCheckEvent(MetaCheckEvent.Origin origin, String checkTarget, ContextSet checkContext, String key, String result) {
|
||||||
|
// don't bother even processing the check if there are no listeners registered
|
||||||
|
if (!this.listening) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//noinspection ThrowableNotThrown
|
||||||
|
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||||
|
|
||||||
|
// add the check data to a queue to be processed later.
|
||||||
|
this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkContext.makeImmutable(), trace, key, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +141,7 @@ public class VerboseHandler extends RepeatingTask {
|
|||||||
// remove listeners where the sender is no longer valid
|
// remove listeners where the sender is no longer valid
|
||||||
this.listeners.values().removeIf(l -> !l.getNotifiedSender().isValid());
|
this.listeners.values().removeIf(l -> !l.getNotifiedSender().isValid());
|
||||||
|
|
||||||
// handle all checks in the queue
|
// handle all events in the queue
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
// update listening state
|
// update listening state
|
||||||
@ -121,12 +149,12 @@ public class VerboseHandler extends RepeatingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes the current check data to the listeners.
|
* Flushes the pending events to listeners.
|
||||||
*/
|
*/
|
||||||
public synchronized void flush() {
|
public synchronized void flush() {
|
||||||
for (CheckData e; (e = this.queue.poll()) != null; ) {
|
for (VerboseEvent e; (e = this.queue.poll()) != null; ) {
|
||||||
for (VerboseListener listener : this.listeners.values()) {
|
for (VerboseListener listener : this.listeners.values()) {
|
||||||
listener.acceptData(e);
|
listener.acceptEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,9 @@ import me.lucko.luckperms.common.utils.StackTracePrinter;
|
|||||||
import me.lucko.luckperms.common.utils.TextUtils;
|
import me.lucko.luckperms.common.utils.TextUtils;
|
||||||
import me.lucko.luckperms.common.utils.gson.JArray;
|
import me.lucko.luckperms.common.utils.gson.JArray;
|
||||||
import me.lucko.luckperms.common.utils.gson.JObject;
|
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.VerboseEvent;
|
||||||
import me.lucko.luckperms.common.web.StandardPastebin;
|
import me.lucko.luckperms.common.web.StandardPastebin;
|
||||||
|
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
@ -50,7 +53,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts and processes {@link CheckData}, passed from the {@link VerboseHandler}.
|
* Accepts and processes {@link VerboseEvent}, passed from the {@link VerboseHandler}.
|
||||||
*/
|
*/
|
||||||
public class VerboseListener {
|
public class VerboseListener {
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||||
@ -64,7 +67,6 @@ public class VerboseListener {
|
|||||||
|
|
||||||
private static final StackTracePrinter FILTERING_PRINTER = StackTracePrinter.builder()
|
private static final StackTracePrinter FILTERING_PRINTER = StackTracePrinter.builder()
|
||||||
.ignoreClassStartingWith("me.lucko.luckperms.")
|
.ignoreClassStartingWith("me.lucko.luckperms.")
|
||||||
.ignoreClassStartingWith("com.github.benmanes.caffeine")
|
|
||||||
.ignoreClass("java.util.concurrent.CompletableFuture")
|
.ignoreClass("java.util.concurrent.CompletableFuture")
|
||||||
.ignoreClass("java.util.concurrent.ConcurrentHashMap")
|
.ignoreClass("java.util.concurrent.ConcurrentHashMap")
|
||||||
.build();
|
.build();
|
||||||
@ -93,13 +95,13 @@ public class VerboseListener {
|
|||||||
private final VerboseFilter filter;
|
private final VerboseFilter filter;
|
||||||
// if we should notify the sender
|
// if we should notify the sender
|
||||||
private final boolean notify;
|
private final boolean notify;
|
||||||
// the number of checks we have processed
|
// the number of events we have processed
|
||||||
private final AtomicInteger counter = new AtomicInteger(0);
|
private final AtomicInteger counter = new AtomicInteger(0);
|
||||||
// the number of checks we have processed and accepted, based on the filter rules for this
|
// the number of events we have processed and accepted, based on the filter rules for this
|
||||||
// listener
|
// listener
|
||||||
private final AtomicInteger matchedCounter = new AtomicInteger(0);
|
private final AtomicInteger matchedCounter = new AtomicInteger(0);
|
||||||
// the checks which passed the filter, up to a max size of #DATA_TRUNCATION
|
// the events which passed the filter, up to a max size of #DATA_TRUNCATION
|
||||||
private final List<CheckData> results = new ArrayList<>(DATA_TRUNCATION / 10);
|
private final List<VerboseEvent> results = new ArrayList<>(DATA_TRUNCATION / 10);
|
||||||
|
|
||||||
public VerboseListener(Sender notifiedSender, VerboseFilter filter, boolean notify) {
|
public VerboseListener(Sender notifiedSender, VerboseFilter filter, boolean notify) {
|
||||||
this.notifiedSender = notifiedSender;
|
this.notifiedSender = notifiedSender;
|
||||||
@ -108,16 +110,16 @@ public class VerboseListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts and processes check data.
|
* Accepts and processes verbose events.
|
||||||
*
|
*
|
||||||
* @param data the data to process
|
* @param event the event to process
|
||||||
*/
|
*/
|
||||||
public void acceptData(CheckData data) {
|
public void acceptEvent(VerboseEvent event) {
|
||||||
// increment handled counter
|
// increment handled counter
|
||||||
this.counter.incrementAndGet();
|
this.counter.incrementAndGet();
|
||||||
|
|
||||||
// check if the data passes our filter
|
// check if the data passes our filter
|
||||||
if (!this.filter.evaluate(data)) {
|
if (!this.filter.evaluate(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,47 +128,84 @@ public class VerboseListener {
|
|||||||
|
|
||||||
// record the check, if we have space for it
|
// record the check, if we have space for it
|
||||||
if (this.results.size() < DATA_TRUNCATION) {
|
if (this.results.size() < DATA_TRUNCATION) {
|
||||||
this.results.add(data);
|
this.results.add(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle notifications
|
// handle notifications
|
||||||
if (this.notify) {
|
if (this.notify) {
|
||||||
sendNotification(data);
|
sendNotification(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(CheckData data) {
|
private void sendNotification(VerboseEvent event) {
|
||||||
if (this.notifiedSender.isConsole()) {
|
if (this.notifiedSender.isConsole()) {
|
||||||
// just send as a raw message
|
// just send as a raw message
|
||||||
Message.VERBOSE_LOG.send(this.notifiedSender,
|
if (event instanceof PermissionCheckEvent) {
|
||||||
data.getCheckTarget(),
|
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
|
||||||
data.getPermission(),
|
Message.VERBOSE_LOG.send(this.notifiedSender,
|
||||||
getTristateColor(data.getResult()),
|
permissionEvent.getCheckTarget(),
|
||||||
data.getResult().name().toLowerCase()
|
permissionEvent.getPermission(),
|
||||||
);
|
getTristateColor(permissionEvent.getResult()),
|
||||||
|
permissionEvent.getResult().name().toLowerCase()
|
||||||
|
);
|
||||||
|
} else if (event instanceof MetaCheckEvent) {
|
||||||
|
MetaCheckEvent metaEvent = (MetaCheckEvent) event;
|
||||||
|
Message.VERBOSE_LOG.send(this.notifiedSender,
|
||||||
|
metaEvent.getCheckTarget(),
|
||||||
|
metaEvent.getKey() + " (meta)",
|
||||||
|
"&7",
|
||||||
|
metaEvent.getResult()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unknown event type: " + event);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// form a hoverevent from the check trace
|
// form a text component from the check trace
|
||||||
TextComponent textComponent = Message.VERBOSE_LOG.asComponent(this.notifiedSender.getPlugin().getLocaleManager(),
|
TextComponent textComponent;
|
||||||
data.getCheckTarget(),
|
|
||||||
data.getPermission(),
|
|
||||||
getTristateColor(data.getResult()),
|
|
||||||
data.getResult().name().toLowerCase()
|
|
||||||
);
|
|
||||||
|
|
||||||
// build the text
|
if (event instanceof PermissionCheckEvent) {
|
||||||
|
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
|
||||||
|
textComponent = Message.VERBOSE_LOG.asComponent(this.notifiedSender.getPlugin().getLocaleManager(),
|
||||||
|
permissionEvent.getCheckTarget(),
|
||||||
|
permissionEvent.getPermission(),
|
||||||
|
getTristateColor(permissionEvent.getResult()),
|
||||||
|
permissionEvent.getResult().name().toLowerCase()
|
||||||
|
);
|
||||||
|
} else if (event instanceof MetaCheckEvent) {
|
||||||
|
MetaCheckEvent metaEvent = (MetaCheckEvent) event;
|
||||||
|
textComponent = Message.VERBOSE_LOG.asComponent(this.notifiedSender.getPlugin().getLocaleManager(),
|
||||||
|
metaEvent.getCheckTarget(),
|
||||||
|
metaEvent.getKey() + " (meta)",
|
||||||
|
"&7",
|
||||||
|
metaEvent.getResult()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unknown event type: " + event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// build the hover text
|
||||||
List<String> hover = new ArrayList<>();
|
List<String> hover = new ArrayList<>();
|
||||||
hover.add("&bOrigin: &2" + data.getCheckOrigin().name());
|
|
||||||
hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlugin().getLocaleManager(), data.getCheckContext()));
|
if (event instanceof PermissionCheckEvent) {
|
||||||
|
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
|
||||||
|
hover.add("&bOrigin: &2" + permissionEvent.getOrigin().name());
|
||||||
|
}
|
||||||
|
if (event instanceof MetaCheckEvent) {
|
||||||
|
MetaCheckEvent metaEvent = (MetaCheckEvent) event;
|
||||||
|
hover.add("&bOrigin: &2" + metaEvent.getOrigin().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlugin().getLocaleManager(), event.getCheckContext()));
|
||||||
hover.add("&bTrace: &r");
|
hover.add("&bTrace: &r");
|
||||||
|
|
||||||
Consumer<StackTraceElement> printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str));
|
Consumer<StackTraceElement> printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str));
|
||||||
int overflow;
|
int overflow;
|
||||||
if (data.getCheckOrigin() == CheckOrigin.API || data.getCheckOrigin() == CheckOrigin.INTERNAL) {
|
if (shouldFilterStackTrace(event)) {
|
||||||
overflow = CHAT_UNFILTERED_PRINTER.process(data.getCheckTrace(), printer);
|
overflow = CHAT_FILTERED_PRINTER.process(event.getCheckTrace(), printer);
|
||||||
} else {
|
} else {
|
||||||
overflow = CHAT_FILTERED_PRINTER.process(data.getCheckTrace(), printer);
|
overflow = CHAT_UNFILTERED_PRINTER.process(event.getCheckTrace(), printer);
|
||||||
}
|
}
|
||||||
if (overflow != 0) {
|
if (overflow != 0) {
|
||||||
hover.add("&f... and " + overflow + " more");
|
hover.add("&f... and " + overflow + " more");
|
||||||
@ -178,6 +217,15 @@ public class VerboseListener {
|
|||||||
this.notifiedSender.sendMessage(text);
|
this.notifiedSender.sendMessage(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shouldFilterStackTrace(VerboseEvent event) {
|
||||||
|
if (event instanceof PermissionCheckEvent) {
|
||||||
|
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
|
||||||
|
return permissionEvent.getOrigin() == PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK ||
|
||||||
|
permissionEvent.getOrigin() == PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads the captured data in this listener to a paste and returns the url
|
* Uploads the captured data in this listener to a paste and returns the url
|
||||||
*
|
*
|
||||||
@ -217,12 +265,8 @@ public class VerboseListener {
|
|||||||
.add("truncated", truncated);
|
.add("truncated", truncated);
|
||||||
|
|
||||||
JArray data = new JArray();
|
JArray data = new JArray();
|
||||||
for (CheckData c : this.results) {
|
for (VerboseEvent events : this.results) {
|
||||||
if (c.getCheckOrigin() == CheckOrigin.API || c.getCheckOrigin() == CheckOrigin.INTERNAL) {
|
data.add(events.toJson(shouldFilterStackTrace(events) ? WEB_FILTERED_PRINTER : WEB_UNFILTERED_PRINTER));
|
||||||
data.add(c.toJson(WEB_UNFILTERED_PRINTER));
|
|
||||||
} else {
|
|
||||||
data.add(c.toJson(WEB_FILTERED_PRINTER));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.results.clear();
|
this.results.clear();
|
||||||
|
|
||||||
|
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.verbose.event;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||||
|
|
||||||
|
public class MetaCheckEvent extends VerboseEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The origin of the check
|
||||||
|
*/
|
||||||
|
private final Origin origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The meta key which was checked for
|
||||||
|
*/
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of the meta check
|
||||||
|
*/
|
||||||
|
private final String result;
|
||||||
|
|
||||||
|
public MetaCheckEvent(Origin origin, String checkTarget, ImmutableContextSet checkContext, StackTraceElement[] checkTrace, String key, String result) {
|
||||||
|
super(checkTarget, checkContext, checkTrace);
|
||||||
|
this.origin = origin;
|
||||||
|
this.key = key;
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Origin getOrigin() {
|
||||||
|
return this.origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void serializeTo(JObject object) {
|
||||||
|
object.add("type", "meta")
|
||||||
|
.add("key", this.key)
|
||||||
|
.add("result", this.result)
|
||||||
|
.add("origin", this.origin.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the origin of a meta check
|
||||||
|
*/
|
||||||
|
public enum Origin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a lookup in a platform API
|
||||||
|
*/
|
||||||
|
PLATFORM_API,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a 3rd party API call
|
||||||
|
*/
|
||||||
|
THIRD_PARTY_API,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a LuckPerms API call
|
||||||
|
*/
|
||||||
|
LUCKPERMS_API,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a LuckPerms internal
|
||||||
|
*/
|
||||||
|
INTERNAL
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.verbose.event;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Tristate;
|
||||||
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.utils.gson.JObject;
|
||||||
|
|
||||||
|
public class PermissionCheckEvent extends VerboseEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The origin of the check
|
||||||
|
*/
|
||||||
|
private final Origin origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The permission which was checked for
|
||||||
|
*/
|
||||||
|
private final String permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of the permission check
|
||||||
|
*/
|
||||||
|
private final Tristate result;
|
||||||
|
|
||||||
|
public PermissionCheckEvent(Origin origin, String checkTarget, ImmutableContextSet checkContext, StackTraceElement[] checkTrace, String permission, Tristate result) {
|
||||||
|
super(checkTarget, checkContext, checkTrace);
|
||||||
|
this.origin = origin;
|
||||||
|
this.permission = permission;
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Origin getOrigin() {
|
||||||
|
return this.origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return this.permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tristate getResult() {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void serializeTo(JObject object) {
|
||||||
|
object.add("type", "permission")
|
||||||
|
.add("permission", this.permission)
|
||||||
|
.add("result", this.result.name().toLowerCase())
|
||||||
|
.add("origin", this.origin.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the origin of a permission check
|
||||||
|
*/
|
||||||
|
public enum Origin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a 'hasPermission' check on the platform
|
||||||
|
*/
|
||||||
|
PLATFORM_PERMISSION_CHECK,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a 'hasPermissionSet' type check on the platform
|
||||||
|
*/
|
||||||
|
PLATFORM_LOOKUP_CHECK,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a 3rd party API call
|
||||||
|
*/
|
||||||
|
THIRD_PARTY_API,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by an LuckPerms API call
|
||||||
|
*/
|
||||||
|
LUCKPERMS_API,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the check was caused by a LuckPerms internal
|
||||||
|
*/
|
||||||
|
INTERNAL
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -23,11 +23,10 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package me.lucko.luckperms.common.verbose;
|
package me.lucko.luckperms.common.verbose.event;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.utils.StackTracePrinter;
|
import me.lucko.luckperms.common.utils.StackTracePrinter;
|
||||||
import me.lucko.luckperms.common.utils.gson.JArray;
|
import me.lucko.luckperms.common.utils.gson.JArray;
|
||||||
@ -36,14 +35,9 @@ import me.lucko.luckperms.common.utils.gson.JObject;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the data from a permission check
|
* Represents a verbose event.
|
||||||
*/
|
*/
|
||||||
public class CheckData {
|
public abstract class VerboseEvent {
|
||||||
|
|
||||||
/**
|
|
||||||
* The origin of the check
|
|
||||||
*/
|
|
||||||
private final CheckOrigin checkOrigin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the entity which was checked
|
* The name of the entity which was checked
|
||||||
@ -60,27 +54,10 @@ public class CheckData {
|
|||||||
*/
|
*/
|
||||||
private final StackTraceElement[] checkTrace;
|
private final StackTraceElement[] checkTrace;
|
||||||
|
|
||||||
/**
|
protected VerboseEvent(String checkTarget, ImmutableContextSet checkContext, StackTraceElement[] checkTrace) {
|
||||||
* The permission which was checked for
|
|
||||||
*/
|
|
||||||
private final String permission;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of the permission check
|
|
||||||
*/
|
|
||||||
private final Tristate result;
|
|
||||||
|
|
||||||
public CheckData(CheckOrigin checkOrigin, String checkTarget, ImmutableContextSet checkContext, StackTraceElement[] checkTrace, String permission, Tristate result) {
|
|
||||||
this.checkOrigin = checkOrigin;
|
|
||||||
this.checkTarget = checkTarget;
|
this.checkTarget = checkTarget;
|
||||||
this.checkContext = checkContext;
|
this.checkContext = checkContext;
|
||||||
this.checkTrace = checkTrace;
|
this.checkTrace = checkTrace;
|
||||||
this.permission = permission;
|
|
||||||
this.result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckOrigin getCheckOrigin() {
|
|
||||||
return this.checkOrigin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCheckTarget() {
|
public String getCheckTarget() {
|
||||||
@ -95,29 +72,21 @@ public class CheckData {
|
|||||||
return this.checkTrace;
|
return this.checkTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermission() {
|
protected abstract void serializeTo(JObject object);
|
||||||
return this.permission;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tristate getResult() {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JObject formBaseJson() {
|
private JObject formBaseJson() {
|
||||||
return new JObject()
|
return new JObject()
|
||||||
.add("who", new JObject()
|
.add("who", new JObject()
|
||||||
.add("identifier", this.checkTarget)
|
.add("identifier", this.checkTarget)
|
||||||
)
|
)
|
||||||
.add("permission", this.permission)
|
|
||||||
.add("result", this.result.name().toLowerCase())
|
|
||||||
.add("origin", this.checkOrigin.name().toLowerCase())
|
|
||||||
.add("context", new JArray()
|
.add("context", new JArray()
|
||||||
.consume(arr -> {
|
.consume(arr -> {
|
||||||
for (Map.Entry<String, String> contextPair : this.checkContext.toSet()) {
|
for (Map.Entry<String, String> contextPair : this.checkContext.toSet()) {
|
||||||
arr.add(new JObject().add("key", contextPair.getKey()).add("value", contextPair.getValue()));
|
arr.add(new JObject().add("key", contextPair.getKey()).add("value", contextPair.getValue()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
|
.consume(this::serializeTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonObject toJson() {
|
public JsonObject toJson() {
|
@ -29,9 +29,9 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LookupSetting;
|
import me.lucko.luckperms.api.LookupSetting;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.model.HolderType;
|
import me.lucko.luckperms.common.model.HolderType;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
@ -50,7 +50,7 @@ public class NukkitCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
|
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
|||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.nukkit.LPNukkitPlugin;
|
import me.lucko.luckperms.nukkit.LPNukkitPlugin;
|
||||||
import me.lucko.luckperms.nukkit.model.PermissionDefault;
|
import me.lucko.luckperms.nukkit.model.PermissionDefault;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
return ts != Tristate.UNDEFINED || PermissionDefault.OP.getValue(isOp());
|
return ts != Tristate.UNDEFINED || PermissionDefault.OP.getValue(isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
if (ts != Tristate.UNDEFINED) {
|
if (ts != Tristate.UNDEFINED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK);
|
||||||
return ts != Tristate.UNDEFINED ? ts.asBoolean() : PermissionDefault.OP.getValue(isOp());
|
return ts != Tristate.UNDEFINED ? ts.asBoolean() : PermissionDefault.OP.getValue(isOp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public class LPPermissible extends PermissibleBase {
|
|||||||
throw new NullPointerException("permission");
|
throw new NullPointerException("permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
|
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK);
|
||||||
if (ts != Tristate.UNDEFINED) {
|
if (ts != Tristate.UNDEFINED) {
|
||||||
return ts.asBoolean();
|
return ts.asBoolean();
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ package me.lucko.luckperms.nukkit.model.permissible;
|
|||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.nukkit.model.dummy.DummyPermissibleBase;
|
import me.lucko.luckperms.nukkit.model.dummy.DummyPermissibleBase;
|
||||||
|
|
||||||
import cn.nukkit.permission.PermissibleBase;
|
import cn.nukkit.permission.PermissibleBase;
|
||||||
@ -70,8 +70,8 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
recalculatePermissions();
|
recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCheck(CheckOrigin origin, String permission, boolean result) {
|
private void logCheck(PermissionCheckEvent.Origin origin, String permission, boolean result) {
|
||||||
this.plugin.getVerboseHandler().offerCheckData(origin, this.name, ContextSet.empty(), permission, Tristate.fromBoolean(result));
|
this.plugin.getVerboseHandler().offerPermissionCheckEvent(origin, this.name, ContextSet.empty(), permission, Tristate.fromBoolean(result));
|
||||||
this.plugin.getPermissionRegistry().offer(permission);
|
this.plugin.getPermissionRegistry().offer(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.isPermissionSet(permission);
|
final boolean result = this.delegate.isPermissionSet(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission, result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class MonitoredPermissibleBase extends PermissibleBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final boolean result = this.delegate.hasPermission(permission);
|
final boolean result = this.delegate.hasPermission(permission);
|
||||||
logCheck(CheckOrigin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
logCheck(PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK, permission.getName(), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ package me.lucko.luckperms.sponge.calculators;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||||
@ -49,7 +49,7 @@ public class SpongeCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
|
@ -33,7 +33,8 @@ import me.lucko.luckperms.api.context.ContextSet;
|
|||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.graph.TraversalAlgorithm;
|
import me.lucko.luckperms.common.graph.TraversalAlgorithm;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
import me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph;
|
import me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraph;
|
||||||
import me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraphs;
|
import me.lucko.luckperms.sponge.service.inheritance.SubjectInheritanceGraphs;
|
||||||
@ -294,7 +295,7 @@ public abstract class CalculatedSubject implements LPSubject {
|
|||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(ImmutableContextSet contexts, String permission) {
|
public Tristate getPermissionValue(ImmutableContextSet contexts, String permission) {
|
||||||
Contexts lookupContexts = Contexts.of(contexts, Contexts.global().getSettings());
|
Contexts lookupContexts = Contexts.of(contexts, Contexts.global().getSettings());
|
||||||
return this.cachedData.getPermissionData(lookupContexts).getPermissionValue(permission, CheckOrigin.INTERNAL);
|
return this.cachedData.getPermissionData(lookupContexts).getPermissionValue(permission, PermissionCheckEvent.Origin.INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -310,8 +311,7 @@ public abstract class CalculatedSubject implements LPSubject {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(ImmutableContextSet contexts, String key) {
|
public Optional<String> getOption(ImmutableContextSet contexts, String key) {
|
||||||
Contexts lookupContexts = Contexts.of(contexts, Contexts.global().getSettings());
|
Contexts lookupContexts = Contexts.of(contexts, Contexts.global().getSettings());
|
||||||
Map<String, String> meta = this.cachedData.getMetaData(lookupContexts).getMeta();
|
return Optional.ofNullable(this.cachedData.getMetaData(lookupContexts).getMetaValue(key, MetaCheckEvent.Origin.PLATFORM_API));
|
||||||
return Optional.ofNullable(meta.get(key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,10 +31,10 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.caching.MetaContexts;
|
import me.lucko.luckperms.api.caching.MetaContexts;
|
||||||
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
import me.lucko.luckperms.api.metastacking.MetaStackDefinition;
|
||||||
import me.lucko.luckperms.common.caching.AbstractCachedData;
|
import me.lucko.luckperms.common.caching.AbstractCachedData;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
import me.lucko.luckperms.common.caching.type.MetaAccumulator;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition;
|
import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition;
|
||||||
import me.lucko.luckperms.common.metastacking.StandardStackElements;
|
import me.lucko.luckperms.common.metastacking.StandardStackElements;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
@ -60,8 +60,8 @@ public class SubjectCachedData extends AbstractCachedData implements CalculatorF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PermissionCalculatorMetadata getMetadataForContexts(Contexts contexts) {
|
protected CacheMetadata getMetadataForContexts(Contexts contexts) {
|
||||||
return PermissionCalculatorMetadata.of(null, this.subject.getParentCollection().getIdentifier() + "/" + this.subject.getIdentifier(), contexts.getContexts());
|
return new CacheMetadata(this, null, this.subject.getParentCollection().getIdentifier() + "/" + this.subject.getIdentifier(), contexts.getContexts());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,7 +95,7 @@ public class SubjectCachedData extends AbstractCachedData implements CalculatorF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
processors.add(new SpongeWildcardProcessor());
|
processors.add(new SpongeWildcardProcessor());
|
||||||
@ -105,6 +105,6 @@ public class SubjectCachedData extends AbstractCachedData implements CalculatorF
|
|||||||
processors.add(new FixedDefaultsProcessor(this.subject.getService(), contexts.getContexts().makeImmutable(), this.subject.getDefaults()));
|
processors.add(new FixedDefaultsProcessor(this.subject.getService(), contexts.getContexts().makeImmutable(), this.subject.getDefaults()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PermissionCalculator(this.plugin, metadata, processors.build());
|
return new PermissionCalculator(getPlugin(), metadata, processors.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import com.google.common.collect.ImmutableList;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.caching.MetaData;
|
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.caching.type.MetaCache;
|
||||||
import me.lucko.luckperms.common.graph.TraversalAlgorithm;
|
import me.lucko.luckperms.common.graph.TraversalAlgorithm;
|
||||||
import me.lucko.luckperms.common.inheritance.InheritanceGraph;
|
import me.lucko.luckperms.common.inheritance.InheritanceGraph;
|
||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
@ -38,7 +38,8 @@ import me.lucko.luckperms.common.model.NodeMapType;
|
|||||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||||
import me.lucko.luckperms.common.node.model.NodeTypes;
|
import me.lucko.luckperms.common.node.model.NodeTypes;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||||
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
import me.lucko.luckperms.sponge.model.SpongeGroup;
|
import me.lucko.luckperms.sponge.model.SpongeGroup;
|
||||||
import me.lucko.luckperms.sponge.service.LuckPermsService;
|
import me.lucko.luckperms.sponge.service.LuckPermsService;
|
||||||
@ -110,7 +111,7 @@ public abstract class HolderSubject<T extends PermissionHolder> implements LPSub
|
|||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(ImmutableContextSet contexts, String permission) {
|
public Tristate getPermissionValue(ImmutableContextSet contexts, String permission) {
|
||||||
Contexts lookupContexts = this.plugin.getContextManager().formContexts(contexts);
|
Contexts lookupContexts = this.plugin.getContextManager().formContexts(contexts);
|
||||||
return this.parent.getCachedData().getPermissionData(lookupContexts).getPermissionValue(permission, CheckOrigin.PLATFORM_LOOKUP_CHECK);
|
return this.parent.getCachedData().getPermissionData(lookupContexts).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,20 +138,22 @@ public abstract class HolderSubject<T extends PermissionHolder> implements LPSub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getOption(ImmutableContextSet contexts, String s) {
|
public Optional<String> getOption(ImmutableContextSet contexts, String s) {
|
||||||
MetaData data = this.parent.getCachedData().getMetaData(this.plugin.getContextManager().formContexts(contexts));
|
MetaCache data = this.parent.getCachedData().getMetaData(this.plugin.getContextManager().formContexts(contexts));
|
||||||
if (s.equalsIgnoreCase(NodeTypes.PREFIX_KEY)) {
|
if (s.equalsIgnoreCase(NodeTypes.PREFIX_KEY)) {
|
||||||
if (data.getPrefix() != null) {
|
String prefix = data.getPrefix(MetaCheckEvent.Origin.PLATFORM_API);
|
||||||
return Optional.of(data.getPrefix());
|
if (prefix != null) {
|
||||||
|
return Optional.of(prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.equalsIgnoreCase(NodeTypes.SUFFIX_KEY)) {
|
if (s.equalsIgnoreCase(NodeTypes.SUFFIX_KEY)) {
|
||||||
if (data.getSuffix() != null) {
|
String suffix = data.getSuffix(MetaCheckEvent.Origin.PLATFORM_API);
|
||||||
return Optional.of(data.getSuffix());
|
if (suffix != null) {
|
||||||
|
return Optional.of(suffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String val = data.getMeta().get(s);
|
String val = data.getMetaValue(s, MetaCheckEvent.Origin.PLATFORM_API);
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
return Optional.of(val);
|
return Optional.of(val);
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ package me.lucko.luckperms.velocity.calculators;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.common.caching.CacheMetadata;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
import me.lucko.luckperms.common.calculators.PermissionCalculator;
|
||||||
import me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata;
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.processors.MapProcessor;
|
import me.lucko.luckperms.common.processors.MapProcessor;
|
||||||
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
import me.lucko.luckperms.common.processors.PermissionProcessor;
|
||||||
@ -46,7 +46,7 @@ public class VelocityCalculatorFactory implements CalculatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
|
public PermissionCalculator build(Contexts contexts, CacheMetadata metadata) {
|
||||||
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
|
||||||
|
|
||||||
processors.add(new MapProcessor());
|
processors.add(new MapProcessor());
|
||||||
|
@ -35,7 +35,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
|
|
||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
import me.lucko.luckperms.velocity.LPVelocityPlugin;
|
import me.lucko.luckperms.velocity.LPVelocityPlugin;
|
||||||
import me.lucko.luckperms.velocity.service.CompatibilityUtil;
|
import me.lucko.luckperms.velocity.service.CompatibilityUtil;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public class MonitoringPermissionCheckListener {
|
|||||||
Tristate result = CompatibilityUtil.convertTristate(setting);
|
Tristate result = CompatibilityUtil.convertTristate(setting);
|
||||||
String name = "internal/" + this.name;
|
String name = "internal/" + this.name;
|
||||||
|
|
||||||
MonitoringPermissionCheckListener.this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, result);
|
MonitoringPermissionCheckListener.this.plugin.getVerboseHandler().offerPermissionCheckEvent(PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK, name, ContextSet.empty(), permission, result);
|
||||||
MonitoringPermissionCheckListener.this.plugin.getPermissionRegistry().offer(permission);
|
MonitoringPermissionCheckListener.this.plugin.getPermissionRegistry().offer(permission);
|
||||||
|
|
||||||
return setting;
|
return setting;
|
||||||
|
@ -34,7 +34,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
import me.lucko.luckperms.common.contexts.ContextsSupplier;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.verbose.CheckOrigin;
|
import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -57,6 +57,6 @@ public class PlayerPermissionProvider implements PermissionProvider, PermissionF
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Tristate getPermissionValue(@NonNull String permission) {
|
public @NonNull Tristate getPermissionValue(@NonNull String permission) {
|
||||||
return CompatibilityUtil.convertTristate(this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, CheckOrigin.PLATFORM_PERMISSION_CHECK));
|
return CompatibilityUtil.convertTristate(this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_PERMISSION_CHECK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user