mirror of
https://github.com/PaperMC/Paper.git
synced 2025-09-01 04:43:50 -07:00
Properly disallow async Player#chat (#8123)
Clarify asynchronous status of AsyncChatEvent
This commit is contained in:
@@ -512,6 +512,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
+ * An event fired when a {@link Player} sends a chat message to the server.
|
+ * 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 {
|
+public final class AsyncChatEvent extends AbstractChatEvent {
|
||||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
@@ -2947,6 +2947,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- } else {
|
- } else {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ } else if (true) {
|
+ } else if (true) {
|
||||||
|
+ if (!async && !org.bukkit.Bukkit.isPrimaryThread()) {
|
||||||
|
+ org.spigotmc.AsyncCatcher.catchOp("Asynchronous player chat is not allowed here");
|
||||||
|
+ }
|
||||||
+ final ChatProcessor cp = new ChatProcessor(this.server, this.player, original, async);
|
+ final ChatProcessor cp = new ChatProcessor(this.server, this.player, original, async);
|
||||||
+ cp.process();
|
+ cp.process();
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
Reference in New Issue
Block a user