Issue removing item from OffHand.

Discussion in 'Spigot Plugin Development' started by arsenalfcgunners, May 16, 2016.

  1. I use this to remove an item from a player's inventory:
    player.getInventory().remove(Material.SPECTRAL_ARROW);

    However, if the arrow is in the offhand slot it is not removed. Anyone know how to fix this?
     
  2. Get the item in the player's offhand and remove it then?...
     
  3. I tried that too. Idk if I did it wrong though. This is what I did:
    player.getInventory().removeItem(player.getInventory().getItemInOffHand());
     
  4. Try this:
    Code (Java):
    player.getInventory().getItemInOffHand().setType(Material.AIR);
     
  5. Didn't work. And just because I know someone will ask me this, yes it is getting called. I verified with a print statement.
     
    • Friendly Friendly x 1
  6. player.getInventory().setItemInOffHand(new ItemStack(Material.AIR, 1));
    It might be possible to just set it to null, not 100% sure rn.
     
    • Agree Agree x 2