Custom no permission messages for (Plugin)Command

Discussion in 'Bukkit Preview' started by Wolvereness, Feb 10, 2012.

  1. Offline

    Wolvereness Bukkit Team Member

    An optional configuration node has been added to the commands section of the plugin.yml, and a method to the Command class. For each command, in addition to supplying a permission node, a custom message may be added that is displayed when a player attempts to use a command for which they do not have permission. Syntax is as shown:
    Code:
    commands:
      perform:
        description: Performs the action
        usage: /<command> (action)
        permission: myplugin.perform
        permission-message: You need <permission> to use perform
    Empty quotes for the permission-message indicates that no message should be sent.

    In addition to the message being definable in the plugin.yml of the jar, it may also be defined at runtime. This is an example that would set the permission-message like above:
    Code:
    public void onEnable() {
    this.getServer().getPluginCommand("perform").setPermissionMessage("You need <permission> to use perform");
    }
    Note that the code <permission> gets replaced with the appropriate permission node that is required for the command. The display for the player in this example would look like this:
    Code:
    You need myplugin.perform to use perform
     
    iKeirNez, Kohle and r3Fuze like this.

Share This Page