Paper/CraftBukkit-Patches/0143-Process-conversation-input-on-the-main-thread.-Fixes.patch
2014-06-22 19:28:17 +10:00

42 lines
1.7 KiB
Diff

From 8ca523f991cd751d079cad96e0222564263c1f6b Mon Sep 17 00:00:00 2001
From: riking <rikingcoding@gmail.com>
Date: Wed, 14 May 2014 13:46:48 -0700
Subject: [PATCH] Process conversation input on the main thread. Fixes
BUKKIT-5611
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index d7dff1e..c6fbf44 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -834,7 +834,25 @@ public class PlayerConnection implements PacketPlayInListener {
} else if (s.isEmpty()) {
c.warn(this.player.getName() + " tried to send an empty message");
} else if (getPlayer().isConversing()) {
- getPlayer().acceptConversationInput(s);
+ final String message = s;
+
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ getPlayer().acceptConversationInput(message);
+ return null;
+ }
+ };
+
+ this.minecraftServer.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
} else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
--
1.9.1