Record Class ChatMessage

java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.ChatMessage
Record Components:
sourceProxyId - the proxy that originated the message
timestamp - when the message was sent
targetPlayerUuid - UUID of target player (null for broadcast)
targetPlayerName - name of target player (null for broadcast)
message - the chat message content
senderName - display name of the sender
senderUuid - 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 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 a ChatMessage record class.
      Parameters:
      sourceProxyId - the value for the sourceProxyId record component
      timestamp - the value for the timestamp record component
      targetPlayerUuid - the value for the targetPlayerUuid record component
      targetPlayerName - the value for the targetPlayerName record component
      message - the value for the message record component
      senderName - the value for the senderName record component
      senderUuid - the value for the senderUuid record component
  • 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")
    • 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

      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. All components in this record class are compared with Objects::equals(Object,Object).
      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
    • targetPlayerUuid

      @Nullable public UUID targetPlayerUuid()
      Returns the value of the targetPlayerUuid record component.
      Returns:
      the value of the targetPlayerUuid record component
    • targetPlayerName

      @Nullable public String targetPlayerName()
      Returns the value of the targetPlayerName record component.
      Returns:
      the value of the targetPlayerName record component
    • message

      @Nonnull public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • senderName

      @Nonnull public String senderName()
      Returns the value of the senderName record component.
      Returns:
      the value of the senderName record component
    • senderUuid

      @Nullable public UUID senderUuid()
      Returns the value of the senderUuid record component.
      Returns:
      the value of the senderUuid record component