onPlayerInteract event not occuring

Discussion in 'Plugin Development' started by lethaltactics, Jan 8, 2014.

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

    lethaltactics

    I am debugging my plugin but when I interact with either of these items it does not output my message.

    Here is the code for the event.


    Code:java
    1. @EventHandler(priority=EventPriority.HIGH)
    2. public void onPlayerInteract(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4.  
    5. if(p.getItemInHand().getType() == Material.BLAZE_POWDER){
    6. p.sendMessage(ChatColor.GRAY + "Blaze Powder");
    7. }
    8. else if(p.getItemInHand().getType() == Material.BLAZE_ROD){
    9. //Do whatever
    10. p.sendMessage(ChatColor.GRAY + "Blaze Rod");
    11. }
    12. }


    In the plugin on enable I have also included
    Code:java
    1. PluginManager pm = this.getServer().getPluginManager();
    2. pm.registerEvents(this, this);


    If you could help me figure out why it is not working it would be a big help.
     
  2. Offline

    Luke_Lax

    This code works just fine for me, is the event in the same class as your onEnable?
     
  3. Offline

    GaaTavares

    Make sure you implements to Listener
     
  4. Offline

    lethaltactics

    Yes it is in the same class as my onEnable. The code is also in my main class
     
  5. Offline

    HeavyMine13

    Whole code I guess? Make sure the plugin yml works and there is no any console errors!
     
  6. Offline

    Luke_Lax

    As GaaTavares pointed out, make sure your main class implements Listner.
    Code:
    public class <class> extends JavaPlugin implements Listner {
     
Thread Status:
Not open for further replies.

Share This Page