Changing System MOTD. (I need answer rather soon)

Discussion in 'Plugin Development' started by flash110, Jul 8, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    flash110

    So I have been making a minigame network for a while now and on the last couple steps I noticed something that could cause some errors. My lobby plugin pings the other servers and gets their motd's which update depending on map and gamestate. The only problem is that when they ping the servers they only get back the MOTD that was set by default and bypass the player ping event since it is not a player that is pinging from the list... Does anyone have any workarounds/ ways to fix this... I this is urgent. EDIT: I think it needs to be the way I am getting the info, Here is my current method:
    Code:
    try {
                         Socket socket = new Socket();
                         socket.connect(new InetSocketAddress(ip, port), time * 1000);
                       
                         DataOutputStream out = new DataOutputStream(socket.getOutputStream());
                         DataInputStream in = new DataInputStream(socket.getInputStream());
                       
                         out.write(0xFE);
                       
                         StringBuilder str = new StringBuilder();
                       
                         int b;
                         while ((b = in.read()) != -1) {
                                 if (b != 0 && b > 16 && b != 255 && b != 23 && b != 24) {
                                         str.append((char) b);
                                 }
                         }
                       
                         String[] data = str.toString().split("§");
                         String motd = data[0];
                         int onlinePlayers = Integer.valueOf(data[1]);
                         int maxPlayers = Integer.valueOf(data[2]);
                         String[] gameInfo = motd.split("-", 2);
                         String map = gameInfo[0];
                         String gameState = gameInfo[1];
                         addServerItem(Material.STAINED_CLAY, (byte) onlinePlayers, clayColor, inv, slotNumber, ChatColor.GREEN + "" + ChatColor.BOLD + "Server» " + Servername, ChatColor.AQUA + "Map» " + map, ChatColor.GREEN + "Gamestate» " + gameState, ChatColor.AQUA + "Players» " + onlinePlayers + "/" + maxPlayers);
                       
                         socket.close();
                 } catch (Exception e) {
                         e.printStackTrace();
                         addServerItem(Material.STAINED_CLAY, (byte) 1, (byte) 14, inv, slotNumber, ChatColor.GREEN + "" + ChatColor.BOLD + "ERROR", ChatColor.AQUA + "ERROR", ChatColor.GREEN + "ERROR", ChatColor.AQUA + "ERROR");
                 }
     
    Last edited: Jul 8, 2016
  2. Offline

    MisterErwin

    @flash110 Another sort of communication would be the "best" way
     
  3. @flash110 I assume this is Bungeecord since you wouldn't need to do this for Bukkit mostly because it doesn't have multiple servers.
     
  4. Offline

    MisterErwin

    You are using multiple servers. Thus you require offline mode.

    You might want to take a look at the packets used when doing the ping And check if the IP is the one of your lobby server.

    €: Back then I did something similar using redis pub/sub methods
     
    Last edited: Jul 8, 2016
  5. Offline

    MCKrypto14

    I don't know if this helps or not, but the ServerListPingEvent has a .setMotd() method, and it has the InetAddress that is connecting
     
Thread Status:
Not open for further replies.

Share This Page