Make verbose output more readable when a check is made against a lot of contexts

This commit is contained in:
Luck 2017-09-27 20:11:17 +01:00
parent f98aafb97c
commit ec75fdddb5
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -108,25 +108,21 @@ public class VerboseListener {
if (notify) {
StringBuilder msgContent = new StringBuilder();
msgContent.append("&a")
.append(data.getCheckTarget());
if (notifiedSender.isConsole()) {
msgContent.append("&7 - &8[&2")
msgContent.append("&8[&2")
.append(data.getCheckOrigin().getCode())
.append("&8] ");
}
msgContent.append("&7 - &a")
msgContent.append("&a")
.append(data.getCheckTarget())
.append("&7 - &a")
.append(data.getPermission())
.append("&7 - ")
.append(getTristateColor(data.getResult()))
.append(data.getResult().name().toLowerCase());
if (notifiedSender.isConsole()) {
msgContent.append("&7 - ").append(Util.contextSetToString(data.getCheckContext()));
}
if (notifiedSender.isConsole()) {
Message.VERBOSE_LOG.send(notifiedSender, msgContent.toString());
} else {
@ -145,7 +141,17 @@ public class VerboseListener {
for (StackTraceElement e : checkTrace) {
// start printing when we escape LP internals code
if (!printing && !e.getClassName().startsWith("me.lucko.luckperms.")) {
boolean shouldStartPrinting = !printing && (
(data.getCheckOrigin() == CheckOrigin.API || data.getCheckOrigin() == CheckOrigin.INTERNAL) || (
!e.getClassName().startsWith("me.lucko.luckperms.") &&
// all used within the checking impl somewhere
!e.getClassName().equals("java.util.concurrent.CompletableFuture") &&
!e.getClassName().startsWith("com.github.benmanes.caffeine") &&
!e.getClassName().equals("java.util.concurrent.ConcurrentHashMap")
)
);
if (shouldStartPrinting) {
printing = true;
}
@ -250,7 +256,17 @@ public class VerboseListener {
for (StackTraceElement e : checkTrace) {
// start printing when we escape LP internals code
if (!printing && !e.getClassName().startsWith("me.lucko.luckperms.")) {
boolean shouldStartPrinting = !printing && (
(c.getCheckOrigin() == CheckOrigin.API || c.getCheckOrigin() == CheckOrigin.INTERNAL) || (
!e.getClassName().startsWith("me.lucko.luckperms.") &&
// all used within the checking impl somewhere
!e.getClassName().equals("java.util.concurrent.CompletableFuture") &&
!e.getClassName().startsWith("com.github.benmanes.caffeine") &&
!e.getClassName().equals("java.util.concurrent.ConcurrentHashMap")
)
);
if (shouldStartPrinting) {
printing = true;
}