Package com.ohacd.matchbox.api
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 displaysender- player who sent the messagesenderId- UUID of the senderchannel- chat channel the message belongs tosessionName- session name the message was sent inisAlivePlayer- whether the sender is an alive playertimestamp- 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
ConstructorsConstructorDescriptionChatMessage(@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 aChatMessagerecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull ChatChannelchannel()Returns the value of thechannelrecord component.final booleanIndicates whether some other object is "equal to" this one.@NotNull net.kyori.adventure.text.ComponentReturns the value of theformattedMessagerecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theisAlivePlayerrecord component.@NotNull net.kyori.adventure.text.ComponentReturns the value of theoriginalMessagerecord component.@NotNull org.bukkit.entity.Playersender()Returns the value of thesenderrecord component.@NotNull UUIDsenderId()Returns the value of thesenderIdrecord component.@NotNull StringReturns the value of thesessionNamerecord component.@NotNull InstantReturns the value of thetimestamprecord component.final StringtoString()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.
-
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 displaysender- sender playerchannel- channel of messagesessionName- session nameisAlivePlayer- 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 aChatMessagerecord class.- Parameters:
originalMessage- the value for theoriginalMessagerecord componentformattedMessage- the value for theformattedMessagerecord componentsender- the value for thesenderrecord componentsenderId- the value for thesenderIdrecord componentchannel- the value for thechannelrecord componentsessionName- the value for thesessionNamerecord componentisAlivePlayer- the value for theisAlivePlayerrecord componenttimestamp- the value for thetimestamprecord 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
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
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. -
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. -
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 '=='. -
originalMessage
@NotNull public @NotNull net.kyori.adventure.text.Component originalMessage()Returns the value of theoriginalMessagerecord component.- Returns:
- the value of the
originalMessagerecord component
-
formattedMessage
@NotNull public @NotNull net.kyori.adventure.text.Component formattedMessage()Returns the value of theformattedMessagerecord component.- Returns:
- the value of the
formattedMessagerecord component
-
sender
@NotNull public @NotNull org.bukkit.entity.Player sender()Returns the value of thesenderrecord component.- Returns:
- the value of the
senderrecord component
-
senderId
Returns the value of thesenderIdrecord component.- Returns:
- the value of the
senderIdrecord component
-
channel
Returns the value of thechannelrecord component.- Returns:
- the value of the
channelrecord component
-
sessionName
Returns the value of thesessionNamerecord component.- Returns:
- the value of the
sessionNamerecord component
-
isAlivePlayer
public boolean isAlivePlayer()Returns the value of theisAlivePlayerrecord component.- Returns:
- the value of the
isAlivePlayerrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-