mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Include processor & cause in verbose hover message
This commit is contained in:
parent
287cc308d6
commit
8773ec07ab
@ -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,12 +220,17 @@ 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();
|
||||||
for (String value : values) {
|
if (!values.isEmpty()) {
|
||||||
verboseHandler.offerMetaCheckEvent(this.origin, MetaCache.this.metadata.getObjectName(), MetaCache.this.metadata.getContext(), key, String.valueOf(value));
|
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;
|
return values;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user