Solved Plugin is not logging events. Help!

Discussion in 'Plugin Development' started by NewMasterBR, Oct 1, 2021.

  1. Offline

    NewMasterBR

    I haven't played with Java for a long time, I recently went back to playing survival with friends and I missed how to create a plugin, but unfortunately I'm not getting it. I'm using Spigot version 1.17.1. He doesn't want to register my class

    edit: I had forgotten to implement the commandexecutor, but I've fixed it in the print. Even so it doesn't log JoinEvent events
     

    Attached Files:

    Last edited: Oct 1, 2021
  2. Offline

    Strahan

    You are forgetting the @EventHandler tag for the PlayerJoinEvent. Also there is no need for plugin to be public and static in Join. Don't register your main class twice for event handling, and there is no need for all that casting.

    PS in the future, don't use screen shots to show code. Just use code tags on the message here or something like PasteBin. It's much easier to deal with.
     
  3. Offline

    NewMasterBR

    Damn! What a silly mistake haha. Thanks, I totally forgot about it. As for main, do you mean that?
    Code:
    Bukkit.getServer().getPluginManager().registerEvents(this, (Plugin)this);
                getServer().getPluginManager().registerEvents(this, (Plugin)this);
                Register();
     
  4. Offline

    Strahan

    No prob. As to the main bit, you have in your code:
    Code:
    Bukkit.getServer().getPluginManager().registerEvents(this, (Plugin)this);
    getServer().getPluginManager().registerEvents(this, (Plugin)this);
    You're registering Main twice to handle events. That will cause duplication. Like if you throw this into Main:

    Code:
    @EventHandler
    public void onPIE(PlayerInteractEvent e) {
      e.getPlayer().sendMessage("You just interacted");
    }
    Then go in game and swing your arm, you'll see:
    Code:
    You just interacted
    You just interacted
     
  5. Offline

    NewMasterBR

    thanks!

    solved.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 2, 2021

Share This Page