Record Class PlayerCountMessage
java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.PlayerCountMessage
- Record Components:
sourceProxyId- the proxy reporting its player counttimestamp- when the count was recordedplayerCount- current number of connected playersmaxPlayers- 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 Summary
ConstructorsConstructorDescriptionPlayerCountMessage(String sourceProxyId, 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 Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxPlayersrecord component.Get the message type identifier for serialization.intReturns the value of theplayerCountrecord component.Returns the value of thesourceProxyIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PlayerCountMessage
-
-
Method Details
-
messageType
Description copied from interface:ChannelMessageGet the message type identifier for serialization.- Specified by:
messageTypein interfaceChannelMessage- Returns:
- the message type (e.g., "heartbeat", "chat", "plugin")
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
sourceProxyId
Returns the value of thesourceProxyIdrecord component.- Specified by:
sourceProxyIdin interfaceChannelMessage- Returns:
- the value of the
sourceProxyIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceChannelMessage- Returns:
- the value of the
timestamprecord component
-
playerCount
public int playerCount()Returns the value of theplayerCountrecord component.- Returns:
- the value of the
playerCountrecord component
-
maxPlayers
public int maxPlayers()Returns the value of themaxPlayersrecord component.- Returns:
- the value of the
maxPlayersrecord component
-