Solved Send Players A Private Message?

Discussion in 'Plugin Development' started by Epicballzy, Apr 21, 2014.

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

    Epicballzy

    If you were to type a command like /send message [player] [message].. How would you send the specified player a message? What would I use?
     
  2. Offline

    lukewizzy

    Find the player and assign it to a variable:
    Code:java
    1. Player recipient = Bukkit.getPlayer(name);

    Then send them a message:
    Code:java
    1. recipient.sendMessage("message");


    Remember to check that the player is online, you should probably use a try/catch statement when setting the name because it's most likely that someone will type in a player that isn't online, so it'll throw a nullpointerexception
     
  3. Offline

    Epicballzy

    lukewizzy likes this.
Thread Status:
Not open for further replies.

Share This Page