Class PacketTracker

java.lang.Object
com.viaversion.viaversion.api.protocol.packet.PacketTracker

public class PacketTracker extends Object
Tracks packet count/packet size.

Every second, the current rate of that second is put into a sliding window to be checked against a sustained max rate. After a sufficient amount of hits to the max rate during a configured time period, a connection will be kicked.

Next to the sustained tracking, the current count per second is also constantly checked against its respective max rate per second.

  • Constructor Details

  • Method Details

    • incrementSent

      public void incrementSent()
      Increments the number of packets sent to the client.
    • incrementReceived

      @Deprecated(forRemoval=true) public boolean incrementReceived()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • incrementReceived

      public boolean incrementReceived(int packetSize)
      Increments the number of packets and packet size received by clients. This is either added to the current second, or processed into the rate over multiple seconds.
      Returns:
      true if the interval has reset after a second has passed since the last update
    • exceedsLimits

      public boolean exceedsLimits()
    • getSentPackets

      public long getSentPackets()
    • setSentPackets

      @Deprecated(forRemoval=true) public void setSentPackets(long sentPackets)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getReceivedPackets

      public long getReceivedPackets()
    • setReceivedPackets

      @Deprecated(forRemoval=true) public void setReceivedPackets(long receivedPackets)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getIntervalPackets

      public long getIntervalPackets()
    • setIntervalPackets

      public void setIntervalPackets(long intervalPackets)
    • getPacketsPerSecond

      public int getPacketsPerSecond()
    • isPacketLimiterEnabled

      public boolean isPacketLimiterEnabled()
    • setPacketLimiterEnabled

      public void setPacketLimiterEnabled(boolean packetLimiterEnabled)
    • setWarnings

      @Deprecated(forRemoval=true) public void setWarnings(int warnings)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • reset

      public void reset()