Message API: update javadoc for 22w42a ()

This commit is contained in:
apple502j 2022-10-29 02:26:52 +09:00 committed by GitHub
parent 51f6ee1127
commit 6ede1da9e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 33 deletions
fabric-message-api-v1/src/main/java/net/fabricmc/fabric/api/message/v1

View file

@ -41,13 +41,6 @@ import net.fabricmc.fabric.api.event.EventFactory;
* function. If not given, the message decorator will run in the default phase, which is between
* the content phase and the styling phase.
*
* <p>The message decorator's result is cached (as of 1.19.1) if the chat preview is enabled.
* If the original message did not change between the last preview and submission, the decorator
* is not called during submission and the cached preview is used instead. Note that the
* decorator can still be called during submission if the chat preview is disabled, the
* sent message was not the same as the previewed message, or if text filtering was enabled and
* it produced a different message.
*
* <p>Example of registering a content phase message decorator:
*
* <pre>{@code

View file

@ -26,19 +26,21 @@ import net.minecraft.text.Text;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
/**
* Contains server-side events triggered when broadcasting messages.
*/
public final class ServerMessageEvents {
/**
* An event triggered when the server broadcasts a chat message sent by a player,
* typically from a client GUI or a player-executed command. Mods can use this to block
* the message body, but due to client-side limitations, the header (which includes the
* sender profile) will always be sent.
* the message.
*
* <p>If a listener returned {@code false}, the message body will not be broadcast,
* <p>If a listener returned {@code false}, the message will not be broadcast,
* the remaining listeners will not be called (if any), and {@link #CHAT_MESSAGE}
* event will not be triggered.
*
* <p>If the message is from a player-executed command, this will be called
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message body,
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message,
* and after triggering {@link #COMMAND_MESSAGE} event.
*/
public static final Event<AllowChatMessage> ALLOW_CHAT_MESSAGE = EventFactory.createArrayBacked(AllowChatMessage.class, handlers -> (message, sender, params) -> {
@ -69,14 +71,13 @@ public final class ServerMessageEvents {
/**
* An event triggered when the server broadcasts a command message to all players, such as one
* from {@code /me} and {@code /say} (but not ones that specify the recipients like
* {@code /msg}). Mods can use this to block the message body, but due to client-side
* limitations, the header (which includes the sender profile) will always be sent.
* {@code /msg}). Mods can use this to block the message.
*
* <p>If a listener returned {@code false}, the message body will not be broadcast,
* <p>If a listener returned {@code false}, the message will not be broadcast,
* the remaining listeners will not be called (if any), and {@link #COMMAND_MESSAGE}
* event will not be triggered.
*
* <p>If the command is executed by a player and the message body is not blocked,
* <p>If the command is executed by a player and the message is not blocked,
* {@link #ALLOW_CHAT_MESSAGE} and {@link #CHAT_MESSAGE} events will also be
* triggered after triggering {@link #COMMAND_MESSAGE}.
*/
@ -91,10 +92,10 @@ public final class ServerMessageEvents {
/**
* An event triggered when the server broadcasts a chat message sent by a player, typically
* from a client GUI or a player-executed command. Is not called when {@linkplain
* #ALLOW_CHAT_MESSAGE chat message bodies are blocked}.
* #ALLOW_CHAT_MESSAGE chat messages are blocked}.
*
* <p>If the message is from a player-executed command, this will be called
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message body,
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message,
* and after triggering {@link #COMMAND_MESSAGE} event.
*/
public static final Event<ChatMessage> CHAT_MESSAGE = EventFactory.createArrayBacked(ChatMessage.class, handlers -> (message, sender, params) -> {
@ -117,8 +118,8 @@ public final class ServerMessageEvents {
/**
* An event triggered when the server broadcasts a command message to all players, such as one
* from {@code /me} and {@code /say} (but not ones that specify the recipients like
* {@code /msg}). Is not called when {@linkplain #ALLOW_COMMAND_MESSAGE command message
* bodies are blocked}.
* {@code /msg}). Is not called when {@linkplain #ALLOW_COMMAND_MESSAGE command messages
* are blocked}.
*
* <p>If the command is executed by a player, {@link #ALLOW_CHAT_MESSAGE} and
* {@link #CHAT_MESSAGE} events will also be triggered after this event.
@ -137,18 +138,17 @@ public final class ServerMessageEvents {
/**
* Called when the server broadcasts a chat message sent by a player, typically
* from a client GUI or a player-executed command. Returning {@code false}
* prevents the message body from being broadcast and the {@link #CHAT_MESSAGE} event
* from triggering. However, the header (which includes the sender profile) will always
* be sent.
* prevents the message from being broadcast and the {@link #CHAT_MESSAGE} event
* from triggering.
*
* <p>If the message is from a player-executed command, this will be called
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message body,
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message,
* and after triggering {@link #COMMAND_MESSAGE} event.
*
* @param message the broadcast message with message decorators applied; use {@code message.getContent()} to get the text
* @param sender the player that sent the message
* @param params the {@link MessageType.Parameters}
* @return {@code true} if the message body should be broadcast, otherwise {@code false}
* @return {@code true} if the message should be broadcast, otherwise {@code false}
*/
boolean allowChatMessage(SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters params);
}
@ -174,18 +174,17 @@ public final class ServerMessageEvents {
/**
* Called when the server broadcasts a command message to all players, such as one
* from {@code /me} and {@code /say} (but not ones that specify the recipients like
* {@code /msg}). Returning {@code false} prevents the message body from being broadcast
* and the {@link #COMMAND_MESSAGE} event from triggering. However, the header (which
* includes the sender profile) will always be sent.
* {@code /msg}). Returning {@code false} prevents the message from being broadcast
* and the {@link #COMMAND_MESSAGE} event from triggering.
*
* <p>If the command is executed by a player and the message body is not blocked,
* <p>If the command is executed by a player and the message is not blocked,
* {@link #ALLOW_CHAT_MESSAGE} and {@link #CHAT_MESSAGE} events will also be
* triggered after triggering {@link #COMMAND_MESSAGE}.
*
* @param message the broadcast message with message decorators applied if applicable; use {@code message.getContent()} to get the text
* @param source the command source that sent the message
* @param params the {@link MessageType.Parameters}
* @return {@code true} if the message body should be broadcast, otherwise {@code false}
* @return {@code true} if the message should be broadcast, otherwise {@code false}
*/
boolean allowCommandMessage(SignedMessage message, ServerCommandSource source, MessageType.Parameters params);
}
@ -195,10 +194,10 @@ public final class ServerMessageEvents {
/**
* Called when the server broadcasts a chat message sent by a player, typically
* from a client GUI or a player-executed command. Is not called when {@linkplain
* #ALLOW_CHAT_MESSAGE chat message bodies are blocked}.
* #ALLOW_CHAT_MESSAGE chat messages are blocked}.
*
* <p>If the message is from a player-executed command, this will be called
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message body,
* only if {@link #ALLOW_COMMAND_MESSAGE} event did not block the message,
* and after triggering {@link #COMMAND_MESSAGE} event.
*
* @param message the broadcast message with message decorators applied; use {@code message.getContent()} to get the text
@ -227,8 +226,8 @@ public final class ServerMessageEvents {
/**
* Called when the server broadcasts a command message to all players, such as one
* from {@code /me} and {@code /say} (but not ones that specify the recipients like
* {@code /msg}). Is not called when {@linkplain #ALLOW_COMMAND_MESSAGE command message
* bodies are blocked}.
* {@code /msg}). Is not called when {@linkplain #ALLOW_COMMAND_MESSAGE command messages
* are blocked}.
*
* <p>If the command is executed by a player, {@link #ALLOW_CHAT_MESSAGE} and
* {@link #CHAT_MESSAGE} events will also be triggered after this event.