From 4199b0ca64a63c6e336ed7a9101b37241c7e0449 Mon Sep 17 00:00:00 2001 From: mciolkosz Date: Sat, 17 Oct 2020 18:12:01 +1100 Subject: [PATCH] #2977: Added availability to set custom permission messages on commands. --- api/src/main/java/net/md_5/bungee/api/plugin/Command.java | 4 ++++ .../main/java/net/md_5/bungee/api/plugin/PluginManager.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Command.java b/api/src/main/java/net/md_5/bungee/api/plugin/Command.java index eba3040a..b4566327 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/Command.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/Command.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import lombok.AccessLevel; import lombok.Data; import lombok.RequiredArgsConstructor; +import lombok.Setter; import net.md_5.bungee.api.CommandSender; /** @@ -17,6 +18,8 @@ public abstract class Command private final String name; private final String permission; private final String[] aliases; + @Setter(AccessLevel.PROTECTED) + private String permissionMessage; /** * Construct a new command with no permissions or aliases. @@ -42,6 +45,7 @@ public abstract class Command this.name = name; this.permission = permission; this.aliases = aliases; + this.permissionMessage = null; } /** diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index e7cd8a27..b4da08dc 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -172,7 +172,7 @@ public final class PluginManager { if ( tabResults == null ) { - sender.sendMessage( proxy.getTranslation( "no_permission" ) ); + sender.sendMessage( ( command.getPermissionMessage() == null ) ? proxy.getTranslation( "no_permission" ) : command.getPermissionMessage() ); } return true; }