Properly disallow async Player#chat (#8123)

Clarify asynchronous status of AsyncChatEvent
This commit is contained in:
Jake Potrebic 2023-12-28 16:50:06 -08:00 committed by GitHub
parent 2951732742
commit e4ab50de34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 78 additions and 65 deletions

View file

@ -497,7 +497,7 @@ new file mode 100644
index 0000000000000000000000000000000000000000..4eada40b8abb1833ce623ccee0789555e370d024
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java
@@ -0,0 +1,37 @@
@@ -0,0 +1,47 @@
+package io.papermc.paper.event.player;
+
+import java.util.Set;
@ -512,6 +512,16 @@ index 0000000000000000000000000000000000000000..4eada40b8abb1833ce623ccee0789555
+
+/**
+ * An event fired when a {@link Player} sends a chat message to the server.
+ * <p>
+ * This event will sometimes fire synchronously, depending on how it was
+ * triggered.
+ * <p>
+ * If a player is the direct cause of this event by an incoming packet, this
+ * event will be asynchronous. If a plugin triggers this event by compelling a
+ * player to chat, this event will be synchronous.
+ * <p>
+ * Care should be taken to check {@link #isAsynchronous()} and treat the event
+ * appropriately.
+ */
+public final class AsyncChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList();