398f6983bd
Make "moved too quickly" limit configurable SpigotMC/Spigot@99a0a640e8 Undeprecate Player#updateInventory()V SpigotMC/Spigot@5c32e1cb48 Fetch complete profile for skull items, similarly to TileEntitySkull. SpigotMC/Spigot@33d758773e Move getDouble into the Spigot Configuration patch SpigotMC/Spigot@b5dd202af1 Add missing particle to particle API SpigotMC/Spigot@273c64bbad Log debug levels to the log file. SpigotMC/Spigot@348eae75f4 Fix PlayerItemDamageEvent (we already had this #badupstreamrelations) SpigotMC/Spigot@e207ea23cd Move hopper patch to top for PR180 SpigotMC/Spigot@abb775108d Don't be so spammy on Java 6 SpigotMC/Spigot@5abb82b1ca Apply NBTReadLimiter to more things SpigotMC/Spigot@408944e9f5
58 lines
2.8 KiB
Diff
58 lines
2.8 KiB
Diff
From 9d0db6f7de036491b343ae39b3aebbb824248818 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 9491101..20c49e3 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -573,7 +573,20 @@ public class PlayerConnection implements PacketPlayInListener {
|
|
}
|
|
}
|
|
|
|
+ // Spigot start - limit place/interactions
|
|
+ private long lastPlace = -1;
|
|
+ private int packets = 0;
|
|
+
|
|
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
|
+ 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
|
|
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
|
|
|
// CraftBukkit start
|
|
@@ -616,10 +629,14 @@ public class PlayerConnection implements PacketPlayInListener {
|
|
|
|
// 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
|
|
@@ -640,7 +657,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
|
return;
|
|
}
|
|
|
|
- if (!this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j())) {
|
|
+ if (throttled || !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j())) { // Spigot - skip the event if throttled
|
|
always = true; // force PacketPlayOutSetSlot to be sent to client to update ItemStack count
|
|
}
|
|
// CraftBukkit end
|
|
--
|
|
1.9.1
|
|
|