Class UserChatEvent

    • Constructor Detail

      • UserChatEvent

        public UserChatEvent​(@NotNull
                             @NotNull User user,
                             @NotNull
                             @NotNull String message,
                             boolean cancelled,
                             boolean cancellable,
                             boolean modifiable)
        User chat event constructor.
        Parameters:
        user - User that sent the message.
        message - Message that the user attempted to send.
        cancelled - Whether this event is cancelled.
        cancellable - Whether this event can be cancelled on this platform.
        modifiable - Whether this event can be modified on this platform.
    • Method Detail

      • getUser

        @NotNull
        public @NotNull User getUser()
        Returns the user who sent this message.
        Specified by:
        getUser in interface UserEvent
        Returns:
        message sender.
      • getMessage

        @NotNull
        public @NotNull String getMessage()
        Returns the message that was sent.
        Returns:
        message.
      • setMessage

        public void setMessage​(@NotNull
                               @NotNull String message)
        Changes the chat message.

        Due to changes in Minecraft 1.19.1+, some platforms no longer support modifying the chat message. If the current platform does not support changing the chat message, no changes will be made.

        Parameters:
        message - New message.
      • isCancellable

        public boolean isCancellable()
        Returns whether this event can be cancelled.

        Due to changes in Minecraft 1.19.1+, some platforms no longer support cancelling signed chat packets. If the current platform does not support cancelling this event, this will return false.

        If this method returns false, but the event is cancelled, the event will not be cancelled on the platform to prevent problems from occurring.

        Returns:
        true if this chat event can be cancelled on the underlying platform, otherwise false.
      • isModifiable

        public boolean isModifiable()
        Returns whether this event can be modified.

        Due to changes in Minecraft 1.19.1+, some platforms no longer support modifying the chat message. If the current platform does not support changing the chat message for this event, this will return false.

        If this method returns false, but the chat message is modified, the event's chat message will not be changed on the platform to prevent problems from occurring.

        Returns:
        true if this chat event can be modified on the underlying platform, otherwise false.