PluginMessageListeners

Discussion in 'BungeeCord 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