Record Class ChatMessage

java.lang.Object
java.lang.Record
com.ohacd.matchbox.api.ChatMessage
Record Components:
originalMessage - original message content (unmodified)
formattedMessage - formatted message used for display
sender - player who sent the message
senderId - UUID of the sender
channel - chat channel the message belongs to
sessionName - session name the message was sent in
isAlivePlayer - whether the sender is an alive player
timestamp - instant the message was recorded

public record ChatMessage(@NotNull net.kyori.adventure.text.Component originalMessage, @NotNull net.kyori.adventure.text.Component formattedMessage, @NotNull org.bukkit.entity.Player sender, @NotNull UUID senderId, @NotNull ChatChannel channel, @NotNull String sessionName, boolean isAlivePlayer, @NotNull Instant timestamp) extends Record
Immutable representation of a chat message with all metadata needed for routing. Used throughout the chat pipeline system.
Since:
0.9.5
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChatMessage(@NotNull net.kyori.adventure.text.Component originalMessage, @NotNull net.kyori.adventure.text.Component formattedMessage, @NotNull org.bukkit.entity.Player sender, @NotNull ChatChannel channel, @NotNull String sessionName, boolean isAlivePlayer)
    Creates a new ChatMessage with the current timestamp.
    ChatMessage(@NotNull net.kyori.adventure.text.Component originalMessage, @NotNull net.kyori.adventure.text.Component formattedMessage, @NotNull org.bukkit.entity.Player sender, @NotNull UUID senderId, @NotNull ChatChannel channel, @NotNull String sessionName, boolean isAlivePlayer, @NotNull Instant timestamp)
    Creates an instance of a ChatMessage record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull ChatChannel
    Returns the value of the channel record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    @NotNull net.kyori.adventure.text.Component
    Returns the value of the formattedMessage record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the isAlivePlayer record component.
    @NotNull net.kyori.adventure.text.Component
    Returns the value of the originalMessage record component.
    @NotNull org.bukkit.entity.Player
    Returns the value of the sender record component.
    @NotNull UUID
    Returns the value of the senderId record component.
    @NotNull String
    Returns the value of the sessionName record component.
    @NotNull Instant
    Returns the value of the timestamp record component.
    final String
    Returns a string representation of this record class.
    withChannel(@NotNull ChatChannel newChannel)
    Creates a copy of this message with a modified channel.
    withFormattedMessage(@NotNull net.kyori.adventure.text.Component newFormattedMessage)
    Creates a copy of this message with a modified formatted message.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ChatMessage

      public ChatMessage(@NotNull @NotNull net.kyori.adventure.text.Component originalMessage, @NotNull @NotNull net.kyori.adventure.text.Component formattedMessage, @NotNull @NotNull org.bukkit.entity.Player sender, @NotNull @NotNull ChatChannel channel, @NotNull @NotNull String sessionName, boolean isAlivePlayer)
      Creates a new ChatMessage with the current timestamp.
      Parameters:
      originalMessage - original message content (unmodified)
      formattedMessage - formatted message used for display
      sender - sender player
      channel - channel of message
      sessionName - session name
      isAlivePlayer - whether sender is alive
    • ChatMessage

      public ChatMessage(@NotNull @NotNull net.kyori.adventure.text.Component originalMessage, @NotNull @NotNull net.kyori.adventure.text.Component formattedMessage, @NotNull @NotNull org.bukkit.entity.Player sender, @NotNull @NotNull UUID senderId, @NotNull @NotNull ChatChannel channel, @NotNull @NotNull String sessionName, boolean isAlivePlayer, @NotNull @NotNull Instant timestamp)
      Creates an instance of a ChatMessage record class.
      Parameters:
      originalMessage - the value for the originalMessage record component
      formattedMessage - the value for the formattedMessage record component
      sender - the value for the sender record component
      senderId - the value for the senderId record component
      channel - the value for the channel record component
      sessionName - the value for the sessionName record component
      isAlivePlayer - the value for the isAlivePlayer record component
      timestamp - the value for the timestamp record component
  • Method Details

    • withFormattedMessage

      public ChatMessage withFormattedMessage(@NotNull @NotNull net.kyori.adventure.text.Component newFormattedMessage)
      Creates a copy of this message with a modified formatted message. Useful for processors that want to modify message content.
      Parameters:
      newFormattedMessage - the updated formatted message component
      Returns:
      a new ChatMessage with the modified formatted message
    • withChannel

      public ChatMessage withChannel(@NotNull @NotNull ChatChannel newChannel)
      Creates a copy of this message with a modified channel. Useful for processors that want to reroute messages.
      Parameters:
      newChannel - new chat channel for the message
      Returns:
      a new ChatMessage routed to the provided channel
    • 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 '=='.
      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.
    • originalMessage

      @NotNull public @NotNull net.kyori.adventure.text.Component originalMessage()
      Returns the value of the originalMessage record component.
      Returns:
      the value of the originalMessage record component
    • formattedMessage

      @NotNull public @NotNull net.kyori.adventure.text.Component formattedMessage()
      Returns the value of the formattedMessage record component.
      Returns:
      the value of the formattedMessage record component
    • sender

      @NotNull public @NotNull org.bukkit.entity.Player sender()
      Returns the value of the sender record component.
      Returns:
      the value of the sender record component
    • senderId

      @NotNull public @NotNull UUID senderId()
      Returns the value of the senderId record component.
      Returns:
      the value of the senderId record component
    • channel

      @NotNull public @NotNull ChatChannel channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component
    • sessionName

      @NotNull public @NotNull String sessionName()
      Returns the value of the sessionName record component.
      Returns:
      the value of the sessionName record component
    • isAlivePlayer

      public boolean isAlivePlayer()
      Returns the value of the isAlivePlayer record component.
      Returns:
      the value of the isAlivePlayer record component
    • timestamp

      @NotNull public @NotNull Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component