Solved No idea why events aren't working

Discussion in 'Plugin Development' started by coobro123, Aug 11, 2016.

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

    coobro123

    Hey guys. So I have 0 errors on this plugin it just totally doesn't work. Here is the code idk if I have missed something or not.
    Main class:

    Code:
    package com.gmail.cooperclark132.plugin.Zombiespawn;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerToggleSprintEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener {
    
        public void onEnbable() {
            PluginManager pm = Bukkit.getServer().getPluginManager();
            pm.registerEvents(new Events(), this);
            pm.registerEvents(this, this);
        }
       
        public void onDisable() {
           
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            Player p = ((Player)sender);
            if(cmd.getName().equalsIgnoreCase("poo")) {
                p.sendMessage("hey");
            }
            return true;
        }
       
        @EventHandler
        public void onPlayerSprint(PlayerToggleSprintEvent e) {
            Bukkit.dispatchCommand(e.getPlayer(), "poo");
        }
    
    
    }
    
    Event class:

    Code:
    package com.gmail.cooperclark132.plugin.Zombiespawn;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerToggleSprintEvent;
    
    public class Events implements Listener {
       
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            e.getPlayer().sendMessage("test");
        }
       
        @EventHandler
        public void onPLayerSprint(PlayerToggleSprintEvent e) {
            e.getPlayer().sendMessage("test1");
        }
    
    }
    
    Thanks heaps guys!
     
  2. Offline

    Zombie_Striker

    @coobro123
    What do you mean by "doesn't work"? Have you tried debugging? If so, at what point does it stop working?
     
  3. @coobro123
    It looks as though it should work, are you sure your plugin even enables?
     
  4. Offline

    N00BHUN73R

    @coobro123
    Like @AlvinB said, Are you sure your plugin is even enabling? check console for anything, and type /pl in chat to see if it's even in the list.
     
  5. Offline

    coobro123

    The whole plugin works fine the command works perfectly the plugin loads everything is great it just doesn't do anything with these events O_O
     
  6. Offline

    N00BHUN73R

    @coobro123
    That is very odd.. What version are you running?
     
  7. Offline

    coobro123

    Omg.

    I'm an idiot. Thanks so much though you do not understand how long I have tried fixing this for!
     
  8. @coobro123
    If your issue has been resolved, please mark the thread as such :)
     
Thread Status:
Not open for further replies.

Share This Page