Class VoicePlayerState

java.lang.Object
com.hypixel.hytale.server.core.modules.voice.VoicePlayerState

public class VoicePlayerState extends Object
Per-player voice state for rate limiting and tracking.
  • Constructor Details

    • VoicePlayerState

      public VoicePlayerState(@Nonnull UUID playerId, @Nonnull HytaleLogger logger, int burstCapacity)
  • Method Details

    • getPlayerId

      @Nonnull public UUID getPlayerId()
    • isSpeaking

      public boolean isSpeaking()
    • setSpeaking

      public void setSpeaking(boolean speaking)
    • isSilenced

      public boolean isSilenced()
    • setSilenced

      public void setSilenced(boolean silenced)
    • isRoutingDisabled

      public boolean isRoutingDisabled()
      Whether voice routing has been disabled for this player due to consecutive errors.
    • setRoutingDisabled

      public void setRoutingDisabled(boolean disabled)
      Sets whether voice routing is disabled for this player.
    • incrementConsecutiveErrors

      public int incrementConsecutiveErrors()
      Increments the consecutive error counter and returns the new count.
    • resetConsecutiveErrors

      public void resetConsecutiveErrors()
      Resets the consecutive error counter (called on successful routing).
    • getConsecutiveErrors

      public int getConsecutiveErrors()
      Gets the current consecutive error count.
    • checkRateLimit

      public boolean checkRateLimit(int maxPacketsPerSecond, int burstCapacity)
      Checks if a voice packet should be allowed based on token bucket rate limiting. Returns true if allowed, false if rate limited. Synchronized to ensure atomic compound operations across threads.
      Parameters:
      maxPacketsPerSecond - The sustained rate limit (tokens added per second)
      burstCapacity - The maximum burst allowance (max tokens in bucket)
    • shouldLogRateLimit

      public boolean shouldLogRateLimit()
      Checks if rate limiting should be logged (throttled to once per 10 seconds). Returns true if a log message should be emitted.
    • getLastPacketTime

      public long getLastPacketTime()
    • getTokenBucket

      public double getTokenBucket()
    • getTotalPacketsReceived

      public long getTotalPacketsReceived()
    • getTotalPacketsRateLimited

      public long getTotalPacketsRateLimited()
    • getSpeakingStateChanges

      public int getSpeakingStateChanges()
    • getStatsString

      public String getStatsString()
      Returns a summary string of statistics for debugging.