Skip to content

Commit

Permalink
Include note in verbose command-exec-as response if there were no mat…
Browse files Browse the repository at this point in the history
…ches (#2734)
  • Loading branch information
lucko committed Dec 14, 2020
1 parent 7bc422c commit e6a5cb0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
Expand Up @@ -99,9 +99,13 @@ public CommandResult execute(LuckPermsPlugin plugin, Sender sender, ArgumentList

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;
Expand Down
15 changes: 15 additions & 0 deletions common/src/main/java/me/lucko/luckperms/common/locale/Message.java
Expand Up @@ -586,6 +586,21 @@ static TextComponent prefixed(ComponentLike component) {
.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")
Expand Down
Expand Up @@ -47,7 +47,6 @@
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;
Expand Down Expand Up @@ -323,18 +322,11 @@ public String uploadPasteData(BytebinClient bytebin) throws IOException, Unsucce
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();
}
}
3 changes: 3 additions & 0 deletions common/src/main/resources/luckperms_en.properties
Expand Up @@ -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
Expand Down

0 comments on commit e6a5cb0

Please sign in to comment.