diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java index ffaf2a32b..fa1dae8cc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/message/Message.java @@ -447,7 +447,7 @@ public enum Message { LOG_EXPORT_NOT_WRITABLE("&cError: File &4{}&c is not writable.", true), LOG_EXPORT_EMPTY("&cThe log is empty and therefore cannot be exported.", true), LOG_EXPORT_FAILURE("&cAn unexpected error occured whilst writing to the file.", true), - LOG_EXPORT_SUCCESS("&aSuccessfully exported the log to &b{}&a.", true), + LOG_EXPORT_SUCCESS("&aSuccessfully exported to &b{}&a.", true), IMPORT_ALREADY_RUNNING("&cAnother import process is already running. Please wait for it to finish and try again.", true), EXPORT_ALREADY_RUNNING("&cAnother export process is already running. Please wait for it to finish and try again.", true), diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java index 7630b1ff5..c8294cb37 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseHandler.java @@ -81,9 +81,10 @@ public class VerboseHandler extends RepeatingTask { } StackTraceElement[] trace = new Exception().getStackTrace(); + String thread = Thread.currentThread().getName(); // add the check data to a queue to be processed later. - this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, trace, permission, result)); + this.queue.offer(new PermissionCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, permission, result)); } /** @@ -105,9 +106,10 @@ public class VerboseHandler extends RepeatingTask { } StackTraceElement[] trace = new Exception().getStackTrace(); + String thread = Thread.currentThread().getName(); // add the check data to a queue to be processed later. - this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, trace, key, result)); + this.queue.offer(new MetaCheckEvent(origin, checkTarget, checkQueryOptions, trace, thread, key, result)); } /** diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java index 2f81129a1..fd91c2a27 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java @@ -45,8 +45,8 @@ import me.lucko.luckperms.common.web.BytebinClient; import net.kyori.text.TextComponent; import net.kyori.text.event.HoverEvent; -import net.luckperms.api.util.Tristate; import net.luckperms.api.query.QueryMode; +import net.luckperms.api.util.Tristate; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -217,6 +217,7 @@ public class VerboseListener { if (event.getCheckQueryOptions().mode() == QueryMode.CONTEXTUAL) { hover.add("&bContext: &r" + MessageUtils.contextSetToString(this.notifiedSender.getPlugin().getLocaleManager(), event.getCheckQueryOptions().context())); } + hover.add("&bThread: &r" + event.getCheckThread()); hover.add("&bTrace: &r"); Consumer printer = StackTracePrinter.elementToString(str -> hover.add("&7" + str)); diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/event/MetaCheckEvent.java b/common/src/main/java/me/lucko/luckperms/common/verbose/event/MetaCheckEvent.java index c63ed7e7b..ccfc90231 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/event/MetaCheckEvent.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/event/MetaCheckEvent.java @@ -46,8 +46,8 @@ public class MetaCheckEvent extends VerboseEvent { */ private final String result; - public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String key, String result) { - super(checkTarget, checkQueryOptions, checkTrace); + public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread, String key, String result) { + super(checkTarget, checkQueryOptions, checkTrace, checkThread); this.origin = origin; this.key = key; this.result = result; diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/event/PermissionCheckEvent.java b/common/src/main/java/me/lucko/luckperms/common/verbose/event/PermissionCheckEvent.java index cacd4b611..9971ec7b7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/event/PermissionCheckEvent.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/event/PermissionCheckEvent.java @@ -47,8 +47,8 @@ public class PermissionCheckEvent extends VerboseEvent { */ private final TristateResult result; - public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String permission, TristateResult result) { - super(checkTarget, checkQueryOptions, checkTrace); + public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread, String permission, TristateResult result) { + super(checkTarget, checkQueryOptions, checkTrace, checkThread); this.origin = origin; this.permission = permission; this.result = result; diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java b/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java index e5d7e26b0..3e8ee9e25 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java @@ -58,10 +58,16 @@ public abstract class VerboseEvent implements VariableEvaluator { */ private final StackTraceElement[] checkTrace; - protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace) { + /** + * The name of the thread where the check took place + */ + private final String checkThread; + + protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread) { this.checkTarget = checkTarget; this.checkQueryOptions = checkQueryOptions; this.checkTrace = checkTrace; + this.checkThread = checkThread; } public String getCheckTarget() { @@ -76,9 +82,13 @@ public abstract class VerboseEvent implements VariableEvaluator { return this.checkTrace; } + public String getCheckThread() { + return this.checkThread; + } + protected abstract void serializeTo(JObject object); - private JObject formBaseJson() { + public JsonObject toJson(StackTracePrinter tracePrinter) { return new JObject() .add("who", new JObject() .add("identifier", this.checkTarget) @@ -95,15 +105,6 @@ public abstract class VerboseEvent implements VariableEvaluator { ); } }) - .consume(this::serializeTo); - } - - public JsonObject toJson() { - return formBaseJson().toJson(); - } - - public JsonObject toJson(StackTracePrinter tracePrinter) { - return formBaseJson() .add("trace", new JArray() .consume(arr -> { int overflow = tracePrinter.process(this.checkTrace, StackTracePrinter.elementToString(arr::add)); @@ -112,6 +113,8 @@ public abstract class VerboseEvent implements VariableEvaluator { } }) ) + .add("thread", this.checkThread) + .consume(this::serializeTo) .toJson(); } }