How to make a player send a message when it joins?

Discussion in 'Plugin Development' started by SugarCraft, Sep 17, 2013.

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

    SugarCraft

    Hey, how do you make a player send a message when it joins?
     
  2. Offline

    mattrick

    Simple!
    Code:java
    1. onJoin(PlayerJoinEvent event){
    2. Bukkit.getServer().broadcastMessage(event.getPlayer()+" has joined the game.")}
     
  3. Offline

    The_Doctor_123

    Supposing you know how events work, use the PlayerJoinEvent, get the Player and send a message.
     
  4. Offline

    SugarCraft

    No, I want the player to send the message.
    I'm trying to make it send a message that's like ".(hackname)" and if it doesnt send, tell the staff, and if it does do nothing.

    @The_Doctor_123 @mattrick16
     
  5. Code:java
    1. @EventHandler
    2. public void onPJ(PlayerJoinEvent e){
    3. e.getPlayer().sendMessage("Your message");
    4. }
    5.  
    6. // Or do you want that the player perform chat message: like : "Hi I'm <playername> "
    7.  
    8. @EventHandler
    9. public void onPJE (PlayerJoinEvent e){
    10. e.getPlayer().chat("Hi I'm "+e.getPlayer().getName()+" Nice to play here!");
    11. }
    12.  
     
  6. Offline

    mattrick

    use event.getPlayer().sendMessage("")
    EDIT: Ninja'd
     
  7. Offline

    remremrem

    player.runCommand("msg whoever blah blah blah")
     
Thread Status:
Not open for further replies.

Share This Page