Fixed offline servers sometimes not being marked as offline on velocity

This commit is contained in:
ajgeiss0702
2022-10-20 13:48:31 -07:00
parent 11dcda49fd
commit d78c795288
4 changed files with 38 additions and 19 deletions
@@ -52,16 +52,7 @@ public class BungeeServer implements AdaptedServer {
handle.ping((pp, error) -> {
if(error != null) {
long lastOnline = lastSuccessfullPing == null ? 0 : lastSuccessfullPing.getFetchedTime();
offlineTime = (int) Math.min(sent - lastOnline, Integer.MAX_VALUE);
lastOffline = sent;
future.completeExceptionally(error);
lastPing = null;
if(debug) logger.info("[pinger] [" + getName() + "] offline:", error);
return;
markOffline(debug, logger, future, sent, error);
}
offlineTime = 0;
@@ -80,6 +71,17 @@ public class BungeeServer implements AdaptedServer {
return future;
}
private void markOffline(boolean debug, QueueLogger logger, CompletableFuture<AdaptedServerPing> future, long sent, Throwable e) {
long lastOnline = lastSuccessfullPing == null ? 0 : lastSuccessfullPing.getFetchedTime();
offlineTime = (int) Math.min(sent - lastOnline, Integer.MAX_VALUE);
lastOffline = sent;
future.completeExceptionally(e);
lastPing = null;
if(debug) logger.info("[pinger] [" + getName() + "] offline:", e);
}
@Override
public Optional<AdaptedServerPing> getLastPing() {
return Optional.ofNullable(lastPing);