Class ServerChatEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.ServerChatEvent

public class ServerChatEvent extends net.minecraftforge.eventbus.api.Event
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 have a result. If the event is cancelled, the message will not be sent to clients.

This event is fired on the main Forge event bus, only on the logical server.

  • Nested Class Summary

    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

    Fields
    Modifier and Type
    Field
    Description
    private Component
     
    private final ServerPlayer
     
    private final String
     
    private final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServerChatEvent(ServerPlayer player, String rawText, Component message)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the message that will be sent to the relevant clients, if the event is not cancelled.
    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
    Set the message to be sent to the relevant clients.

    Methods inherited from class net.minecraftforge.eventbus.api.Event

    getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getPlayer

      public ServerPlayer getPlayer()
      Returns the player who initiated the chat action.
      Returns:
      the player who initiated the chat action
    • getUsername

      public String getUsername()
      Returns the username of the player who initiated the chat action.
      Returns:
      the username of the player who initiated the chat action
    • getRawText

      public String 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(Component message)
      Set the message to be sent to the relevant clients.
    • getMessage

      public 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