Can't remove potion?

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

Thread Status:
Not open for further replies.
  1. I have a problem:
    I made a mana potion and I checked for playerInteractEvent for rightclick. When it fires it should remove the potion, but it doesn't. It gives the exp though. This is the code:
    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e) {
    3. if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.RIGHT_CLICK_AIR) {
    4. if (e.getPlayer().getItemInHand().equals(ManaPot)) {
    5. e.getPlayer().getInventory().remove(e.getItem());
    6. e.getPlayer().setExp(1F);
    7. }
    8. }
    9. }


    Here's the ManaPot:
    Code:java
    1. public Potion ManaPot1 = new Potion(PotionType.NIGHT_VISION);
    2. public ItemStack ManaPot = ManaPot1.toItemStack(1);
    3.  
    4. onEnable() {
    5. getServer().getPluginManager().registerEvents(this, this);
    6. ItemMeta im = ManaPot.getItemMeta();
    7. im.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Mana Potion");
    8. ManaPot.setItemMeta(im);
    9. }


    So yea...
     
  2. Offline

    Retherz_

    Register events, use eventhandler
     
  3. I did, forget to add it on the post :p
     
  4. Offline

    Janmm14

  5. Offline

    nuclearmissile

    Why not just use player.getInventory().removeItem(player.getInventory().getItemInHand()); ?
     
  6. Doesn't work either D:
    Just doesn't remove the potion out of the inventory. Gives the exp though.
     
Thread Status:
Not open for further replies.

Share This Page