Solved Very weird issue

Discussion in 'Spigot Plugin Development' started by TylerV, Jun 8, 2016.

  1. So since yesterday I've been having an issue while working on a plugin that I started yesterday. I am not new to java, I know how to register events. I always use separate classes for my events and in this plugin I just started it's not allowing me to, I register them properly, I implement Listener, etc. I'd just like another developers eye I guess to let me know if there's something small that I missed. I made debug messages, nothing happens. But if I put the event in my main class, it works.. Code is below.
    // main class
    Code (Text):
        public void onEnable() {
            register();
            if(!(getServer().getPluginManager().getPlugin("AuraAPI").isEnabled())) {
                getLogger().info("AURA API NOT FOUND --> DISABLING PLUGIN.");
                getServer().getPluginManager().disablePlugin(this);
            }
        }
       
        public void onDisable() {
           
        }
       
        public void register() {
            getServer().getPluginManager().registerEvents(new JoinEvent(), this);
            getServer().getPluginManager().registerEvents(new ClickEvent(), this);
        }
    // event class
    Code (Text):
    public class JoinEvent implements Listener {
       
        @EventHandler
        public void onJoin(PlayerJoinEvent e) {
            e.getPlayer().getInventory().setItem(0, HotbarItems.help());
            e.getPlayer().getInventory().setItem(4, HotbarItems.compass());
            e.getPlayer().getInventory().setItem(8, HotbarItems.settings());
            e.getPlayer().updateInventory();
        }
    Let me know if you see any error I have, but a friend that looked at it also told me that there should be nothing wrong. Again, I'm not new to Java so this is a weird issue for me to be having. I've tried the plugin on multiple servers, the join event still doesn't fire.
     
  2. May seem obvious, but is your plugin disabling without you realizing? Logger info messages can be a bit hard to see since they don't have color
     
  3. Nope, the plugin is enabled in /plugins
     
  4. Looks like you're gonna have to debug it for hours
     
  5. Double check your event is actually being called, it doesn't look like it is
     
  6. You should try delaying your method for about 3 ticks. The player may not have completely loaded into the server to where you could add items to their inventory yet.
     
  7. I've even tried sending the player a message when they join, and broadcasting a message. Nothing happens.
    it is not being called, which is why I'm confused.
     
  8. Can you show us the entire main class, including the imports?
     
  9. The only imports are java plugin and my 2 events.

    Code (Text):
    package me.tyler.aura;

    import org.bukkit.plugin.java.JavaPlugin;

    import me.tyler.aura.events.ClickEvent;
    import me.tyler.aura.events.JoinEvent;

    public class AuraHub extends JavaPlugin {

        public void onEnable() {
            register();
            if(!(getServer().getPluginManager().getPlugin("AuraAPI").isEnabled())) {
                getLogger().info("AURA API NOT FOUND --> DISABLING PLUGIN.");
                getServer().getPluginManager().disablePlugin(this);
            }
        }
       
        public void onDisable() {
           
        }
       
        public void register() {
            getServer().getPluginManager().registerEvents(new JoinEvent(), this);
            getServer().getPluginManager().registerEvents(new ClickEvent(), this);
        }
       
    }
     
  10. Full startup log please. Should be in /logs/ directory.
     
  11. It starts normal. It enables, and it shows in /plugins. No errors in console, nothing about the plugin.
     
  12. Fine, I won't help you.
     
  13. I really don't see how my console saying my plugin is enabled effects my events being registered.
     
  14. Does your onEnable gets called correctly? Maybe there's another plugin with the same name running that you didn't notice
     
  15. http://pastebin.com/Jaz9R2xJ
    I only have Pex, Vault, a plugin I made (dependency for this), and this plugin on the server.
     
  16. By any chance, are the plugins inter-dependent? Maybe you've set it so the API depends on the Hub and the Hub depends on the API?
     
  17. Nope, just double checked too. Hub depends on API though.
     
  18. Debug it to death. Put a debug message (using System.out) in every if statement everywhere. See where it gets stuck.
     
  19. There's no if statements in my event, I've tried debug messages already but I just added a System.out and it doesn't print anything, so the event is not getting fired.
     
  20. This is what a smart developer would do when his code is shitting the bed.

    Sure, if they're having issues with the API directly, posting here isn't a bad idea, but when the code should work but doesn't, this is what you should be doing.