what event should detect this?

Discussion in 'Plugin Development' started by xize, Jun 21, 2014.

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



    so I'm wondering this for some while, which event triggers when a player removes an item inside his creative inventory by placing the item in the removal slot? or by using ctrl + shift and clicking on the red cross?

    because I need to find a way how to detect this since ive made a backpack wrapper which extend a ItemStack but they are binded on configuration files to, so I need to be sure the files will be deleted even when a player does this action.

  2. Offline


    Does the inventory click event not pick that up?
  3. Offline


    This is a very good question.
    Try listening for the InventoryClickEvent and have it send the slot you clicked via message to you. Then mash the clear button and see if it sends you anything.

    (I'd like to know too)
  4. Offline


    xize you shouldn't extend ItemStack
    Garris0n likes this.
  5. Offline



    the event seems not to detect that slot with the red cross, ive also tried to use ctrl + shift and clicking on it then it fires with the action PLACE_ALL but it won't show the slot.

    could I may ask why I shouldn't extend it?, besides I'm ignoring serializing and casting and its not the best design:p.
  6. Offline


    xize Bukkit will create it's own ItemStacks from the NMS ItemStacks, and not yours
  7. Offline


    thats very true, but I won't mess with the internals say setting the amount of that ItemStack, I just use the ItemStack as a super constructor so I can wrap around that stack and merge my own method to it, so I can easier attach uuid's on it to get easier ways to difference the backpacks which a player uses and of course my design is not that good it was more a play around.

    but its not that I do this:
    ItemStack someitem = new ItemStack(Material.GOLD_ORE, 1);
    Backpack pack = (Backpack) someitem;
    but rather:
    ItemStack stack = new ItemStack(Material.GOLD_ORE, 1);
    Backpack pack = new Backpack(stack); //<- constructor with super(itemstack) takes care, because Backpack extends ItemStack, I only add my own UUID things without affecting the ItemStack itself.
    and then vice versa I only can inthirit back from a backpack to a ItemStack with casting but not as above from ItemStack to backpack.

    why is this wrong?
  8. Offline


    xize as far as I am aware, in (for example) inventory events the ItemStacks you get would be regular Bukkit ItemStacks and not your Backpack ItemStacks, thus losing the data they hold.
    Zwander and xize like this.
  9. Offline


    ah fair enough, that explained it, I was more into the concern I did something really dangerous but the backpack constructor does some checks to if it has a specific uuid lore which is serialized in chat colors to see if it matches else the constructor throws a exception but I'm fine (I hope), forgot to mentoid that :p
  10. Offline


    You will code for a cookie, i will code for a whopper :cool:
    Hopefully bukkit will make this more simple.
Thread Status:
Not open for further replies.

Share This Page