p.getInventory().clear() Exeptions

Discussion in 'Plugin Development' started by MinesnHD, Apr 17, 2014.

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

    MinesnHD

    Sorry for my bad english but i am german :D.

    I want to clear the Inventory of a Player with p.getInventory().clear(); but i dont want to clear Arrows. How do i exept an item ?
     
  2. Offline

    DrEinsteinium

    Code:
    for(int i = 0; i < 27; i++)
    {
        if(player.getInventory.getStackInSlot(i) != null)
        {
             ItemStack item = player.getInventory().getStackInSlot(i);
             if(item.getType() != Material.ARROW)
                player.getInventory().clear(item.getType);
        }
    }
    
    I think that works for versions past 1.6.4, but don't quote me on that... the .clear method takes parameters.
     
  3. Offline

    MinesnHD



    Thank you :D - i am using it for GunGame - i dont want that VIP-Stuff, that is bought with real money, gets deleted :D Thank you - And the int i should run 36 times. The hotbar is also a line in your inventory :)
     
    DrEinsteinium likes this.
Thread Status:
Not open for further replies.

Share This Page