Solved PlayerInteractEvent not firing?

Discussion in 'Plugin Development' started by FluR0, Nov 28, 2012.

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

    FluR0

    I cant get this code to work
    Code:
        @EventHandler
        public void onPlayerRightClick(PlayerInteractEvent event) {
            Player p = event.getPlayer();
            int typeId = event.getItem().getTypeId();
            int health = getHealth(typeId);
            if (health == 0 || !canEat(p, health))
                return;
     
            setHealth(p, health);
     
            event.setUseItemInHand(Result.DENY);
            p.getInventory().removeItem(new ItemStack(typeId, 1));
        }
    Yes it is added to the PluginManager and other events in that class are firing.
    It wont even log to console when I try to.
     
  2. So... What exactly fails (add debugging) ?
    Also we know neither what getHealth nor what setHealth does.
     
  3. Offline

    FluR0

    The code is not the problem, there is no error in the console either :/

    I have tried replacing the code with some code that wrote to the log, it didn't work.
     
  4. if you add debugging before
    Player p = event.getPlayer();
    and it doesn't print out you did something wrong while registering the event (can't tell without seeing more code) or (another plugin) cancelled it at a lower priority (add (ignoreCancelled = false) after @EventHandler) to check).
     
    FluR0 likes this.
  5. Offline

    FluR0

    It appears the event was being cancelled for some reason, it is now throwing errors that I can fix.

    Thanks for your help mate, I appreciate it.
     
Thread Status:
Not open for further replies.

Share This Page