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

View File

@ -28,6 +28,7 @@ package me.lucko.luckperms.common.verbose;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import me.lucko.luckperms.api.Tristate; 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.CommandManager;
import me.lucko.luckperms.common.command.utils.MessageUtils; import me.lucko.luckperms.common.command.utils.MessageUtils;
import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.locale.message.Message;
@ -190,6 +191,14 @@ public class VerboseListener {
PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event; PermissionCheckEvent permissionEvent = (PermissionCheckEvent) event;
hover.add("&aType: &2permission"); hover.add("&aType: &2permission");
hover.add("&bOrigin: &2" + permissionEvent.getOrigin().name()); 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) { if (event instanceof MetaCheckEvent) {
MetaCheckEvent metaEvent = (MetaCheckEvent) event; MetaCheckEvent metaEvent = (MetaCheckEvent) event;