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
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.
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
mazentheamazin Ok Sweet!! My email is [email protected] if you needed me for a quick question on the plugin. Thanks again! -King
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.
TopTobster5 Code:java String[] rawMessage = event.getMessage().split(" "); String permission; if(Bukkit.getPluginCommand(rawMessage[0].replaceAll("/", "")) != null) { permission = Bukkit.getPluginCommand(rawMessage[0].replaceAll("/", "")).getPermission(); }else{ permission = ""; } if(permission != null && !event.getPlayer().hasPermission(permission)) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("No permission message"))); } This is all in PlayerCommandPreProcessEvent.
@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~