mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-02-19 13:31:20 +01:00
Rename class
This commit is contained in:
parent
5efc4a5def
commit
2eb90907c2
@ -13,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
|
||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerAddress;
|
||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger;
|
||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerStatus;
|
||||
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.PingResponse;
|
||||
import com.gmail.filoghost.holographicdisplays.disk.Configuration;
|
||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||
|
||||
@ -159,7 +159,7 @@ public class BungeeServerTracker {
|
||||
boolean displayOffline = false;
|
||||
|
||||
try {
|
||||
ServerStatus data = pinger.fetchData(entry.getValue(), Configuration.pingerTimeout);
|
||||
PingResponse data = pinger.fetchData(entry.getValue(), Configuration.pingerTimeout);
|
||||
if (data.isOnline()) {
|
||||
serverInfo.setOnline(true);
|
||||
serverInfo.setOnlinePlayers(data.getOnlinePlayers());
|
||||
|
@ -4,21 +4,21 @@ import java.lang.String;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ServerStatus
|
||||
public class PingResponse
|
||||
{
|
||||
private boolean isOnline;
|
||||
private String motd;
|
||||
private int onlinePlayers;
|
||||
private int maxPlayers;
|
||||
|
||||
public ServerStatus(boolean isOnline, String motd, int onlinePlayers, int maxPlayers) {
|
||||
public PingResponse(boolean isOnline, String motd, int onlinePlayers, int maxPlayers) {
|
||||
this.isOnline = isOnline;
|
||||
this.motd = motd;
|
||||
this.onlinePlayers = onlinePlayers;
|
||||
this.maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
public ServerStatus(JSONObject json) {
|
||||
public PingResponse(JSONObject json) {
|
||||
isOnline = true;
|
||||
motd = ((String) json.get("description"));
|
||||
|
@ -13,6 +13,6 @@ public abstract class ServerPinger {
|
||||
// For 1.6 and lower
|
||||
public static final ServerPinger PRE_NETTY_REWRITE = new ServerPingerPreNetty();
|
||||
|
||||
public abstract ServerStatus fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception;
|
||||
public abstract PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception;
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import org.json.simple.JSONValue;
|
||||
final class ServerPingerPostNetty extends ServerPinger {
|
||||
|
||||
@Override
|
||||
public ServerStatus fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
public PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOut = null;
|
||||
@ -43,7 +43,7 @@ final class ServerPingerPostNetty extends ServerPinger {
|
||||
final byte[] responseData = new byte[PacketUtils.readVarInt(dataIn)];
|
||||
dataIn.readFully(responseData);
|
||||
final String jsonString = new String(responseData, PacketUtils.UTF8);
|
||||
return new ServerStatus((JSONObject) JSONValue.parse(jsonString));
|
||||
return new PingResponse((JSONObject) JSONValue.parse(jsonString));
|
||||
}
|
||||
finally {
|
||||
PacketUtils.closeQuietly(dataOut);
|
||||
|
@ -13,7 +13,7 @@ import java.lang.String;
|
||||
final class ServerPingerPreNetty extends ServerPinger {
|
||||
|
||||
@Override
|
||||
public ServerStatus fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
public PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {
|
||||
|
||||
Socket socket = null;
|
||||
DataOutputStream dataOut = null;
|
||||
@ -33,7 +33,7 @@ final class ServerPingerPreNetty extends ServerPinger {
|
||||
dataIn.readFully(bytes);
|
||||
socket.close();
|
||||
final String[] info = new String(bytes, PacketUtils.UTF16BE).split(String.valueOf('\0'));
|
||||
final ServerStatus response = new ServerStatus(true, info[3], Integer.parseInt(info[4]), Integer.parseInt(info[5]));
|
||||
final PingResponse response = new PingResponse(true, info[3], Integer.parseInt(info[4]), Integer.parseInt(info[5]));
|
||||
// String versionName = info[2];
|
||||
// String protocol = info[1];
|
||||
return response;
|
||||
|
Loading…
Reference in New Issue
Block a user