mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 15:33:43 +01:00
80 lines
2.8 KiB
Diff
80 lines
2.8 KiB
Diff
From 76b567282192c8c32c0d05050d3c410d28888e98 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/PacketPlayInArmAnimation.java b/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java
|
|
deleted file mode 100644
|
|
index cb0356e..0000000
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayInArmAnimation.java
|
|
+++ /dev/null
|
|
@@ -1,30 +0,0 @@
|
|
-package net.minecraft.server;
|
|
-
|
|
-import java.io.IOException;
|
|
-
|
|
-public class PacketPlayInArmAnimation implements Packet<PacketListenerPlayIn> {
|
|
-
|
|
- private EnumHand a;
|
|
-
|
|
- public PacketPlayInArmAnimation() {}
|
|
-
|
|
- public PacketPlayInArmAnimation(EnumHand enumhand) {
|
|
- this.a = enumhand;
|
|
- }
|
|
-
|
|
- public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
|
- this.a = (EnumHand) packetdataserializer.a(EnumHand.class);
|
|
- }
|
|
-
|
|
- public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
|
- packetdataserializer.a((Enum) this.a);
|
|
- }
|
|
-
|
|
- public void a(PacketListenerPlayIn packetlistenerplayin) {
|
|
- packetlistenerplayin.a(this);
|
|
- }
|
|
-
|
|
- public EnumHand a() {
|
|
- return this.a;
|
|
- }
|
|
-}
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index e263764..9e9dfb2 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -862,6 +862,10 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
|
|
}
|
|
|
|
+ // Spigot start - limit place/interactions
|
|
+ private long lastPlace = -1;
|
|
+ private int packets = 0;
|
|
+ // Spigot end
|
|
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
|
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
|
|
if (this.player.dead) return; // CraftBukkit
|
|
@@ -870,7 +874,17 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
ItemStack itemstack = this.player.b(enumhand);
|
|
|
|
this.player.resetIdleTimer();
|
|
- if (itemstack != null) {
|
|
+ // Spigot start
|
|
+ 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
|
|
+ if (!throttled && itemstack != null) { // Spigot - skip the event if throttled
|
|
// CraftBukkit start
|
|
// Raytrace to look for 'rogue armswings'
|
|
float f1 = this.player.pitch;
|
|
--
|
|
2.5.0
|
|
|