Getting Player Count And Name Of Server

Discussion in 'BungeeCord Plugin Help' started by toxiccoke, May 17, 2015.

  1. Hi
    I was making a MOTD for my network and i wanted to get the player count of the network and the name of the server the player has connected to.
    This is what i have but i am getting errors and i cannot work out why
    Code (Text):
    package me.toxiccoke.core.Motd;

    import me.toxiccoke.core.Main;
    import me.toxiccoke.core.Chat.ChatUtils;
    import net.md_5.bungee.api.ProxyServer;
    import net.md_5.bungee.api.connection.ProxiedPlayer;

    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;

    public class MOTD implements Listener{
     
        Main plugin;
     
        @EventHandler
        public void onJoin(PlayerJoinEvent e){
            Player p = e.getPlayer();
            e.setJoinMessage(null);

            ChatUtils.sendMessage(p, ChatColor.YELLOW + "Welcome To " + ChatColor.RED + "Inferno Network");
            ChatUtils.sendMessage(p, ChatColor.YELLOW + "There are " + ChatColor.RED + p.getServer().getOnlinePlayers().length + ChatColor.YELLOW + " Player Online");
            ChatUtils.sendMessage(p, ChatColor.YELLOW + "Visit Our Website At " + ChatColor.RED + "");
            ChatUtils.sendMessage(p, ChatColor.YELLOW + "You Are Connected To " + "");
            ChatUtils.sendMessage(p, ChatColor.YELLOW + "Use " + ChatColor.RED + "/Server" + ChatColor.YELLOW + " To Switch Between Servers");
        }
     
        @EventHandler
        public void onQuit(PlayerQuitEvent e){
            e.setQuitMessage(null);
        }
     

    }
    If you would like anymore information then pls post below i will be happy to supply you with what i can to help me out
    thanks toxiccoke
     
    #1 toxiccoke, May 17, 2015
    Last edited: May 17, 2015
  2. for player count: Bukkit.getServer().getOnlinePlayers() (similar)
     
  3. Make sure to make its a int
     
  4. Nevermind its bungee :p
    thought just 1 server xd
     
  5. Well how I would do it is, send the amount of players to a database (MYSQL), then get the table data, and then make a string. So then you would be able to use the data on scoreboards and in chat ect.. Hope it helps a little :)