Skip to content

Commit cd3018e

Browse files
me4502gabizou
authored andcommitted
Added an API to simulate Player chat.
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
1 parent 0abcf6a commit cd3018e

File tree

1 file changed

+25
-0
lines changed
  • src/main/java/org/spongepowered/api/entity/living/player

1 file changed

+25
-0
lines changed

src/main/java/org/spongepowered/api/entity/living/player/Player.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
import org.spongepowered.api.Server;
2828
import org.spongepowered.api.block.tileentity.EnderChest;
29+
import org.spongepowered.api.command.CommandManager;
30+
import org.spongepowered.api.command.CommandSource;
31+
import org.spongepowered.api.event.message.MessageChannelEvent;
32+
import org.spongepowered.api.text.channel.MessageReceiver;
33+
import org.spongepowered.api.text.chat.ChatType;
2934
import org.spongepowered.api.command.source.RemoteSource;
3035
import org.spongepowered.api.data.key.Keys;
3136
import org.spongepowered.api.data.manipulator.mutable.DisplayNameData;
@@ -130,6 +135,26 @@ default boolean isViewingInventory() {
130135
*/
131136
boolean isChatColorsEnabled();
132137

138+
/**
139+
* Simulates a chat message from a player.
140+
*
141+
* <p>This method sends a message as if it came from this player.
142+
* To send a message to this player instead, see
143+
* {@link MessageReceiver#sendMessage(Text)} or
144+
* {@link ChatTypeMessageReceiver#sendMessage(ChatType, Text)}.</p>
145+
*
146+
* <p>Commands cannot be sent using this method. To send commands, use
147+
* {@link CommandManager#process(CommandSource, String)}.</p>
148+
*
149+
* <p>If text formatting is not supported in the implementation
150+
* it will be displayed as plain text.</p>
151+
*
152+
* @param message The message to send
153+
* @param cause The cause for the message
154+
* @return The event that was thrown from sending the message
155+
*/
156+
MessageChannelEvent.Chat simulateChat(Text message, Cause cause);
157+
133158
/**
134159
* Gets the skin parts that this player has allowed to render.
135160
*

0 commit comments

Comments
 (0)