PluginMessageListener

Discussion in 'Spigot Plugin Development' started by Erouax, Jun 21, 2015.

  1. I'm quite new to PluginMessageListeners and i'm trying to get the player count whenever i need it.
    I have this:
    Code (Text):
        HashMap<String, Integer> serverPlayersSize = new HashMap<String, Integer>();

        @Override
        public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();
            if (subchannel.equals("PlayerCount")) {
                String server = in.readUTF();
                serverPlayersSize.put(server, in.readInt());
                Bukkit.broadcastMessage(server);
            }
        }
    How could i make it so that when i need to, i can call this so it get's the playercount. I might not have done this the right way, as i am new to this area. Thanks for any help
     
  2. This is Spigot development, looks like you're trying to use Bungee
     
  3. It's a spigot plugin, that's hooking into a BungeeCord server to get info about the other spigot servers it's connected to.
     
  4. Either way, i expect you'd get more help on the Bungee side of the fourms
     
  5. Ok thanks, i'll make a post there :)