getting the server name?

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

  1. hello so im trying to make a scoreboard with the server name on it.. right now ive got this
    public String getServerName(Player p) {
            ByteArrayOutputStream b = new ByteArrayOutputStream();
            DataOutputStream out = new DataOutputStream(b);
            DataInputStream in = new DataInputStream(new ByteArrayInputStream(b.toByteArray()));
            try {
            } catch (Exception e) {
            p.sendPluginMessage(this, "BungeeCord", b.toByteArray());
            try {
                return in.readUTF();
            } catch (IOException e) {
            return null;
    and it just says "null" on the scoreboard
  2. dtm

    dtm Retired Moderator
    Retired Supporter

    With the current server's name?
  3. JamesJ


    You have to listen for the returned message.
    • Agree Agree x 1
  4. dtm

    dtm Retired Moderator
    Retired Supporter

    If it's just the current servers name, which is what you replied yes to.

    Then just use the Bukkit.getServerName(); method?

    However, what I do believe you really want is a way to get the name of all the servers on the network? :p
  5. ye kinda...

    but if u dont want to spoon feed me then just stop xD
  6. @T0X1C this is what you need to do. PluginMessages do not get instant replies, so you probably have to work with callbacks in order to properly get the reply.