Solved "Method is never used" when events are registered.

Discussion in 'Plugin Development' started by Bamco6657, Dec 28, 2016.

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


    For some weird reason the event I put in is not registering and the method is constantly saying that it's never used. I even tried registering it in another class and it still gave the same message. I feel like I'm missing something that's right in front of me. Please help. :'(

    package me.commandcore.smpwarplugin;
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    * Created by Beto on 12/26/2016.
    public class SMPWARPlugin extends JavaPlugin implements Listener{
        public void onEnable(){
            getLogger().info(getDescription().getName() + " has been enabled!");
            Bukkit.getPluginManager().registerEvents(this, this);
        public void onDisable(){
            getLogger().info(getDescription().getName() + " has been disabled!");
        public void onJoin(PlayerJoinEvent event){
  2. Offline


    In onEnable register Your event in another class

    Bukkit.getServer().getPluginManager().registerEvents(new OnJoin(),this);

    Also if you want to use the main class replace new OnJoin() with "this"

    Using this you register the class as an actual event listener
  3. Online

    timtower Administrator Administrator Moderator

    @MrGeneralQ That is not the issue.

    @Bamco6657 Export the plugin, does it work?
    Because now you are talking about an eclipse warning.
  4. Offline


    Hey, extremely sorry for the late reply, I've been busy lately. It worked! I'm not sure why is says that it was never used, but it works. ¯\_(ツ)_/¯ Thanks for the help guys!
  5. Offline


    If your problem has been solved, mark this thread as solved.
  6. @Bamco6657
    The reason for this is that your IDE (which is what alerts you to these sorts of things) can't see that the Bukkit API will call this method, because the Bukkit API uses Reflection to do it.
Thread Status:
Not open for further replies.

Share This Page