Solved Getting dropped items.

Discussion in 'Plugin Development' started by Link_Awesomesause, Apr 3, 2016.

Thread Status:
Not open for further replies.
  1. Simple problem, but VERY frustrating for me.
    I need to get the drops and store it in a variable, and then clear the drops.

    I tried (btw this is in a PlayerDeathEvent):

    List<ItemStack> drops = e.getDrops();
    e.getDrops().clear();

    What is happening is for some reason, bukkit is clearing the drops (?before) I store it or, I don't know. In the end, my "drops" is empty.
     
  2. Offline

    mcdorli

    If you have learnt java before, then you would know why this is happening. Basically, e.getDrops is the exact same object as drops, so if you change one, the other is also going to get saved. This is because ct variables store a pointer tonthe place in the memory, where the object is located, not the itself
     
  3. @mcdorli
    Anyway you can show me how to do it. I am (eh) in java.

    EDIT: I think I just thought of a way.. lemme give it a shot

    EDIT x2: Yup fixed it, thanks for reminding me @mcdorli
     
    Last edited: Apr 4, 2016
Thread Status:
Not open for further replies.

Share This Page