Include processor & cause in verbose hover message

This commit is contained in:
Luck 2019-02-19 23:30:11 +00:00
parent 287cc308d6
commit 8773ec07ab
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 18 additions and 2 deletions

View File

@ -46,6 +46,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.SortedMap;
/**
@ -194,6 +195,7 @@ public class MetaCache implements MetaData {
@Override
public String get(Object key) {
Objects.requireNonNull(key, "key");
String value = super.get(key);
// log this meta lookup to the verbose handler
@ -218,12 +220,17 @@ public class MetaCache implements MetaData {
@Override
public List<String> get(String key) {
Objects.requireNonNull(key, "key");
List<String> values = super.get(key);
// log this meta lookup to the verbose handler
VerboseHandler verboseHandler = MetaCache.this.metadata.getParentContainer().getPlugin().getVerboseHandler();
for (String value : values) {
verboseHandler.offerMetaCheckEvent(this.origin, MetaCache.this.metadata.getObjectName(), MetaCache.this.metadata.getContext(), key, String.valueOf(value));
if (!values.isEmpty()) {
for (String value : values) {
verboseHandler.offerMetaCheckEvent(this.origin, MetaCache.this.metadata.getObjectName(), MetaCache.this.metadata.getContext(), key, String.valueOf(value));
}
} else {
verboseHandler.offerMetaCheckEvent(this.origin, MetaCache.this.metadata.getObjectName(), MetaCache.this.metadata.getContext(), key, "null");
}
return values;

View File

@ -28,6 +28,7 @@ package me.lucko.luckperms.common.verbose;
import com.google.gson.JsonObject;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.common.calculator.result.TristateResult;
import me.lucko.luckperms.common.command.CommandManager;
import me.lucko.luckperms.common.command.utils.MessageUtils;
import me.lucko.luckperms.common.locale.message.Message;
@ -190,6 +191,14 @@ public class VerboseListener {
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
hover.add("&aType: &2permission");
hover.add("&bOrigin: &2" + permissionEvent.getOrigin().name());
TristateResult result = permissionEvent.getResult();
if (result.processorClass() != null) {
hover.add("&bProcessor: &2" + result.processorClass().getName());
}
if (result.cause() != null) {
hover.add("&bCause: &2" + result.cause());
}
}
if (event instanceof MetaCheckEvent) {
MetaCheckEvent metaEvent = (MetaCheckEvent) event;