testserver/CraftBukkit-Patches/0084-Disconnect-for-spam-in...

43 lines
1.8 KiB
Diff
Raw Normal View History

2014-01-22 08:19:39 +00:00
From bb7fa8838e6ec0bfefb57159d8e33dc0e06cf6d2 Mon Sep 17 00:00:00 2001
2014-01-03 17:32:20 +00:00
From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Fri, 3 Jan 2014 17:30:52 +0000
Subject: [PATCH] Disconnect for spam in the main thread
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 1903362..f7fdca3 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -838,7 +838,27 @@ public class PlayerConnection implements PacketPlayInListener {
// this.chatThrottle += 20;
if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getName())) {
// CraftBukkit end
- this.disconnect("disconnect.spam");
+ if (packetplayinchat.a()) { // Spigot - Thread safety
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect( "disconnect.spam" );
+ return null;
+ }
+ };
+
+ this.minecraftServer.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ PlayerConnection.this.disconnect( "disconnect.spam" );
+ }
}
}
}
--
2014-01-22 08:19:39 +00:00
1.8.3.2
2014-01-03 17:32:20 +00:00