Include note in verbose command-exec-as response if there were no matches (#2734)

This commit is contained in:
Luck 2020-12-14 15:11:49 +00:00
parent 7bc422c83f
commit e6a5cb06af
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 28 additions and 14 deletions

View File

@ -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;

View File

@ -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")

View File

@ -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();
}
}

View File

@ -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