Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/main/scala/li/cil/oc/common/PacketHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ abstract class PacketHandler {
try {
stream = new ByteBufInputStream(data)
if (stream.read() != 0) stream = new InflaterInputStream(stream)
dispatch(new PacketParser(stream, player))
val packetParser = new PacketParser(stream, player)
dispatch(packetParser)

// Avoid AFK kicks by marking players as non-idle when they send packets.
// This will usually be stuff like typing while in screen GUIs.
player match {
case mp: EntityPlayerMP => {
packetParser.packetType match {
case PacketType.TextBufferInit | PacketType.RobotStateRequest => // This packet isn't a player interaction result, don't tick the afk timer
case _ => mp.func_143004_u()
}
}
case _ => // Uh... OK?
}
} catch {
case e: Throwable =>
OpenComputers.log.warn("Received a badly formatted packet.", e)
Expand All @@ -43,13 +56,6 @@ abstract class PacketHandler {
data.release();
}
}

// Avoid AFK kicks by marking players as non-idle when they send packets.
// This will usually be stuff like typing while in screen GUIs.
player match {
case mp: EntityPlayerMP => mp.func_143004_u()
case _ => // Uh... OK?
}
}

/**
Expand Down Expand Up @@ -146,4 +152,4 @@ abstract class PacketHandler {
def readPacketType() = PacketType(readByte())
}

}
}