I want it to return with the message "You don't have permission to execute this command!" if they don't have permission, but it returns with this, http://gyazo.com/7ee4a7baa1517889fda76770ed9585de, here's my code, Code:java if(commandLabel.equalsIgnoreCase("hi")) { if(player.hasPermission("hi.hi")){ } else { player.sendMessage(ChatColor.RED + "You don't have permission to execute this command!"); } } return false; }}
iiHeroo iiHeroo Bukkit will automatically send that message if you have it enabled in the plugin.yml. Make sure your plugin.yml looks something like this Code: name: {$PluginName} main: {$PackageName}.{$MainClass} version: {$VersionNumber} commands: hi: description: This says hi. usage: /<command> permission: hi.hi permission-message: You don't have <permission> Change the plugin.yml line "permission-message" to what you want it to say if they do not have permission. The one above will say "You don't have hi.hi" iiHeroo Forgot to tag you EDIT by Moderator: merged posts, please use the edit button instead of double posting.
iiHeroo Yup. Bukkit has implemented a lot of nice things like this. I edited my original post to explain it a bit more.
Is there a way to still have "children" if I create a permission outside the plugin.yml ? If so, how ?
iiHeroo Yea, if I'm understanding you're question correctly it is still possible. You can always have permissions outside of the plugin.yml as bukkit will always check if there is any permission node in the plugin.yml or the code before doing the command.
okay thanks ! If you could give me an example of the code, you don't need to if you don't want to, I can always find out somehow. But thanks for the help !
iiHeroo Code:java if(player.hasPermission(lol.hi)){if(cmd.getName().equalsIgnorecase("troll")){ player.setHealth(0);}} What this does is it first checks if the player has permission to do the command. If they do not it will tell them the "I'm sorry but you do not have permission to use this command, if you beleive this is an error contact an admin" if they do have permission it will kill them
iiHeroo That's what I did. Doing if(player.hasPermission(some.permissionhere)){} is creating a new permission for your plugin
Random thought, did you register your permissions within the plugin.yml? Code: permissions: example.*: default: op children: example.node: true example.admin: true
Can you include your entire onCommand then? Edit: Don't bind a permission to your command within the plugin.yml. Just do the checking within the plugin yourself, register the permissions only in the plugin.yml, then you can use the message.
On mobile so can't use code option here's onCommand code public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)