Many small fixes.

This commit is contained in:
filoghost 2014-12-30 16:33:55 +01:00
parent ab23d82fc5
commit b478133950
5 changed files with 28 additions and 19 deletions

View File

@ -4,20 +4,20 @@ import com.gmail.filoghost.holographicdisplays.disk.Configuration;
public class BungeeServerInfo {
private boolean isOnline;
private int onlinePlayers;
private int maxPlayers;
private volatile boolean isOnline;
private volatile int onlinePlayers;
private volatile int maxPlayers;
// The two lines of a motd
private String motd1; // Should never be null
private String motd2; // Should never be null
private volatile String motd1; // Should never be null
private volatile String motd2; // Should never be null
private long lastRequest;
private volatile long lastRequest;
protected BungeeServerInfo() {
isOnline = true;
isOnline = false;
this.motd1 = "";
this.motd2 = "";
this.motd2 = "".trim();
updateLastRequest();
}
@ -54,6 +54,7 @@ public class BungeeServerInfo {
}
public void setMotd(String motd) {
if (motd == null) {
this.motd1 = "";
this.motd2 = "";

View File

@ -31,6 +31,7 @@ public class BungeeServerTracker {
public static void track(String server) {
if (!trackedServers.containsKey(server)) {
BungeeServerInfo info = new BungeeServerInfo();
info.setMotd(Configuration.pingerOfflineMotd);
trackedServers.put(server, info);
if (!Configuration.pingerEnable) {
@ -47,6 +48,7 @@ public class BungeeServerTracker {
BungeeServerInfo info = trackedServers.get(server);
if (info == null) {
info = new BungeeServerInfo();
info.setMotd(Configuration.pingerOfflineMotd);
trackedServers.put(server, info);
}
@ -61,7 +63,7 @@ public class BungeeServerTracker {
} else {
// It was not tracked, add it.
track(server);
return "[Loading...]";
return "0";
}
}
@ -78,7 +80,7 @@ public class BungeeServerTracker {
} else {
// It was not tracked, add it.
track(server);
return "[Loading...]";
return "0";
}
}
@ -95,7 +97,7 @@ public class BungeeServerTracker {
} else {
// It was not tracked, add it.
track(server);
return "[Loading...]";
return Configuration.pingerOfflineMotd;
}
}
@ -112,7 +114,7 @@ public class BungeeServerTracker {
} else {
// It was not tracked, add it.
track(server);
return "[Loading...]";
return "";
}
}
@ -129,7 +131,7 @@ public class BungeeServerTracker {
} else {
// It was not tracked, add it.
track(server);
return "[Loading...]";
return "0";
}
}
@ -160,6 +162,7 @@ public class BungeeServerTracker {
try {
PingResponse data = pinger.fetchData(entry.getValue(), Configuration.pingerTimeout);
if (data.isOnline()) {
serverInfo.setOnline(true);
serverInfo.setOnlinePlayers(data.getOnlinePlayers());
@ -198,6 +201,6 @@ public class BungeeServerTracker {
}
}
}, 0, refreshSeconds * 20);
}, 1, refreshSeconds * 20);
}
}

View File

@ -51,11 +51,14 @@ public class ReloadCommand extends HologramSubCommand {
UnicodeSymbols.load(HolographicDisplays.getInstance());
Configuration.load(HolographicDisplays.getInstance());
BungeeServerTracker.resetTrackedServers();
BungeeServerTracker.startTask(Configuration.bungeeRefreshSeconds);
HologramDatabase.loadYamlFile(HolographicDisplays.getInstance());
AnimationsRegister.loadAnimations(HolographicDisplays.getInstance());
PlaceholdersManager.untrackAll();
PlaceholdersManager.untrackAll();
NamedHologramManager.clearAll();
Set<String> savedHolograms = HologramDatabase.getHolograms();

View File

@ -12,11 +12,11 @@ public enum ConfigNode {
BUNGEE_REFRESH_SECONDS("bungee.refresh-seconds", 3),
BUNGEE_USE_REDIS_BUNGEE("bungee.use-RedisBungee", false),
BUNGEE_USE_FULL_PINGER("bungee.pinger.enable", false),
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 2000),
BUNGEE_PINGER_TIMEOUT("bungee.pinger.timeout", 500),
BUNGEE_PINGER_OFFLINE_MOTD("bungee.pinger.offline-motd", "&cOffline, couldn't get the MOTD."),
BUNGEE_PINGER_ONLINE_FORMAT("bungee.pinger.status.online", "&aOnline"),
BUNGEE_PINGER_OFFLINE_FORMAT("bungee.pinger.status.offline", "&cOffline"),
BUNGEE_PINGER_TRIM_MOTD("bungee.pinger.trim-motd", true),
BUNGEE_PINGER_TRIM_MOTD("bungee.pinger.motd-remove-leading-trailing-spaces", true),
BUNGEE_PINGER_SERVERS("bungee.pinger.servers", Arrays.asList("hub: 127.0.0.1:25565", "survival: 127.0.0.1:25566", "minigames: 127.0.0.1:25567")),
TIME_FORMAT("time.format", "H:mm"),
TIME_ZONE("time.zone", "GMT+1"),

View File

@ -35,11 +35,11 @@ public class Configuration {
public static boolean pingerEnable;
public static int pingerTimeout;
public static Map<String, ServerAddress> pingerServers;
public static String pingerOfflineMotd;
public static String pingerStatusOnline;
public static String pingerStatusOffline;
public static boolean pingerTrimMotd;
public static Map<String, ServerAddress> pingerServers;
public static boolean debug;
@ -130,7 +130,9 @@ public class Configuration {
pingerStatusOffline = StringConverter.toReadableFormat(config.getString(ConfigNode.BUNGEE_PINGER_OFFLINE_FORMAT.getPath()));
if (pingerTimeout <= 0) {
pingerTimeout = 1;
pingerTimeout = 100;
} else if (pingerTimeout >= 10000) {
pingerTimeout = 10000;
}
pingerServers = Utils.newMap();