Plugin Help Mind Broken.... Please help!

Discussion in 'Plugin Help/Development/Requests' started by across566, Jul 3, 2015.

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

    across566

    Hi,
    I have used this event HUNDREDS of times but today the PlayerInteractEvent isnt working for me!
    please if you can spot it out TELL ME!!! <3
    Code:
    public void click(PlayerInteractEvent e) {
        if(e.getAction() == Action.RIGHT_CLICK_AIR) {
            if(e.getPlayer().getItemInHand().getType() == Material.DIRT) {
                e.getPlayer().sendMessage("Paper");
            }
        }
    }
     
  2. Firstly, are you registering the listener, using: this.getServer().getPluginManager().registerEvents(this, this);
    ^ assuming the class with your current code is in the same class as the class extending JavaPlugin.

    Secondly, do you have the @EventHandler annotation above your method?

    Thirdly, make sure not to use ignoreCancelled if you are using it, it's a bit buggy with PlayerInteractEvent.

    Fourthly, check if the item is not null first, before checking if the material in hand is dirt. Also use event.getItem() instead of event.getPlayer().getItemInHand(). There's no point of it existing if no one uses it.
     
Thread Status:
Not open for further replies.

Share This Page