3
0

Limit TNT detonations per world per tick

This commit is contained in:
Sergey Shatunov 2016-01-05 14:20:01 +07:00
parent 0aad7977fc
commit 0011dd0d9a
4 changed files with 47 additions and 17 deletions

View File

@ -16,7 +16,15 @@
public EntityTNTPrimed(World p_i1729_1_) public EntityTNTPrimed(World p_i1729_1_)
{ {
@@ -68,12 +72,14 @@ @@ -50,6 +54,7 @@
public void onUpdate()
{
+ if (worldObj.spigotConfig.currentPrimedTnt++ > worldObj.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
@@ -68,12 +73,14 @@
if (this.fuse-- <= 0) if (this.fuse-- <= 0)
{ {
@ -33,7 +41,7 @@
} }
else else
{ {
@@ -83,8 +89,19 @@ @@ -83,8 +90,19 @@
private void explode() private void explode()
{ {
@ -55,7 +63,7 @@
} }
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) protected void writeEntityToNBT(NBTTagCompound p_70014_1_)
@@ -107,4 +124,11 @@ @@ -107,4 +125,11 @@
{ {
return this.tntPlacedBy; return this.tntPlacedBy;
} }

View File

@ -389,7 +389,15 @@
{ {
if (this.updateEntityTick++ >= 1200) if (this.updateEntityTick++ >= 1200)
{ {
@@ -506,7 +686,16 @@ @@ -487,6 +667,7 @@
}
super.updateEntities();
+ spigotConfig.currentPrimedTnt = 0; // Spigot
}
public void resetUpdateEntityTick()
@@ -506,7 +687,16 @@
{ {
if (i > 1000) if (i > 1000)
{ {
@ -407,7 +415,7 @@
} }
this.theProfiler.startSection("cleaning"); this.theProfiler.startSection("cleaning");
@@ -651,7 +840,37 @@ @@ -651,7 +841,37 @@
protected IChunkProvider createChunkProvider() protected IChunkProvider createChunkProvider()
{ {
IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider);
@ -446,7 +454,7 @@
return this.theChunkProviderServer; return this.theChunkProviderServer;
} }
@@ -659,29 +878,31 @@ @@ -659,29 +879,31 @@
{ {
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
@ -493,7 +501,7 @@
return arraylist; return arraylist;
} }
@@ -733,7 +954,28 @@ @@ -733,7 +955,28 @@
int i = 0; int i = 0;
int j = this.provider.getAverageGroundLevel(); int j = this.provider.getAverageGroundLevel();
int k = 0; int k = 0;
@ -522,7 +530,7 @@
if (chunkposition != null) if (chunkposition != null)
{ {
i = chunkposition.chunkPosX; i = chunkposition.chunkPosX;
@@ -876,6 +1118,20 @@ @@ -876,6 +1119,20 @@
public boolean addWeatherEffect(Entity p_72942_1_) public boolean addWeatherEffect(Entity p_72942_1_)
{ {
@ -543,7 +551,7 @@
if (super.addWeatherEffect(p_72942_1_)) if (super.addWeatherEffect(p_72942_1_))
{ {
this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_)); this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_));
@@ -894,13 +1150,23 @@ @@ -894,13 +1151,23 @@
public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_) public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{ {
@ -568,7 +576,7 @@
if (!p_72885_10_) if (!p_72885_10_)
{ {
explosion.affectedBlockPositions.clear(); explosion.affectedBlockPositions.clear();
@@ -977,7 +1243,7 @@ @@ -977,7 +1244,7 @@
{ {
boolean flag = this.isRaining(); boolean flag = this.isRaining();
super.updateWeather(); super.updateWeather();
@ -577,7 +585,7 @@
if (this.prevRainingStrength != this.rainingStrength) if (this.prevRainingStrength != this.rainingStrength)
{ {
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
@@ -988,10 +1254,6 @@ @@ -988,10 +1255,6 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
} }
@ -588,7 +596,7 @@
if (flag != this.isRaining()) if (flag != this.isRaining())
{ {
if (flag) if (flag)
@@ -1006,6 +1268,33 @@ @@ -1006,6 +1269,33 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
} }
@ -622,7 +630,7 @@
} }
protected int func_152379_p() protected int func_152379_p()
@@ -1069,4 +1358,51 @@ @@ -1069,4 +1359,51 @@
this(); this();
} }
} }

View File

@ -50,8 +50,8 @@ public class SpigotConfig
commands = new HashMap<String, Command>(); commands = new HashMap<String, Command>();
version = getInt( "config-version", 5 ); version = getInt( "config-version", 7 );
set( "config-version", 5 ); set( "config-version", 7 );
readConfig( SpigotConfig.class, null ); readConfig( SpigotConfig.class, null );
} }
@ -152,7 +152,7 @@ public class SpigotConfig
public static String unknownCommandMessage; public static String unknownCommandMessage;
public static String serverFullMessage; public static String serverFullMessage;
public static String outdatedClientMessage = "Outdated client! Please use {}"; public static String outdatedClientMessage = "Outdated client! Please use {}";
public static String outdatedServerMessage = "Outdated server! I\'m still on {0}"; public static String outdatedServerMessage = "Outdated server! I\'m still on {}";
private static String transform(String s) private static String transform(String s)
{ {
return ChatColor.translateAlternateColorCodes( '&', s ).replaceAll( "\\n", "\n" ); return ChatColor.translateAlternateColorCodes( '&', s ).replaceAll( "\\n", "\n" );
@ -199,7 +199,10 @@ public class SpigotConfig
private static void nettyThreads() private static void nettyThreads()
{ {
int count = getInt( "settings.netty-threads", 4 ); if (version < 7)
set("settings.netty-threads", -1);
int count = getInt( "settings.netty-threads", -1 );
count = count == -1 ? Runtime.getRuntime().availableProcessors() : count;
System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) ); System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count ); Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
} }

View File

@ -287,4 +287,15 @@ public class SpigotWorldConfig
entityMaxTickTime = getInt("max-tick-time.entity", 50); entityMaxTickTime = getInt("max-tick-time.entity", 50);
log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms"); log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms");
} }
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 );
}
} }