player.hasPermission problems

Discussion in 'Plugin Development' started by billman555555, Sep 27, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    billman555555

    Hi,
    i am making a custom plugin but need to check if the player has a permission.
    Here is my code:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. Player player = (Player) sender;
    3. if(cmd.getName().equalsIgnoreCase("fly")) {
    4. if (player.hasPermission("billcraft.vip")) {
    5. if (player.getAllowFlight()) {
    6. player.setAllowFlight(false);
    7. player.sendMessage("§eFlying has been disabled.");
    8. } else {
    9. player.setAllowFlight(true);
    10. player.sendMessage("§eFlying has been enabled.");
    11. }
    12. } else {
    13. player.sendMessage("§cYou cant do this!");
    14. }
    15. return true;
    16. }
    17. return false;
    18. }

    Any 1 know what my problem is?
     
  2. Offline

    waicool20

    What exactly is your problem?
    Try and check your plugin.yml
    and before you cast player check if the sender is a player cuz if the console sent this command you would get a pain of errors
     
  3. Offline

    billman555555

    waicool20
    I think it might be how i setup PermissionsEx,
    The default rank dosnt have billcraft.vip and can still use /fly.
    Also Any 1 know how to setup ladders (eg. /promote user ladder)
     
  4. Offline

    ThunderWaffeMC

    Add the permission to your plugin.yml and set default to op.
     
Thread Status:
Not open for further replies.

Share This Page