Solved Interact Event With Heads {URGENT}

Discussion in 'Plugin Development' started by WingedMLGPro, Apr 16, 2015.

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

    WingedMLGPro

    Hey Everyone!
    I am trying to make a interact event with a Player Head,
    Here is my Code:
    Code:
    public class PlayerInfoInvListener implements Listener {
    
        @EventHandler
        public void onInteract(PlayerInteractEvent e){
            Player p = e.getPlayer();
            Action a = e.getAction();
            if (a==Action.RIGHT_CLICK_AIR || a==Action.RIGHT_CLICK_BLOCK){
                ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
                if (p.getItemInHand()!=null && p.getItemInHand()==item) {
                    p.openInventory(PInfoInv.getPInfo());
                    p.sendMessage("ยง6Opening Player Info...");
                }
            }
        }
    }
    It doesnt work for some reason.
    Plz help, this is kinda urgent!
    Thanks,
    WingedMLGPro
     
  2. Offline

    nj2miami

    You should probably define "doesnt work" a little better. Troubleshoot your code, put in some debug code and figure out where your problem is coming from specifically. I'll give a hint, I'd be willing to bet, it is here:

     
    mine-care likes this.
  3. Offline

    mine-care

    @nj2miami totally agree! umm a hint (too): Take a look at object comparason.
     
  4. Offline

    FisheyLP

    Don't compare objects with ==, use .equals
     
  5. Offline

    WingedMLGPro

    @FisheyLP Would it work with comparing the display name??
     
  6. Offline

    nverdier

  7. Offline

    WingedMLGPro

    NVM, i fixed it myself :D
     
Thread Status:
Not open for further replies.

Share This Page