Package net.minecraftforge.client.event
Class ClientChatReceivedEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.client.event.ClientChatReceivedEvent
- Direct Known Subclasses:
ClientChatReceivedEvent.System
public class ClientChatReceivedEvent
extends net.minecraftforge.eventbus.api.Event
Fired when a chat message is received on the client.
This can be used for filtering and detecting messages with specific words or phrases, and suppressing them.
This event is cancellable, and does not have a result. If the event is cancelled, the message is not displayed in the chat message window.
This event is fired on the main Forge event bus, only on the logical client.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Fired when a system chat message is received on the client.Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ChatType.Bound
private Component
private final MessageSigner
private final PlayerChatMessage
-
Constructor Summary
ModifierConstructorDescriptionprivate
ClientChatReceivedEvent
(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage) ClientChatReceivedEvent
(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner) -
Method Summary
Modifier and TypeMethodDescriptionReturns the bound chat type of the chat message.Returns the message that will be displayed in the chat message window, if the event is not cancelled.Returns the message signer.Returns the full player chat message.boolean
isSystem()
Returnstrue
if the message was sent by the system,false
otherwise.void
setMessage
(Component message) Sets the new message to be displayed in the chat message window, if the event is not cancelled.Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
Field Details
-
message
-
boundChatType
-
playerChatMessage
-
messageSigner
-
-
Constructor Details
-
ClientChatReceivedEvent
@Internal public ClientChatReceivedEvent(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner) -
ClientChatReceivedEvent
private ClientChatReceivedEvent(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage)
-
-
Method Details
-
getMessage
Returns the message that will be displayed in the chat message window, if the event is not cancelled.- Returns:
- the message that will be displayed in the chat message window, if the event is not cancelled
-
setMessage
Sets the new message to be displayed in the chat message window, if the event is not cancelled.- Parameters:
message
- the new message to be displayed
-
getBoundChatType
Returns the bound chat type of the chat message.. This contains the chat type, display name of the sender, and nullable target name depending on the chat type.- Returns:
- the bound chat type of the chat message
-
getPlayerChatMessage
Returns the full player chat message.. This contains the sender UUID, various signing data, and the optional unsigned contents.- Returns:
- the full player chat message
-
getMessageSigner
Returns the message signer.. This contains the sender UUID, timestamp of message creation, and signature salt. The sender UUID will beUtil.NIL_UUID
if the message is a system message.- Returns:
- the message signer
-
isSystem
public boolean isSystem()Returnstrue
if the message was sent by the system,false
otherwise.- Returns:
true
if the message was sent by the system,false
otherwise
-