GettingOnline Players to a String for a InfoBoard

Discussion in 'Plugin Development' started by diamondcodes, Sep 9, 2014.

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


    How would I get the onlinePlayers to a string? (For a info board) I have tried this
    1. Score RPcount = objective.getScore(Bukkit.getOfflinePlayer(Bukkit.getServer().getOnlinePlayers().toString()));
    but It does not work, Can anybody help?
  2. Offline


    String.valueOf(Bukkit.getOnlinePlayers().size()) or for 1.7.9 and below String.valueOf(Bukkit.getOnlinePlayers().length)
  3. Offline


    rbrick This will return the amount of online players

    diamondcodes If you have the Player object, do player.getName(), if it's the opposite (you have the name & want a OfflinePlayer or Player), you do Bukkit.getOfflinePlayer(name_of_player) or Bukkit.getPlayer(name_of_player)
  4. Offline


    rbrick Thanks :D Totom3 Thanks But I need the amount of online players :p

    Also How would I refresh the board when a new player joins?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 14, 2016
  5. Offline


    diamondcodes Add a Listener to PlayerJoinEvent & PlayerKickEvent and update the scoreboard
  6. Offline


    Totom3 Yes I know I need a Listener but how do I update the scoreboard?
  7. Offline


    diamondcodes Did you try updating the Score of the OfflinePlayer ?
  8. Offline


    Try this:
    1. //IMPORT:
    2. import org.apache.commons.lang.StringUtils;
    3. //CODE:
    4. String online = StringUtils.join(Bukkit.getOnlinePlayers(),",");
    5. //WILL PRINT
    6. player1,player2,player3,player4 //names will vary :P
Thread Status:
Not open for further replies.

Share This Page