Solved Server Menu

Discussion in 'Spigot Plugin Development' started by arci224, May 4, 2017.

  1. Hi i have problem, i creating my own first plugin -> Server menu, i have all with count players via bungeecord api -> Message Listener. And i can´t find how to get server if offline and if server offline then api give me same number when server online and empty -> 0 .. how can i fix that ? i need get server when offline and when online Thank for help.. Sorry for my bad english
    Code (Text):
    public void onEnable() {
            getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
            getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
        }
       
    public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
           
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();
            player.sendMessage(subchannel);
            if (subchannel.equals("PlayerCount")) {
                String server = in.readUTF();
                int playerCount = in.readInt();
                addServerMenu(server, playerCount, player);
               
            }
           
        }

    public void addServerMenu(String server, int playerCount, Player player)
        {
            String mng1 = "mng1";
            if(mng1.equals(server)){
                createDisplay(Material.EMERALD_BLOCK, myInventory, 4, "Survival 01", "Status: Online", "Počet hráčů:" + playerCount + "/50", "", "");
            }
        }

    public void getCount(Player player, String server) {
           
            if (server == null) {
                server = "ALL";
            }
           
            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF("PlayerCount");
            out.writeUTF(server);
            out.writeUTF("motd");
            player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
           
        }
     
  2. Oh, okay sorry thank you.