[SOLVED] Item add/removal from inventory :)

Discussion in 'Plugin Development' started by NeoSilky, Sep 18, 2011.

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

    NeoSilky

    Hi, im making quite a useful plugin and i need to add and remove items from a players inventory. This is probably a easy solution, but i can't figure it. My code is:

    Code:
    		if(player.getInventory().contains(Material.STICK, 1) && player.getInventory().contains(Material.WOOD, 2)){
    		ItemStack remove1 = new ItemStack(Material.STICK, 1);
    		ItemStack remove2 = new ItemStack(Material.WOOD, 2);
    		ItemStack add3 = new ItemStack(Material.WOOD_SWORD);
    		ci.removeItem(remove1);
    		ci.removeItem(remove2);
    		ci.addItem(add3);
    
    It removes the items, but when it adds the sword, left clicking is okay, but it goes if you right click with it, any ideaS? :)
     
  2. new ItemStack(Material.WOOD_SWORD, 1)
    The default amount is 0 for whatever reason, so you have to manually set it to 1.
     
  3. Offline

    NeoSilky

    God, i was so careful to get it all right, if i would of checked my code, i would of noticed it! Damn :L what a waste of a post :L
     
Thread Status:
Not open for further replies.

Share This Page