Check Player is Online

Discussion in 'Spigot Plugin Development' started by qVotka, May 1, 2015.

  1. Hi
    I need to check player is Online on BungeeCord side. How can I make this. Thanks for help.
     
  2. So is this for a bungeecord plugin?


    ** Presuming you have the player you're checking's name already in a string called name **

    If so:
    Code (Text):
    String name = playersNameToCheckGoesHere;

    ProxiedPlayer player = ProxyServer.getInstance().getPlayer(name);

    if (player == null)
    {
        // not online
    }
     
  3. This is for a spigot plugin :(
     
  4. gigosaurus

    Supporter

    So you want a spigot plugin to be able to tell if a player is online somewhere in the bungee?
     
  5. Or instead of splitting the list you can do
    playersOnline.contains(", playername,")
     
  6. @unon1100
    But that wouldn't work if there was only 1 player online or if the player was the first on the list right?
     
  7. You can use this:

    Code (Text):
    @SuppressWarnings("deprecation")
        public boolean onlinePlayer(String name){
            for(Player p : Bukkit.getOnlinePlayers()){
                if(p.getName().equalsIgnoreCase(name)) return true;
            }
            return false;
        }
     
  8. Array lists

    Create them and add them wen they login to online.. and remove them from online when offline and add them to offline when the leave.. simple :D
     
  9. Inkzzz

    Resource Staff

    Loop through all the plays on bungee like this:

    Code (Text):
    for (ProxiedPlayer on : ProxyServer.getInstance().getPlayers()) {

    // code

    }
     
  10. Look at this

    @gaelitoelquesito
    Didn't he say "BungeeCord Side"?
     
  11. I was send all servers to plugin message. Players name is in this pluginmessage. If this player is online on any server this server returns a message. Problem was sloved. (Sorry for my bad english :) )