Paper/CraftBukkit-Patches/0151-Limit-TNT-Detonations-per-tick.patch
Thinkofdeath 461353e2cb SPIGOT-522: Remove the global api cache option
This was useful when plugins first started upgrading to uuid because each
plugin would implement their own way for grabbing uuid's from mojang. Because
none of them shared the result they would quickly hit the limits on the api
causing the conversion to either fail or pause for long periods of time. The
global api cache was a (very hacky) way to force all plugins to share a cache
but caused a few issues with plugins that expected a full implementation of
the HTTPURLConnection. Due to the fact that most servers/plugins have updated
now it seems to be a good time to remove this as its usefulness mostly has
expired.
2015-02-06 09:03:19 -06:00

56 lines
2.2 KiB
Diff

From 79ab88c862a9310340d15158c5e156c5d0d77d36 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 20 Aug 2014 18:12:32 -0400
Subject: [PATCH] Limit TNT Detonations per tick
This gives a per-world control on how much TNT will be processed per-tick,
preventing a massive TNT detonation from lagging out the server.
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 98c8d26..3621faf 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -41,6 +41,7 @@ public class EntityTNTPrimed extends Entity {
}
public void s_() {
+ if (world.spigotConfig.currentPrimedTnt++ > world.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 439bb00..a61655f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -574,6 +574,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
super.tickEntities();
+ spigotConfig.currentPrimedTnt = 0; // Spigot
}
public void j() {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 0a67739..a88942e 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -338,4 +338,15 @@ public class SpigotWorldConfig
combatExhaustion = (float) getDouble( "hunger.combat-exhaustion", 0.3 );
regenExhaustion = (float) getDouble( "hunger.regen-exhaustion", 3 );
}
+
+ public int currentPrimedTnt = 0;
+ public int maxTntTicksPerTick;
+ private void maxTntPerTick() {
+ if ( SpigotConfig.version < 7 )
+ {
+ set( "max-tnt-per-tick", 100 );
+ }
+ maxTntTicksPerTick = getInt( "max-tnt-per-tick", 100 );
+ log( "Max TNT Explosions: " + maxTntTicksPerTick );
+ }
}
--
2.1.0