PlayerListener not working?

Discussion in 'Plugin Development' started by Lanuk, Jan 22, 2012.

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

    Lanuk

    Alright, so I am trying to use listeners for the first time, and my PlayerListener is not cooperating. In my pm.registerEvent, I get red underlines under Type and Priority, and it says they cannot be resolved/are not a field. Here is my main class:

    Code:
    package com.rocketmail.lanuk.bukkitTest;
     
    import java.awt.Event;
    import java.util.logging.Logger;
     
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class bukkitTest extends JavaPlugin{
     
        Logger log = Logger.getLogger("Minecraft");
        private final bukkitTestPlayerListener playerListener = new bukkitTestPlayerListener(this);
       
        @Override
        public void onDisable() {
            log.info("bukkitTest disabled.");
           
        }
     
        @Override
        public void onEnable() {
            log.info("bukkitTest enabled!");
            PluginManager pm = this.getServer().getPluginManager();
           
            pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this);
           
        }
       
     
    }
    
    And here is my playerlistener:

    Code:
    package com.rocketmail.lanuk.bukkitTest;
     
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerListener;
     
    public class bukkitTestPlayerListener extends PlayerListener {
        public bukkitTest plugin;
     
        public bukkitTestPlayerListener(bukkitTest Instance) {
            plugin = Instance;
     
        }
     
        public void onPlayerJoin(PlayerJoinEvent event) {
     
        }
     
    }
    Any help would be appreciated, thanks!
     
  2. Offline

    theguynextdoor

    Are you using the latest dev version? Because they have a new event system.
     
  3. Offline

    Chiller

    Try ignoring the errors or just close that class and reopen it, your code looks all good so just try that.
    EDIT: Look at the first reply
     
  4. Offline

    Lanuk

    Ok, yeah, im not using the latest one, im using 1.0.0, because when I use the latest build it doesnt work for some reason. I dont know if its the name of the jar thats messing it up or what. Anyone know what I should do?

    EDIT: If I use the latest one, I get strikethroughs through PlayerListener and registerEvent... and the errors dont go away
     
  5. Offline

    theguynextdoor

  6. Offline

    nisovin

    You've imported the wrong Event.
     
  7. Offline

    Technius

    nisovin is correct. You've imported java's AWT Event, which is related to GUIs. You need to import the other one.
     
  8. Offline

    Lanuk

    Ah thank you, thats what it was lol
     
Thread Status:
Not open for further replies.

Share This Page