Simple way to drop player inventory?

Discussion in 'Bukkit Help' started by redloved, Feb 2, 2011.

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

    redloved

    Hi,

    I looked for this feature but didn't find: is there a simple way (unique method?) to drop the total inventory of a player. (like when he dies?).

    Thank you
     
  2. Offline

    Pezmantbh

    You can clear a players inventory by deleting his .dat file in the /world/players/ folder. This is permanent.

    As far as I know, a players stuff drops when he dies anyway - Whats the problem?


    Thanks :)
     
  3. Offline

    redloved

    In fact, I wish to drop inventory on the floor (including clothes) without kill the player
     
  4. Offline

    Timberjaw

    Someone may have a better way, but here's how I do it:

    Code:
    ItemStack[] items = p.getInventory().getContents();
    for(int i = 0; i < items.length; i++)
    {
        ItemStack is = items[i];
        if(is != null && is.getAmount() > 0)
        {
            p.getWorld().dropItemNaturally(p.getLocation(), is);
        }
    }
    
    // Clear player's inventory
    p.getInventory().clear();
     
  5. Offline

    redloved

    Thank you, since I don't have better way, I'll use your's.
     
  6. Offline

    ledhead900

    Wait wait... It hink your in the wrong thread mate.. you should be over in the Plugin development thread.
     
  7. Offline

    Pezmantbh

    I am confused too :p
     
Thread Status:
Not open for further replies.

Share This Page