Problems with the "PlayerLoginEvent"

Discussion in 'Plugin Development' started by VanillaPie, Feb 26, 2011.

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

    VanillaPie

    Hello,
    I try to display a message when a player joins the server:

    PHP:
        public void onPlayerLogin(PlayerLoginEvent event)
        {
            
    System.out.println("USER JOIN!");
             
    Player player event.getPlayer();
            
    player.sendMessage(ChatColor.GREEN "Hello, " player.getDisplayName());
            
    player.sendMessage(ChatColor.GRAY "Currently online: " onlineUser());
        }
    ...
        private 
    String onlineUser()
        {
            
    String onlineuser "";
            for(
    Player p plugin.getServer().getOnlinePlayers())
            {
                
    onlineuser += p.getDisplayName() + ",";
            }
            
    onlineuser onlineuser.substring(0,onlineuser.length()-1);
            return 
    onlineuser;
        }
    But I always have an error if I join. I receive the Test ("USER JOIN!") but I can't deal with the Userdata.
    Can anyone help me?
     
  2. Offline

    Saturisk


    Can you give a little bit more of an explanation so i know what your talking about?
     
  3. Offline

    VanillaPie

    Yes, of course:
    I want to display a motd if the player joins the game.
    But if I try to send to him a message I receive the following exception:
    Now I want to know: How can I send the player a message if he joined the game?
     
  4. Offline

    Saturisk

    You personally or the server does it automatically?
     
  5. Offline

    Plague

    AFAIK you can't. PLAYER_LOGIN is done before the actual joining the game. You can use PLAYER_JOIN wich is sent later.
     
  6. Offline

    Saturisk

    That is true.
     
  7. Offline

    VanillaPie

    But PLAYER_JOIN isn't implemented yet, is it?
     
  8. Offline

    Saturisk

    yes it is.
     
  9. Offline

    Plague

    It is even in the javadocs.
     
  10. Offline

    VanillaPie

    I see. Thanks.
     
  11. Offline

    Dinnerbone Bukkit Team Member

    PLAYER_LOGIN is "this player is logging in, can they join or are they banned?".
     
  12. Offline

    VanillaPie

    Okay, thanks.
    I just was wondering, why I couldn't send them a message :)
     
Thread Status:
Not open for further replies.

Share This Page