Package net.neoforged.neoforge.event
Class ServerChatEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.ServerChatEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
public class ServerChatEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.bus.api.ICancellableEvent
This event is fired whenever a
ServerboundChatPacket
is received from a client
who has submitted their chat message.
This event is cancellable, and does not
.
If the event is cancelled, the message will not be sent to clients.
invalid reference
have a result
This event is fired on the main Forge event bus, only on the logical server.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServerChatEvent
(net.minecraft.server.level.ServerPlayer player, String rawText, net.minecraft.network.chat.Component message) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.Component
Returns the message that will be sent to the relevant clients, if the event is not cancelled.net.minecraft.server.level.ServerPlayer
Returns the player who initiated the chat action.Returns the original raw text of the player chat message.Returns the username of the player who initiated the chat action.void
setMessage
(net.minecraft.network.chat.Component message) Set the message to be sent to the relevant clients.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
player
private final net.minecraft.server.level.ServerPlayer player -
username
-
rawText
-
message
private net.minecraft.network.chat.Component message
-
-
Constructor Details
-
ServerChatEvent
@Internal public ServerChatEvent(net.minecraft.server.level.ServerPlayer player, String rawText, net.minecraft.network.chat.Component message)
-
-
Method Details
-
getPlayer
public net.minecraft.server.level.ServerPlayer getPlayer()Returns the player who initiated the chat action.- Returns:
- the player who initiated the chat action
-
getUsername
Returns the username of the player who initiated the chat action.- Returns:
- the username of the player who initiated the chat action
-
getRawText
Returns the original raw text of the player chat message.- Returns:
- the original raw text of the player chat message
-
setMessage
public void setMessage(net.minecraft.network.chat.Component message) Set the message to be sent to the relevant clients. -
getMessage
public net.minecraft.network.chat.Component getMessage()Returns the message that will be sent to the relevant clients, if the event is not cancelled.- Returns:
- the message that will be sent to the relevant clients, if the event is not cancelled
-