Record Class ChatMessage
java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.ChatMessage
- Record Components:
sourceProxyId- the proxy that originated the messagetimestamp- when the message was senttargetPlayerUuid- UUID of target player (null for broadcast)targetPlayerName- name of target player (null for broadcast)message- the chat message contentsenderName- display name of the sendersenderUuid- UUID of the sender (null for system messages)
- All Implemented Interfaces:
ChannelMessage
public record ChatMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nullable UUID targetPlayerUuid, @Nullable String targetPlayerName, @Nonnull String message, @Nonnull String senderName, @Nullable UUID senderUuid)
extends Record
implements ChannelMessage
Cross-proxy chat message for delivering messages to players on other proxies.
Enables features like:
- Private messaging across proxies
- Global chat broadcasts
- Staff communication channels
Usage
// Send a private message to a player (might be on another proxy)
ChatMessage msg = new ChatMessage(
proxyId, Instant.now(),
targetUuid, targetName,
"Hello from another proxy!",
senderName, senderUuid
);
messaging.publish(Channels.CHAT, msg);
// Subscribe to receive chat messages
@Subscribe(SystemChannel.CHAT)
public void onChat(ChatMessage chat) {
if (chat.isBroadcast()) {
// Global message
} else {
// Targeted message
}
}
-
Constructor Summary
Constructors -
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.booleanCheck if this is a broadcast message (no specific target).message()Returns the value of themessagerecord component.Get the message type identifier for serialization.Returns the value of thesenderNamerecord component.Returns the value of thesenderUuidrecord component.Returns the value of thesourceProxyIdrecord component.Returns the value of thetargetPlayerNamerecord component.Returns the value of thetargetPlayerUuidrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ChatMessage
public ChatMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nullable UUID targetPlayerUuid, @Nullable String targetPlayerName, @Nonnull String message, @Nonnull String senderName, @Nullable UUID senderUuid) Creates an instance of aChatMessagerecord class.- Parameters:
sourceProxyId- the value for thesourceProxyIdrecord componenttimestamp- the value for thetimestamprecord componenttargetPlayerUuid- the value for thetargetPlayerUuidrecord componenttargetPlayerName- the value for thetargetPlayerNamerecord componentmessage- the value for themessagerecord componentsenderName- the value for thesenderNamerecord componentsenderUuid- the value for thesenderUuidrecord component
-
-
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")
-
isBroadcast
public boolean isBroadcast()Check if this is a broadcast message (no specific target).- Returns:
- true if this message should be delivered to all players
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
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
-
targetPlayerUuid
Returns the value of thetargetPlayerUuidrecord component.- Returns:
- the value of the
targetPlayerUuidrecord component
-
targetPlayerName
Returns the value of thetargetPlayerNamerecord component.- Returns:
- the value of the
targetPlayerNamerecord component
-
message
-
senderName
Returns the value of thesenderNamerecord component.- Returns:
- the value of the
senderNamerecord component
-
senderUuid
Returns the value of thesenderUuidrecord component.- Returns:
- the value of the
senderUuidrecord component
-