Solved When Events Misbehave

Discussion in 'Plugin Development' started by Mrawesomecookie, Oct 6, 2013.

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

    Mrawesomecookie

    I am working on a plugin which looks for a PlayerMoveEvent. I can't seem to get it to trigger though.
    Code:

    Code:java
    1. public class RobertSponge extends JavaPlugin implements Listener {
    2. public void onEnable() {
    3. getServer().getPluginManager().registerEvents(this, this);
    4. System.out.println("Registered PlayerMoveEvent event");
    5.  
    6. }
    7. @EventHandler
    8. public void onPlayerMove(PlayerMoveEvent event) {
    9. System.out.println("Player moved! Checking to see if sponge.");
    10. //No free plugin 4 u
    11. }
    12. }
    13. }
    14.  
     
  2. Offline

    Chinwe

    Is the plugin actually loading, ie without any errors in the console? The plugin.yml might be to blame if there are, as that code looks like it should work :confused:
     
  3. Offline

    Varilian

    I'm going to agree with Chinwe, and I would check to see if your plugin.yml and packages are configured correctly.

    Do you receive the first line of output? ("Registered PlayerMoveEvent event") or none at all?
     
  4. Offline

    Mrawesomecookie

    No errors, plugin loads fine. Logs the Registered PlayerMoveEvent event to the console.

    No.
     
  5. Offline

    JRL1004

    Mrawesomecookie
    Does System.out.println() function in bukkit? I would try having it output to console with ConsoleSender. Try this:
    Code:java
    1. public class RobertSponge extends JavaPlugin implements Listener {
    2. public void onEnable() {
    3. getServer().getPluginManager().registerEvents(this, this);
    4. System.out.println("Registered PlayerMoveEvent event");
    5.  
    6. }
    7. @EventHandler
    8. public void onPlayerMove(PlayerMoveEvent event) {
    9. Bukkit.getConsoleSender().sendMessage("Player moved! Checking to see if sponge.");
    10. //No free plugin 4 u
    11. }
    12. }
    13. }
     
  6. Offline

    Mrawesomecookie

    Yes it does, it just dosn't show [RobertSponge] infront as with the Register PlayerMoveEvent event working
     
  7. Offline

    Cirno

    Make sure there's no other plugin?
    You can probably catch it by changing:
    @EventHandler
    to:
    @EventHandler(ignoreCancelled = true)

    If you're really desperate:
    @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
     
  8. Offline

    billman555555

  9. Offline

    Wolvereness Bukkit Team Member

    • Did you actually sign into the server and walk around, having exported the plugin properly?
    • Did you try it with no other plugins installed on an official CraftBukkit build?
    Another plugin or an unofficial build of CB may be 'naughty' and unregister your handler or refuse to fire the event. Similarly, many plugin developers fail to export their plugin properly. That's the entire list though...
    However, it's my belief that you aren't actually giving us the entire code, and your sample does in fact work.
     
    Chinwe and KingFaris11 like this.
  10. Offline

    Mrawesomecookie

    Trying it on a bukkit server with no plugins. I did have a few other plugins on my test server at the time. I was originally running spigot because thats what I use on my non-test server. Also I have exported other custom plugins before using the same way I did with RobertSponge and they work fine.

    NOTE: I will make a [Edit] when I see if this works.
    [Edit] Seems to be working now! Yay!
     
Thread Status:
Not open for further replies.

Share This Page