PaperSpigot-Parent/CraftBukkit-Patches/0175-Limit-TNT-Detonations-per-tick.patch
Zach Brown cab333b217 Rebase (Update) from upstream SpigotMC
Don't send requests of every player was found in the global api cache SpigotMC/Spigot@841270ff1e
Correctly set the response code for the cached lookups and return the ... SpigotMC/Spigot@f170b7899c
Don't try and re-set the global api cache on reload SpigotMC/Spigot@b410a00a66
Use a compile time sneaky throw hack. SpigotMC/Spigot@508462b96b
Fix a missed rename in WorldGenGroundBush SpigotMC/Spigot@0614d8fae9
2014-11-28 14:19:07 -06:00

56 lines
2.2 KiB
Diff

From 373358b33f3e334518b1863d6ec2d40af3c6ebf5 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 13cbc79..2214660 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -42,6 +42,7 @@ public class EntityTNTPrimed extends Entity {
}
public void h() {
+ 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 f9dc0fc..91f036b 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -514,6 +514,7 @@ public class WorldServer extends World {
}
super.tickEntities();
+ spigotConfig.currentPrimedTnt = 0; // Spigot
}
public void i() {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 3500931..5e3dbf9 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 );
+ }
}
--
1.9.1