Solved clone() in org.bukkit.inventory.ItemStack

Discussion in 'Plugin Development' started by Blir, Nov 2, 2012.

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


    Does anyone know if the above mentioned method returns a shallow copy or a deep copy?
  2. Offline


    As far as I know, it should return a deep copy (If you mean that it copies everything). It is literally a clone, exactly the same except they are different objects
  3. Offline


    That's what I thought, but something that was happening in my plugin was showing otherwise. But it turned out to be a minor bug it my code, I've got it all figured. All of the fields of an ItemStack are non-objects anyway, meaning a shallow copy is sort of impossible unless they pretty much do this:

    public ItemStack clone() {
        return this;
    which would be pretty ignorant. But they didn't, so it's all good.
Thread Status:
Not open for further replies.

Share This Page