Solved Getting skull name

Discussion in 'Plugin Development' started by Asgernohns, Mar 21, 2014.

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

    Asgernohns

    hello

    I am developing a plugin and i got a problem that i can't get rid of.
    I need to get the skull name that the player has in the hand, and then check if that player is in a hashset. anybody that know how to do this?

    Code: PlayerInteractEvent
    Code:java
    1. public void onPlayerInteract(PlayerInteractEvent e){
    2. Player p = e.getPlayer();
    3. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
    4. if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST){
    5. Sign sign = (Sign) e.getClickedBlock().getState();
    6. e.setCancelled(true);
    7. if(sign.getLine(0).equalsIgnoreCase("["+ChatColor.GOLD+"Bounty"+ChatColor.BLACK+"]")){
    8. ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
    9. if(p.getInventory().getItemInHand() == skull){
    10. String pName = p.getName();
    11. SkullMeta meta = (SkullMeta) skull.getItemMeta();
    12.  
    13. if(meta.hasOwner()){
    14. String skullmeta = meta.getOwner();
    15. if(bountyHeads.contains(skullmeta)){
    16. p.sendMessage(ChatColor.BLACK+"["+ChatColor.GOLD+"HeadBounty"+ChatColor.BLACK+"]"+ChatColor.GREEN+" "+bountyPrice.get(pName)+"$ Has been added to your wallet!");
    17. econ.depositPlayer(pName, bountyPrice.get(pName));
    18. p.getInventory().remove(Material.SKULL_ITEM);
    19.  
    20. bountyPrice.remove(p.getName());
    21.  
    22.  
    23. }
    24. }
    25. }
    26. }
    27. }
    28. }
    29. }
     
  2. Offline

    drtshock

    Try throwing in some debug code to see which check is holding you up.

    Instead of checking player's iteminhand == new itemstack, try getting the type of the players held item and checking that against the Material.SKULL_ITEM
     
  3. Offline

    Asgernohns

    drtshock then i can't check if the SKULL_ITEM is a player head?
     
  4. Offline

    drtshock

    That's what a skull item is ;o
     
  5. Offline

    Asgernohns

Thread Status:
Not open for further replies.

Share This Page