geforkt von Mirrors/Paper
28414e7e28
6669d6ecd2b b2740df50bb bf71dc61149 fba27a2ea80 92ee7e7f8ec b28f0d3de23 4beb4ac3918 0ddb6f3dde8 afe301fe892 b8f6402bbbe
65 Zeilen
3.3 KiB
Diff
65 Zeilen
3.3 KiB
Diff
From 06d434b6ee068029e1ae6ac736ef2956d057c151 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 7ff587b..6ba95d4 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -616,9 +616,22 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ // Spigot start - limit place/interactions
|
|
+ private long lastPlace = -1;
|
|
+ private int packets = 0;
|
|
+
|
|
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.u());
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
|
+ boolean throttled = false;
|
|
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
|
|
+ throttled = true;
|
|
+ } else if ( packetplayinblockplace.timestamp - lastPlace >= 30 || lastPlace == -1 )
|
|
+ {
|
|
+ lastPlace = packetplayinblockplace.timestamp;
|
|
+ packets = 0;
|
|
+ }
|
|
+ // Spigot end
|
|
|
|
// CraftBukkit start
|
|
if (this.player.dead) return;
|
|
@@ -642,7 +655,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
|
|
// CraftBukkit start
|
|
int itemstackAmount = itemstack.count;
|
|
-
|
|
+ // Spigot start - skip the event if throttled
|
|
+ if (!throttled) {
|
|
// Raytrace to look for 'rogue armswings'
|
|
float f1 = this.player.pitch;
|
|
float f2 = this.player.yaw;
|
|
@@ -668,6 +682,8 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
if (event == null || event.useItemInHand() != Event.Result.DENY) {
|
|
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
|
|
@@ -693,7 +709,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
}
|
|
|
|
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());
|
|
}
|
|
// CraftBukkit end
|
|
|
|
--
|
|
2.1.0
|
|
|