Help with checking if they dont have a permission node?

Discussion in 'Plugin Development' started by thomasoo, Aug 2, 2012.

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

    thomasoo

    I have been trying to make a plugin where they got multiple items to select with and when one gets used they can't use any of the other ones but i ran into problems with using !haspermission

    like so
    (using PlayerInteractEvent)

    Code:
        final Player p = event.getPlayer();
          /***********************COMBAT***COMBAT***COMBAT*************************/
              if (p.getItemInHand().getType().equals(Material.WOOD_SWORD) && !p.hasPermission("Rpg.combat")) {
                  p.sendMessage("You select swords");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.swords");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.combat");
                  }
             
              if (p.getItemInHand().getType().equals(Material.ARROW) && !p.hasPermission("Rpg.combat")) {
                  p.sendMessage("You select Archery");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.archery");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.combat");
                  }
             
              if (p.getItemInHand().getType().equals(Material.WOOD_HOE)) && !p.hasPermission("Rpg.combat")) {
                  p.sendMessage("You select Axes");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.axes");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.combat");
                  }
             
              if (p.getItemInHand().getType().equals(Material.LEATHER_HELMET) && !p.hasPermission("Rpg.combat")) {
                  p.sendMessage("You select Unarmed");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.unarmed");
                  Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " + p.getDisplayName() + " -Rpg.combat");
                  }
    Anyone know what is causing it to not work?`the code works without the !p.haspermission
     
  2. Offline

    Milkywayz

    Using:
    PHP:
    return;
    At the end of your if statements will likely solve this, give it a try and reply the results.
    Example:
    PHP:
    if (p.getItemInHand().getType().equals(Material.LEATHER_HELMET) && !p.hasPermission("Combat")) {
                  
    p.sendMessage("You select Unarmed");
                  
    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " p.getDisplayName() + " -Rpg.unarmed");
                  
    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manuaddp " p.getDisplayName() + " -Rpg.combat");
                  return;
                  }
     
  3. Offline

    thomasoo

    Okay thanks, that seemed to do the trick.
    found out i had to change displayname to name as well due to color codes xD

    /thread
     
Thread Status:
Not open for further replies.

Share This Page