Update from upstream SpigotMC

Don't use Bukkit.getLogger as the CraftServer isn't loaded at this point SpigotMC/Spigot@5c48793ecf
Modify the block placement limit to allow for the odd random packet or two SpigotMC/Spigot@7768676ae2
This commit is contained in:
Zach Brown 2014-07-24 22:21:57 -05:00
parent a5c9b31256
commit 7dd671146d
3 changed files with 22 additions and 20 deletions

View File

@ -1,33 +1,35 @@
From dbda8287c85efa3395598057b157ff3130dabda9 Mon Sep 17 00:00:00 2001
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 b723b73..9a7b256 100644
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,18 @@ public class PlayerConnection implements PacketPlayInListener {
@@ -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 < 5) {
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
+ throttled = true;
+ } else
+ } 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 +627,14 @@ public class PlayerConnection implements PacketPlayInListener {
@@ -616,10 +629,14 @@ public class PlayerConnection implements PacketPlayInListener {
// CraftBukkit start
int itemstackAmount = itemstack.count;
@ -42,7 +44,7 @@ index b723b73..9a7b256 100644
// 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 +655,7 @@ public class PlayerConnection implements PacketPlayInListener {
@@ -640,7 +657,7 @@ public class PlayerConnection implements PacketPlayInListener {
return;
}

View File

@ -1,11 +1,11 @@
From 35a9d4a5f070fa0cc719d68c9a712819965e712b Mon Sep 17 00:00:00 2001
From 5e48f28aa1c321d023ecdd982eee5e931480c3f5 Mon Sep 17 00:00:00 2001
From: Suddenly <suddenly@suddenly.coffee>
Date: Tue, 8 Jul 2014 09:44:18 +1000
Subject: [PATCH] Safer JSON Loading
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
index 9d1cb33..71ae29e 100644
index 9d1cb33..3ef40f2 100644
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -146,6 +146,17 @@ public class JsonList {
@ -15,10 +15,10 @@ index 9d1cb33..71ae29e 100644
+ // Spigot Start
+ } catch ( java.io.FileNotFoundException ex )
+ {
+ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.INFO, "Unable to find file {0}, creating it.", this.c );
+ a.info( "Unable to find file {0}, creating it.", this.c );
+ } catch ( net.minecraft.util.com.google.gson.JsonSyntaxException ex )
+ {
+ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.WARNING, "Unable to read file {0}, backing it up to {0}.backup and creating new copy.", this.c );
+ a.warn( "Unable to read file {0}, backing it up to {0}.backup and creating new copy.", this.c );
+ File backup = new File( this.c + ".backup" );
+ this.c.renameTo( backup );
+ this.c.delete();
@ -27,7 +27,7 @@ index 9d1cb33..71ae29e 100644
IOUtils.closeQuietly(bufferedreader);
}
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
index 9f7de3f..fe42b9a 100644
index 9f7de3f..1ce89c4 100644
--- a/src/main/java/net/minecraft/server/UserCache.java
+++ b/src/main/java/net/minecraft/server/UserCache.java
@@ -176,6 +176,11 @@ public class UserCache {
@ -36,7 +36,7 @@ index 9f7de3f..fe42b9a 100644
;
+ // Spigot Start
+ } catch (net.minecraft.util.com.google.gson.JsonSyntaxException ex) {
+ org.bukkit.Bukkit.getLogger().warning( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues.");
+ JsonList.a.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." );
+ this.g.delete();
+ // Spigot End
} finally {

View File

@ -1,11 +1,11 @@
From 6e0dd036af4916841749c3a12b968c7b0b56f31b Mon Sep 17 00:00:00 2001
From 141d19426334270c18b49625a291185a7d542b36 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com>
Date: Wed, 16 Jul 2014 14:11:08 -0500
Date: Thu, 24 Jul 2014 22:19:44 -0500
Subject: [PATCH] Toggle for player interact limiter
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index f064f6e..f6a1319 100644
index cd4f0c9..43c2278 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -59,6 +59,8 @@ import org.bukkit.inventory.InventoryView;
@ -17,14 +17,14 @@ index f064f6e..f6a1319 100644
public class PlayerConnection implements PacketPlayInListener {
private static final Logger c = LogManager.getLogger();
@@ -579,7 +581,7 @@ public class PlayerConnection implements PacketPlayInListener {
@@ -580,7 +582,7 @@ public class PlayerConnection implements PacketPlayInListener {
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
boolean throttled = false;
- if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 5) {
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 5 && PaperSpigotConfig.interactLimitEnabled) {
- if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
+ if (PaperSpigotConfig.interactLimitEnabled && lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
throttled = true;
} else
} else if ( packetplayinblockplace.timestamp - lastPlace >= 30 || lastPlace == -1 )
{
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
index f7dc787..ec800c3 100644