19972e09b8
5a0150f586ed3eb15fe6f1f596d1a5a7d806f0f9 Fix ITEM_BREAK e6a3911057bd94d8bd7021cbb4923fb84fb106d1 Upstream merge d1cdcf8d4c3639f956474f02ed662517cffbe23e Remove old patch 068df64aeee368377e1673667bffc7a6dcf90554 Rebuild all patches
60 lines
3.2 KiB
Diff
60 lines
3.2 KiB
Diff
From 58c92688a9ff784173fd881118035ec2d2ba3398 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 ea9cdcc..a3e4438 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -615,9 +615,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;
|
|
@@ -641,10 +654,14 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
|
|
|
// CraftBukkit start
|
|
int itemstackAmount = itemstack.count;
|
|
+ // Spigot start - skip the event if throttled
|
|
+ if (!throttled) {
|
|
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
|
if (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
|
|
@@ -670,7 +687,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
|
|
|