2015-02-26 11:40:16 +01:00
|
|
|
From ee3b98fa8abed579526772e472ae6151805db4c2 Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02:00
|
|
|
From: Thinkofdeath <thinkofdeath@spigotmc.org>
|
|
|
|
Date: Sun, 29 Jun 2014 21:10:34 +0100
|
|
|
|
Subject: [PATCH] Limit block placement/interaction packets
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2015-02-26 11:40:16 +01:00
|
|
|
index 2cd242e..58cdeba 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2014-12-07 20:26:30 +01:00
|
|
|
@@ -616,9 +616,22 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
2014-11-28 02:17:45 +01:00
|
|
|
// CraftBukkit end
|
2014-07-21 22:46:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Spigot start - limit place/interactions
|
|
|
|
+ private long lastPlace = -1;
|
2014-07-25 05:21:57 +02:00
|
|
|
+ private int packets = 0;
|
2014-07-21 22:46:54 +02:00
|
|
|
+
|
|
|
|
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
2014-11-28 02:17:45 +01:00
|
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.u());
|
|
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
2014-07-21 22:46:54 +02:00
|
|
|
+ boolean throttled = false;
|
2014-07-25 05:21:57 +02:00
|
|
|
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
|
2014-07-21 22:46:54 +02:00
|
|
|
+ throttled = true;
|
2014-07-25 05:21:57 +02:00
|
|
|
+ } else if ( packetplayinblockplace.timestamp - lastPlace >= 30 || lastPlace == -1 )
|
2014-07-21 22:46:54 +02:00
|
|
|
+ {
|
|
|
|
+ lastPlace = packetplayinblockplace.timestamp;
|
2014-07-25 05:21:57 +02:00
|
|
|
+ packets = 0;
|
2014-07-21 22:46:54 +02:00
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
2014-11-28 02:17:45 +01:00
|
|
|
|
2014-07-21 22:46:54 +02:00
|
|
|
// CraftBukkit start
|
2014-11-28 02:17:45 +01:00
|
|
|
if (this.player.dead) return;
|
2014-12-07 20:26:30 +01:00
|
|
|
@@ -642,7 +655,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
int itemstackAmount = itemstack.count;
|
2014-12-07 20:26:30 +01:00
|
|
|
-
|
2014-07-21 22:46:54 +02:00
|
|
|
+ // Spigot start - skip the event if throttled
|
2014-12-07 20:26:30 +01:00
|
|
|
+ if (!throttled) {
|
|
|
|
// Raytrace to look for 'rogue armswings'
|
|
|
|
float f1 = this.player.pitch;
|
|
|
|
float f2 = this.player.yaw;
|
2014-12-10 02:58:37 +01:00
|
|
|
@@ -678,6 +692,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
|
|
if (!cancelled) {
|
2014-07-21 22:46:54 +02:00
|
|
|
this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
|
|
|
|
// CraftBukkit - notch decrements the counter by 1 in the above method with food,
|
|
|
|
// snowballs and so forth, but he does it in a place that doesn't cause the
|
2014-12-10 02:58:37 +01:00
|
|
|
@@ -703,7 +719,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
2014-07-21 22:46:54 +02:00
|
|
|
}
|
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
if (this.checkMovement && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.af().a(blockposition)) {
|
|
|
|
- always = !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, blockposition, enumdirection, packetplayinblockplace.d(), packetplayinblockplace.e(), packetplayinblockplace.f());
|
|
|
|
+ always = throttled || !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, blockposition, enumdirection, packetplayinblockplace.d(), packetplayinblockplace.e(), packetplayinblockplace.f());
|
2014-07-21 22:46:54 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2014-11-28 02:17:45 +01:00
|
|
|
|
2014-07-21 22:46:54 +02:00
|
|
|
--
|
2014-11-28 02:17:45 +01:00
|
|
|
2.1.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|