diff --git a/Server/src/main/core/net/packet/PacketProcessor.kt b/Server/src/main/core/net/packet/PacketProcessor.kt index 51e4324e9..875d3693f 100644 --- a/Server/src/main/core/net/packet/PacketProcessor.kt +++ b/Server/src/main/core/net/packet/PacketProcessor.kt @@ -307,8 +307,24 @@ object PacketProcessor { pkt.player.interfaceManager.switchWindowMode(pkt.windowMode) } is Packet.TrackingAfkTimeout -> { - //if (pkt.player.details.rights != Rights.ADMINISTRATOR) - //pkt.player.packetDispatch.sendLogout() + /* After 5 minutes idle, the client sends an afk packet every 10 seconds. + *This code counts the number of afk packets recieved, resetting the count if they are more than 100 ticks apart. + *This allows us to customize the afk logout timer + */ + if (pkt.player.details.rights != Rights.ADMINISTRATOR) { + if (GameWorld.ticks - pkt.player.getAttribute("afk:lasttick", 0) > 100) { + pkt.player.setAttribute("afk:count", 0) + } else { + pkt.player.setAttribute("afk:count", pkt.player.getAttribute("afk:count", 0) + 1) + } + pkt.player.setAttribute("afk:lasttick", GameWorld.ticks) + if (pkt.player.getAttribute("afk:count", 0) == 300) { + pkt.player.sendMessage("