I am making a Bukkit plugin that takes the player to a "FunZone" and allows them to do just about anything. I don't want data transferred between the two worlds. So far I have got most everything stopped. Here's the problem code:
Integer normInvSize = player.getInventory().getSize();
Integer i = 0;
for (i=0; i<normInvSize; i++) {
ItemStack item = player.getInventory().getItem(i);
pConfig.set(player.getWorld().getName()+"Inv."+i.toString()+".amount", item.getAmount());
Short durab = item.getDurability();
pConfig.set(player.getWorld().getName()+"Inv."+i.toString()+".durabillity", durab.intValue());
pConfig.set(player.getWorld().getName()+"Inv."+i.toString()+".type", item.getTypeId());
player.getInventory().removeItem(new ItemStack(item.getType(), item.getAmount()));
}
I have everything set up how I want it but I get stray items following me between the worlds. The line
player.getInventory().removeItem(new ItemStack(item.getType(), item.getAmount()));
does not remove all of the inventory. I want some code that will remove all inventory items (I've handled armor already). I already have a way to restore the inventory later, but my code currently won't remove everything. For example I can end up transfering some stone tools from the "FunZone" to the normal world, which I don't want.