Event not working..?

Discussion in 'Plugin Development' started by HyrulesLegend, Oct 26, 2013.

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

    HyrulesLegend

    The event is registered, but for some reason it's not giving me an XP bottle when I kill the player.
    Code:
    Code:java
    1. @EventHandler
    2. public void onPlayerKill(PlayerDeathEvent e) {
    3. Player p = e.getEntity().getKiller();
    4. ItemStack xp = new ItemStack(Material.EXP_BOTTLE, 1);
    5. ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
    6.  
    7.  
    8.  
    9. LeatherArmorMeta bootsm = (LeatherArmorMeta) boots.getItemMeta();
    10. bootsm.setColor(Color.YELLOW);
    11. boots.setItemMeta(bootsm);
    12. if(p.getInventory().getBoots().getType().equals(boots)){
    13. p.sendMessage(ChatColor.RED + "Test!");
    14. p.getInventory().addItem(xp);
    15. }
    16. }
    17. }
    18.  

    (I have a separate class to give them the exact same boots, and put them on their boots slot.)
     
  2. Offline

    MayoDwarf

    getType() method is for materials, not itemstacks. boots in your code is a ItemStack tho. So change it to p.getInventory().getBoots().equals(boots)

    Max_The_Link_Fan
     
    Max_The_Link_Fan likes this.
  3. Offline

    HyrulesLegend

    MayoDwarf For some reason, it only gives us the XP bottle half the time..? Nevermind.
     
  4. Offline

    MayoDwarf

    Lol What did you screw up and then realize was wrong :p
     
Thread Status:
Not open for further replies.

Share This Page