Record Class PlayerCountMessage

java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.PlayerCountMessage
Record Components:
sourceProxyId - the proxy reporting its player count
timestamp - when the count was recorded
playerCount - current number of connected players
maxPlayers - maximum player capacity of the proxy
All Implemented Interfaces:
ChannelMessage

public record PlayerCountMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, int playerCount, int maxPlayers) extends Record implements ChannelMessage
Player count update message for synchronizing counts across proxies.

Used to track the total number of players across the proxy cluster. This enables features like:

  • Displaying accurate global player counts
  • Load balancing decisions
  • Capacity planning

Usage

@Subscribe(SystemChannel.PLAYER_COUNT)
public void onPlayerCount(PlayerCountMessage msg) {
    logger.info("Proxy {} has {}/{} players",
        msg.sourceProxyId(), msg.playerCount(), msg.maxPlayers());
}
  • Constructor Details

    • PlayerCountMessage

      public PlayerCountMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, int playerCount, int maxPlayers)
      Validates that sourceProxyId and timestamp are not null, and that player counts are non-negative and within capacity.
  • Method Details

    • messageType

      @Nonnull public String messageType()
      Description copied from interface: ChannelMessage
      Get the message type identifier for serialization.
      Specified by:
      messageType in interface ChannelMessage
      Returns:
      the message type (e.g., "heartbeat", "chat", "plugin")
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • sourceProxyId

      @Nonnull public String sourceProxyId()
      Returns the value of the sourceProxyId record component.
      Specified by:
      sourceProxyId in interface ChannelMessage
      Returns:
      the value of the sourceProxyId record component
    • timestamp

      @Nonnull public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface ChannelMessage
      Returns:
      the value of the timestamp record component
    • playerCount

      public int playerCount()
      Returns the value of the playerCount record component.
      Returns:
      the value of the playerCount record component
    • maxPlayers

      public int maxPlayers()
      Returns the value of the maxPlayers record component.
      Returns:
      the value of the maxPlayers record component