Code not getting executed

Discussion in 'Plugin Development' started by Jinux, Jan 17, 2011.

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

    Jinux

    Ok, I'm trying to get into this plugin development, so to start I thought I'd do a basic thing and have the player's name sent back to them in a message when they login. I've never touched Java before but I know Python so bear with me :p
    I have the player listener registered for joining players like this:
    Code:
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
    and in the PlayerListener I have this function:
    Code:
    public void onPlayerLogin(PlayerLoginEvent event) {
            Player player = event.getPlayer();
            String name = player.getName();
            player.sendMessage(name);
        }
    The problem is that when someone logs in, the function isn't getting called. Is the hook broken or am I just missing something?

    Thanks in advance :)
     
  2. Offline

    MysticX

    You are using the correct hook (PLAYER_JOIN), but the wrong method for it ;)
    There is also a PLAYER_LOGIN hook.

    Try this:
    Code:
    public void onPlayerJoin(PlayerEvent event) {
    Player player = event.getPlayer();
    String name = player.getName();
    player.sendMessage(name);
    }
     
  3. Offline

    Jinux

    Awesome! Thank You so much! Expect to see more of me though probably :p
     
Thread Status:
Not open for further replies.

Share This Page