CommandDisabler

Discussion in 'Archived: Plugin Requests' started by KingGoldensPanda, Mar 22, 2014.

  1. Plugin category: Admin Tools

    Suggested name: CommandDisabler

    What I want: I would like a simple plugin that is easily customizable and can simply change the access denied message if a player uses a command he can't use. In game, I would also be able to disable the commands, or if needed just go into the config and do any of the items below. I really want an easy way to change what it says when commands are disabled, so through this plugin you could either go into the config or in game and change what the response is when a player does not have permission to a command.
    Note: When adding a command to disable, do add the / before the command to disable it. (If this is more difficult coding, then I don't need the / in front of a command, I would just need to know your choice through this!:)

    Ideas for commands:
    /cd list - Lists the disabled plugins
    /cd disable <command> - Disables a command
    /cd nopermission <quote> - Changes what the command says if you don't have permission.
    *For example* Player uses /plugins in response the command is denied and:
    Before: You do not have permission to use this command!
    After: Access Denied!
    /cd reload - reloads the plugin

    Ideas for permissions: commandDisabler.admin - ability to use the entire plugin.

    When I'd like it by: Thursday, March 27 or ASAP:confused:
     
  2. Offline

    TopTobster5

    I'm not sure if you can change the message sent to players if they don't have permission. Most of this is done from inside a plugin and can't be accessed by another plugin. The only way I can think to do this, is giving them access to all commands, and then cancelling them from inside the plugin, but this would require writing an entire permissions plugin.
     
  3. Offline

    AmbaDev

  4. Offline

    mazentheamazin

    TopTobster5 AmbaDev
    Incorrect, you would use PlayerCommandPreprocessEvent or something like that. This event runs at the 'precommand' phase, which allows you to cancel the event (i.e not run the command), send the player a message, or even override a command to a certain extent.

    EDIT: I'll do this plugin. KingGoldensPanda
     
  5. Offline

    mazentheamazin

    KingGoldensPanda
    Sorry it took so long, been doing a ton of things. Here it is, and I actually recorded myself doing it and speed it up. I am uploading it now, I'll post again when its done uploading ;).

    KingGoldensPanda
    Here's the sped up video clip:


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    TopTobster5

  7. Offline

    mazentheamazin

    TopTobster5
    Code:java
    1. String[] rawMessage = event.getMessage().split(" ");
    2. String permission;
    3. if(Bukkit.getPluginCommand(rawMessage[0].replaceAll("/", "")) != null) {
    4. permission = Bukkit.getPluginCommand(rawMessage[0].replaceAll("/", "")).getPermission();
    5. }else{
    6. permission = "";
    7. }
    8.  
    9. if(permission != null && !event.getPlayer().hasPermission(permission)) {
    10. event.setCancelled(true);
    11. event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("No permission message")));
    12. }

    This is all in PlayerCommandPreProcessEvent.
     
  8. Offline

    TopTobster5

    mazentheamazin Surly that relies on the command having the same permission?
     
  9. Offline

    timtower Administrator Administrator Moderator

    It will work if the command has the permissions setup right for the commands
     
  10. Offline

    TopTobster5

  11. Offline

    timtower Administrator Administrator Moderator

    Then based on inheritance: it would still work
     
  12. @mazenthamazin Thanks again for the plugin!!
    I did find one little glitch in the plugin though, if you type /cd nopermission <message> ; it only will do the first word that is typed such as: /cd nopermission Heh, not today! - it will only keep Heh, or not change it. This doesn't bother me to much since there is a config. Anyways, would you possibly think about adding two things to the plugin? The first is simply /cd reload - this reloads the plugin. The other item i really do need is a node to bypass. This could be default as op, or simply just another node. If it is another node, could you make it like commandDisabler.bypass so I could be able to see my plugin list or complete info on plugins with /?.
    Thanks, King~
     

Share This Page