diff --git a/src/main/java/net/jadedmc/commandblockerpro/commands/DummyCommand.java b/src/main/java/net/jadedmc/commandblockerpro/commands/DummyCommand.java index c787ef3..d7b23c4 100644 --- a/src/main/java/net/jadedmc/commandblockerpro/commands/DummyCommand.java +++ b/src/main/java/net/jadedmc/commandblockerpro/commands/DummyCommand.java @@ -55,7 +55,9 @@ public DummyCommand(@NotNull String name, @NotNull final String blockMessage) { */ @Override public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) { - ChatUtils.chat(commandSender, blockMessage); + // Replaces the {command} placeholder with the command that was run (without the leading '/'). + final String message = blockMessage.replace("{command}", s); + ChatUtils.chat(commandSender, message); return true; } } \ No newline at end of file diff --git a/src/main/java/net/jadedmc/commandblockerpro/listeners/PlayerCommandPreprocessListener.java b/src/main/java/net/jadedmc/commandblockerpro/listeners/PlayerCommandPreprocessListener.java index c0f98f1..aa07d59 100644 --- a/src/main/java/net/jadedmc/commandblockerpro/listeners/PlayerCommandPreprocessListener.java +++ b/src/main/java/net/jadedmc/commandblockerpro/listeners/PlayerCommandPreprocessListener.java @@ -75,7 +75,9 @@ public void onCommandSend(@NotNull final PlayerCommandPreprocessEvent event) { // Display the block message is the rule has one. if(rule.hasBlockMessage()) { - ChatUtils.chat(player, rule.getBlockMessage()); + // Replaces the {command} placeholder with the command that was blocked (without the leading '/'). + final String blockMessage = rule.getBlockMessage().replace("{command}", command.replaceFirst("^/", "")); + ChatUtils.chat(player, blockMessage); } // Play the block sound if the rule has one. diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a0c5a5a..a8a2bb8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,6 +12,7 @@ # The message sent to a player when a command is blocked. # Can be overridden by adding this setting to each rule. # Supports legacy color codes, but you should be using MiniMessage instead (https://docs.advntr.dev/minimessage/format.html). +# Supports the {command} placeholder, which is replaced with the command that was blocked, without the leading '/' (ex: help). blockMessage: "Error ยป You do not have access to that command." # Defines different rules that can be enforced when determining when to block or hide commands.