Solved Issues with PlayerInteractEvent

Discussion in 'Plugin Development' started by tlm920, Aug 13, 2019.

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

    tlm920

    Heyo all. I am trying to create a weed plugin (lmao) and the PlayerInteractEvent listener is not working properly. I've registered the listener in the main class, and the handler looks correct to me. ;-; Can someone please help me! Thanks...

    Handler: https://pastebin.com/9DG5KJzs
     
  2. Offline

    KarimAKL

    What exactly do you mean? What happens? Do you get the message?
     
  3. Offline

    tlm920

    No, I have no errors or stacktrace in my console. I was debugging and it seems that the if statement on line 21 does not get fired.

    EDIT: Nothing happens at all, no message, no speed.
     
  4. Offline

    CraftCreeper6

    @tlm920
    Can I see the code with debugs in.
     
  5. Offline

    tlm920

    @CraftCreeper6 Theres just a println in the if material sugarcane statement and one in the action if statement. Why do you need to see it? Its called in the action one but not the other.
     
    Last edited: Aug 14, 2019
  6. Offline

    Visualizeding

    Could you post your onEnable/Main class where you are registering listeners?
     
  7. Offline

    Sir_Jonn

    Added this to my plugin to test it, and it works. Maybe you're just not registering the actual class for the event.
     
  8. Offline

    Machine Maker

    Did you register the event? Do you have the @EventHandler annotation above the method?
     
  9. Offline

    tlm920

    @Machine Maker As you can tell in the code I linked, I did use @EventHandler
    In my main class, I registered the event like so:

    Code:
    this.getServer().getPluginManager().registerEvents(new WeedListener(), this);
     
    Last edited: Aug 15, 2019
  10. Offline

    CraftCreeper6

  11. Offline

    tlm920

    Yes, it does load and appear in green when i do /pl
     
  12. Offline

    CraftCreeper6

    @tlm920
    Can you put debugs in (if you haven't already) before and after the if statement, just to make sure the event actually fires.
     
  13. Offline

    tlm920

    I have already done that, the event fires and the right click if statement fires, but the inner if statement does not fire at all.
     
  14. Offline

    CraftCreeper6

    @tlm920
    Remove the null check.
     
  15. Offline

    tlm920

    already tried without it.
     
  16. Offline

    CraftCreeper6

    @tlm920
    And you're holding sugar cane correct?
     
  17. Offline

    tlm920

    Yes I am holding the sugar cane correct.
     
  18. Offline

    KarimAKL

    @tlm920 What version are you building on? If it's 1.13+ then try adding 'api-version: 1.13' to your plugin.yml file (if you haven't already).
     
  19. Offline

    tlm920

    That seemed to do the trick, thank you! <3
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page