From e6a5cb06afc7e53b8634545f408e310b52e62d45 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 14 Dec 2020 15:11:49 +0000 Subject: [PATCH] Include note in verbose command-exec-as response if there were no matches (#2734) --- .../common/commands/misc/VerboseCommand.java | 8 ++++++-- .../lucko/luckperms/common/locale/Message.java | 15 +++++++++++++++ .../common/verbose/VerboseListener.java | 16 ++++------------ .../src/main/resources/luckperms_en.properties | 3 +++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java index df6759a0d..2c8d8f793 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/VerboseCommand.java @@ -99,9 +99,13 @@ public class VerboseCommand extends SingleCommand { verboseHandler.registerListener(sender, VerboseFilter.acceptAll(), true); executor.performCommand(command); - verboseHandler.unregisterListener(sender); - Message.VERBOSE_OFF_COMMAND.send(sender); + VerboseListener listener = verboseHandler.unregisterListener(sender); + if (listener.getMatchedCount() == 0) { + Message.VERBOSE_OFF_COMMAND_NO_CHECKS.send(sender); + } else { + Message.VERBOSE_OFF_COMMAND.send(sender); + } }); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index c2027ee6c..e87e44913 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -586,6 +586,21 @@ public interface Message { .append(FULL_STOP) ); + Args0 VERBOSE_OFF_COMMAND_NO_CHECKS = () -> join(newline(), + // &bThe command execution completed, but no permission checks were made. + // &7This might be because the plugin runs commands in the background (async). You can still use verbose manually to detect checks made like this. + prefixed(translatable() + .key("luckperms.command.verbose.command.no-checks") + .color(AQUA) + .append(FULL_STOP)), + prefixed(text() + .color(GRAY) + .append(translatable("luckperms.command.verbose.command.possibly-async")) + .append(FULL_STOP) + .append(translatable("luckperms.command.verbose.command.try-again-manually")) + .append(FULL_STOP)) + ); + Args0 VERBOSE_RECORDING_ON = () -> prefixed(translatable() // "&bVerbose recording &aenabled &bfor checks matching &aANY&b." .key("luckperms.command.verbose.enabled-recording") 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 a0fada13e..5ebd77971 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 @@ -47,7 +47,6 @@ import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; import net.luckperms.api.query.QueryMode; -import net.luckperms.api.util.Tristate; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -323,18 +322,11 @@ public class VerboseListener { return bytebin.postContent(bytesOut.toByteArray(), AbstractHttpClient.JSON_TYPE, false).key(); } - private static String getTristateColor(Tristate tristate) { - switch (tristate) { - case TRUE: - return "&2"; - case FALSE: - return "&c"; - default: - return "&7"; - } - } - public Sender getNotifiedSender() { return this.notifiedSender; } + + public int getMatchedCount() { + return this.matchedCounter.get(); + } } diff --git a/common/src/main/resources/luckperms_en.properties b/common/src/main/resources/luckperms_en.properties index d5600daec..e54be48dd 100644 --- a/common/src/main/resources/luckperms_en.properties +++ b/common/src/main/resources/luckperms_en.properties @@ -107,6 +107,9 @@ luckperms.command.verbose.enabled=Verbose logging {0} for checks matching {1} luckperms.command.verbose.command-exec=Forcing {0} to execute command {1} and reporting all checks made... luckperms.command.verbose.off=Verbose logging {0} luckperms.command.verbose.command-exec-complete=Command execution complete +luckperms.command.verbose.command.no-checks=The command execution completed, but no permission checks were made +luckperms.command.verbose.command.possibly-async=This might be because the plugin runs commands in the background (async) +luckperms.command.verbose.command.try-again-manually=You can still use verbose manually to detect checks made like this luckperms.command.verbose.enabled-recording=Verbose recording {0} for checks matching {1} luckperms.command.verbose.uploading=Verbose logging {0}, uploading results... luckperms.command.verbose.url=Verbose results URL