Event not fired

Discussion in 'Plugin Development' started by TFOXTom, Dec 29, 2018.

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

    TFOXTom

    I'm developing a plugin in 1.12(because it's for a friend, and his server is still in 1.12 lol), but can't get my event to fire... Code:
    Code:
    public class OnItemInHopper implements Listener {
       
        @EventHandler
        public static void onItemInHopper(InventoryMoveItemEvent event) {
    and:
    Code:
    public class Core extends JavaPlugin{
       
        @Override
        public void onEnable() {
           
            this.getServer().getPluginManager().registerEvents(new OnItemInHopper(), this);
           
        }
    
    I get no errors in the console, so that's weird...
    Anyone that knows a solution?
     
  2. Offline

    KarimAKL

    @TFOXTom Have you tried printing a simple message to the console in the event? (outside of any if statements)
    EDIT: Try removing the 'static' keyword from the event.
     
  3. Offline

    TFOXTom

    @KarimAKL sorry for the late reply.
    I have tried that. Removing static doesn't work...
     
  4. Offline

    KarimAKL

    @TFOXTom Any errors in the console? Did you get the message when trying to print it to console outside of any if statements in the event?
     
  5. Offline

    TFOXTom

    No errors, didn't get the message...
     
  6. Offline

    KarimAKL

    @TFOXTom Are you sure it's the correct event?
     
  7. Offline

    TFOXTom

    I'm 95% sure. Im trying to check if a item is moved to or from a hopper, so it's the good one right?

    EDIT: found the problem. There probably is a bug in my bukkit.jar, where the event is only fired when the interaction is between two TileEntities, and not via a player...
     
    Last edited: Dec 30, 2018
  8. Offline

    Escad

    The InventoryItemMoveEvent can't be caused by a player. It is called exclusively when a hopper moves an item to or from a container, which has no relation to a player. Listen into the InventoryPickupItemEvent instead. There is no player association with that, either, though.
     
Thread Status:
Not open for further replies.

Share This Page