1
0
mirror of https://github.com/filoghost/HolographicDisplays.git synced 2024-12-29 12:17:36 +01:00

More clarity

This commit is contained in:
filoghost 2016-08-29 11:15:06 +02:00
parent 108e1bb995
commit 1548d73962

View File

@ -2,6 +2,7 @@ package com.gmail.filoghost.holographicdisplays.task;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerInfo;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker;
@ -11,17 +12,20 @@ import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
* A task to remove unused server data in the server tracker.
*/
public class BungeeCleanupTask implements Runnable {
private static final long MAX_INACTIVITY = TimeUnit.MINUTES.toMillis(10);
@Override
public void run() {
long now = System.currentTimeMillis();
Iterator<Entry<String, BungeeServerInfo>> iter = BungeeServerTracker.getTrackedServers().entrySet().iterator();
while (iter.hasNext()) {
Entry<String, BungeeServerInfo> next = iter.next();
long lastRequest = next.getValue().getLastRequest();
if (lastRequest != 0 && System.currentTimeMillis() - lastRequest > 600000) { // 10 * 60 * 1000 = 10 minutes.
if (lastRequest != 0 && now - lastRequest > MAX_INACTIVITY) {
// Don't track that server anymore.
iter.remove();
DebugHandler.logToConsole("Removed bungee server \"" + next.getKey() + "\" from tracking due to inactivity.");