Class UserChatEvent
- java.lang.Object
-
- dev.hypera.chameleon.event.AbstractCancellable
-
- dev.hypera.chameleon.event.common.UserChatEvent
-
- All Implemented Interfaces:
Cancellable,ChameleonEvent,UserEvent
public final class UserChatEvent extends AbstractCancellable implements UserEvent
User chat event, dispatched when a player sends a chat message.
-
-
Constructor Summary
Constructors Constructor Description UserChatEvent(@NotNull User user, @NotNull String message, boolean cancelled, boolean cancellable, boolean modifiable)User chat event constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull StringgetMessage()Returns the message that was sent.@NotNull UsergetUser()Returns the user who sent this message.booleanisCancellable()Returns whether this event can be cancelled.booleanisModifiable()Returns whether this event can be modified.voidsetMessage(@NotNull String message)Changes the chat message.-
Methods inherited from class dev.hypera.chameleon.event.AbstractCancellable
isCancelled, setCancelled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.hypera.chameleon.event.Cancellable
cancel, uncancel
-
-
-
-
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.
-
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:
trueif this chat event can be cancelled on the underlying platform, otherwisefalse.
-
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:
trueif this chat event can be modified on the underlying platform, otherwisefalse.
-
-