Solved Dropping Item from GUI

Discussion in 'Plugin Development' started by NukeDude, Feb 7, 2018.

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

    NukeDude

    So. This may be a stupid question, but I've spent hours attempting to fix it myself. The plugin I'm working on uses a GUI to "crush" items into other items. My problem is the fact that I can't figure out how to make the items drop on the ground if you exit the GUI while items are in it.

    [​IMG]
     
  2. Offline

    AyWuzzUp

    I am not on my computer to test this, but if I am not mistaken the following should work:
    Code:
    player.getWorld().dropItem(Location, ItemStack);
     
  3. Offline

    NukeDude

    Doesn't seem to work. It doesn't cause any errors, but neither did my original code.
     
  4. Offline

    Lorinthio

    My guess is that the event isn't registered correctly if it is not being called. Ensure you have @EventHandler above the method and the containing class implements Listener.

    As well as the class being registered with Bukkit.getPluginManager().registerEvents(listenerClass, plugin)

    Theoretically everytime you open your inventory, or a chest, all the items should drop at your feet if your event is registered correctly. So you'll want to check to make sure the inventory being closed has a name matching the name of the inventory you want to check for
     
    NukeDude and AyWuzzUp like this.
  5. Offline

    AyWuzzUp

    Agreed, I also just tested out the code above and it works perfectly fine!

    Code:
    player.getWorld().dropItem(Location, ItemStack);
     
  6. Offline

    NukeDude

    Well I seem to have made a fool out of myself.
    This worked perfectly. Thank you so much! I have a list of everything I need to accomplish for this plugin, and you effectively eliminated most of it. My other roadblock is the config but that doesn't matter right now. Either way, my problem is solved.
     
    Lorinthio likes this.
  7. Offline

    Lorinthio

    Glad to hear!

    Mark the thread as solved please! ;)
     
Thread Status:
Not open for further replies.

Share This Page