mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-07 19:31:45 +01:00
Implemented afk check on kick event #705 Note about AFK ignore perm:
- Players kicked by afk that have plan.ignore.afk will be counted as "real" kicks.
This commit is contained in:
parent
08d1067bd8
commit
333936cfa8
@ -65,4 +65,14 @@ public class AFKTracker {
|
|||||||
lastMovement.remove(uuid);
|
lastMovement.remove(uuid);
|
||||||
usedAFKCommand.remove(uuid);
|
usedAFKCommand.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAfk(UUID uuid) {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
Long lastMoved = lastMovement.get(uuid);
|
||||||
|
if (lastMoved == null || lastMoved == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return time - lastMoved > afkThresholdMs;
|
||||||
|
}
|
||||||
}
|
}
|
@ -63,6 +63,10 @@ public class PlayerOnlineListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = event.getPlayer().getUniqueId();
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
if (AFKListener.AFK_TRACKER.isAfk(uuid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Processing.submit(new KickProcessor(uuid));
|
Processing.submit(new KickProcessor(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
Log.toLog(this.getClass(), e);
|
||||||
|
@ -2,6 +2,7 @@ package com.djrapitops.plan.system.listeners.sponge;
|
|||||||
|
|
||||||
import com.djrapitops.plan.data.container.Session;
|
import com.djrapitops.plan.data.container.Session;
|
||||||
import com.djrapitops.plan.system.cache.SessionCache;
|
import com.djrapitops.plan.system.cache.SessionCache;
|
||||||
|
import com.djrapitops.plan.system.listeners.bukkit.AFKListener;
|
||||||
import com.djrapitops.plan.system.processing.Processing;
|
import com.djrapitops.plan.system.processing.Processing;
|
||||||
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
|
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
|
||||||
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
|
import com.djrapitops.plan.system.processing.processors.info.PlayerPageUpdateProcessor;
|
||||||
@ -52,6 +53,9 @@ public class SpongePlayerListener {
|
|||||||
public void onKick(KickPlayerEvent event) {
|
public void onKick(KickPlayerEvent event) {
|
||||||
try {
|
try {
|
||||||
UUID uuid = event.getTargetEntity().getUniqueId();
|
UUID uuid = event.getTargetEntity().getUniqueId();
|
||||||
|
if (AFKListener.AFK_TRACKER.isAfk(uuid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Processing.submit(new KickProcessor(uuid));
|
Processing.submit(new KickProcessor(uuid));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass(), e);
|
Log.toLog(this.getClass(), e);
|
||||||
|
Loading…
Reference in New Issue
Block a user