diff --git a/build.gradle b/build.gradle index afb3e65..345a003 100644 --- a/build.gradle +++ b/build.gradle @@ -45,9 +45,9 @@ group = 'pw.prok.kcauldron' archivesBaseName = 'kcauldron' ext.mcVersion = "1.7.10" -ext.cauldronVersion = "3" +ext.cauldronVersion = "4" ext.forgeVersion = "1403" -ext.revision = "62" +ext.revision = "63" version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}" launch4j { diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index e8e027d..108866d 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -1,6 +1,22 @@ --- ../src-base/minecraft/net/minecraft/world/World.java +++ ../src-work/minecraft/net/minecraft/world/World.java -@@ -23,9 +23,11 @@ +@@ -2,6 +2,7 @@ + + import cpw.mods.fml.relauncher.Side; + import cpw.mods.fml.relauncher.SideOnly; ++ + import java.util.ArrayList; + import java.util.Calendar; + import java.util.Collection; +@@ -12,6 +13,7 @@ + import java.util.Set; + import java.util.UUID; + import java.util.concurrent.Callable; ++ + import net.minecraft.block.Block; + import net.minecraft.block.BlockHopper; + import net.minecraft.block.BlockLiquid; +@@ -23,9 +25,11 @@ import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; @@ -12,7 +28,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; -@@ -70,6 +72,49 @@ +@@ -51,7 +55,6 @@ + import net.minecraft.world.storage.ISaveHandler; + import net.minecraft.world.storage.MapStorage; + import net.minecraft.world.storage.WorldInfo; +- + import cpw.mods.fml.common.FMLLog; + + import com.google.common.collect.ImmutableSetMultimap; +@@ -70,6 +73,55 @@ import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraft.entity.EnumCreatureType; @@ -27,6 +51,7 @@ +import net.minecraft.entity.passive.EntityWaterMob; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.gen.ChunkProviderServer; ++ +import org.bukkit.Bukkit; +import org.bukkit.World.Environment; +import org.bukkit.block.BlockState; @@ -43,10 +68,13 @@ +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.weather.WeatherChangeEvent; +import org.bukkit.event.weather.ThunderChangeEvent; ++ +// CraftBukkit end +// Spigot Start +import net.minecraft.entity.item.EntityXPOrb; ++ +import org.bukkit.craftbukkit.SpigotTimings; ++ +// Spigot end +// Cauldron start +import net.minecraft.nbt.NBTTagCompound; @@ -56,13 +84,15 @@ +import net.minecraftforge.cauldron.configuration.TileEntityConfig; +import net.minecraftforge.cauldron.configuration.TileEntityWorldConfig; +import net.minecraftforge.common.DimensionManager; ++ +import org.bukkit.block.BlockState; +// Cauldron end ++import org.spigotmc.TickLimiter; + public abstract class World implements IBlockAccess { /** -@@ -83,15 +128,14 @@ +@@ -83,15 +135,14 @@ public boolean scheduledUpdatesAreImmediate; public List loadedEntityList = new ArrayList(); @@ -80,7 +110,7 @@ protected final int DIST_HASH_MAGIC = 1013904223; public float prevRainingStrength; public float rainingStrength; -@@ -100,26 +144,88 @@ +@@ -100,26 +151,88 @@ public int lastLightningBolt; public EnumDifficulty difficultySetting; public Random rand = new Random(); @@ -176,7 +206,7 @@ private static final String __OBFID = "CL_00000140"; public boolean restoringBlockSnapshots = false; public boolean captureBlockSnapshots = false; -@@ -166,6 +272,24 @@ +@@ -166,6 +279,27 @@ return this.provider.worldChunkMgr; } @@ -187,6 +217,9 @@ + public ChunkGenerator generator; + public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot + public final SpigotTimings.WorldTimingsHandler timings; // Spigot ++ private org.spigotmc.TickLimiter entityLimiter; // Spigot ++ private org.spigotmc.TickLimiter tileLimiter; // Spigot ++ private int tileTickPosition; // Spigot + + public CraftWorld getWorld() + { @@ -201,7 +234,7 @@ @SideOnly(Side.CLIENT) public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_) { -@@ -179,6 +303,12 @@ +@@ -179,6 +313,12 @@ this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_); this.provider = p_i45368_3_; perWorldStorage = new MapStorage((ISaveHandler)null); @@ -214,7 +247,7 @@ } // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes -@@ -207,8 +337,173 @@ +@@ -207,8 +347,175 @@ this.calculateInitialWeather(); } @@ -223,6 +256,7 @@ + org.bukkit.World.Environment env) + { + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(p_i45369_2_); // Spigot ++ initLimiter(); // Spigot + // Cauldron start + this.cauldronConfig = new CauldronWorldConfig(p_i45369_2_, MinecraftServer.getServer().cauldronConfig); + this.tileentityConfig = new TileEntityWorldConfig(p_i45369_2_, MinecraftServer.getServer().tileEntityConfig); @@ -367,6 +401,7 @@ + if (DimensionManager.getWorld(0) != null) + { + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(p_i45369_2_); // Spigot ++ initLimiter(); // Spigot + this.cauldronConfig = new CauldronWorldConfig(p_i45369_2_, MinecraftServer.getServer().cauldronConfig); + this.tileentityConfig = new TileEntityWorldConfig(p_i45369_2_, MinecraftServer.getServer().tileEntityConfig); + this.world = DimensionManager.getWorld(0).getWorld(); @@ -388,7 +423,7 @@ this.ambientTickCountdown = this.rand.nextInt(12000); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; -@@ -216,7 +511,6 @@ +@@ -216,7 +523,6 @@ this.lightUpdateBlockList = new int[32768]; this.saveHandler = p_i45369_1_; this.theProfiler = p_i45369_5_; @@ -396,7 +431,7 @@ this.worldInfo = p_i45369_1_.loadWorldInfo(); if (p_i45369_4_ != null) -@@ -235,13 +529,26 @@ +@@ -235,13 +541,26 @@ if (this.worldInfo == null) { this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_); @@ -423,15 +458,15 @@ this.chunkProvider = this.createChunkProvider(); if (this instanceof WorldServer) -@@ -294,6 +601,7 @@ +@@ -294,6 +613,7 @@ this.calculateInitialSkylight(); this.calculateInitialWeather(); } -+ // Cauldron end ++ // Cauldron end private static MapStorage s_mapStorage; private static ISaveHandler s_savehandler; -@@ -336,6 +644,18 @@ +@@ -336,6 +656,18 @@ public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { @@ -450,7 +485,7 @@ if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256) { Chunk chunk = null; -@@ -404,7 +724,7 @@ +@@ -404,7 +736,7 @@ } } @@ -459,7 +494,7 @@ { return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_); } -@@ -421,6 +741,27 @@ +@@ -421,6 +753,27 @@ public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_) { @@ -487,7 +522,7 @@ if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000) { if (p_147465_2_ < 0) -@@ -448,8 +789,22 @@ +@@ -448,8 +801,22 @@ this.capturedBlockSnapshots.add(blockSnapshot); } @@ -510,7 +545,7 @@ if (!flag && blockSnapshot != null) { this.capturedBlockSnapshots.remove(blockSnapshot); -@@ -460,6 +815,7 @@ +@@ -460,6 +827,7 @@ this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_); this.theProfiler.endSection(); @@ -518,7 +553,7 @@ if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates { // Modularize client and physic updates -@@ -496,6 +852,19 @@ +@@ -496,6 +864,19 @@ public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { @@ -538,7 +573,7 @@ if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000) { if (p_72805_2_ < 0) -@@ -610,6 +979,12 @@ +@@ -610,6 +991,12 @@ public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_) { @@ -551,7 +586,7 @@ this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_); } -@@ -694,6 +1069,21 @@ +@@ -694,6 +1081,21 @@ try { @@ -573,7 +608,7 @@ block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); } catch (Throwable throwable1) -@@ -1307,6 +1697,12 @@ +@@ -1307,6 +1709,12 @@ public boolean spawnEntityInWorld(Entity p_72838_1_) { @@ -586,7 +621,7 @@ // do not drop any items while restoring blocksnapshots. Prevents dupes if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false; -@@ -1319,8 +1715,84 @@ +@@ -1319,8 +1727,84 @@ flag = true; } @@ -671,7 +706,7 @@ return false; } else -@@ -1332,10 +1804,10 @@ +@@ -1332,10 +1816,10 @@ this.updateAllPlayersSleepingFlag(); } if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false; @@ -683,7 +718,7 @@ return true; } } -@@ -1346,6 +1818,8 @@ +@@ -1346,6 +1830,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); } @@ -692,7 +727,7 @@ } public void onEntityRemoved(Entity p_72847_1_) -@@ -1354,6 +1828,8 @@ +@@ -1354,6 +1840,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); } @@ -701,7 +736,7 @@ } public void removeEntity(Entity p_72900_1_) -@@ -1397,6 +1873,19 @@ +@@ -1397,6 +1885,19 @@ } this.loadedEntityList.remove(p_72973_1_); @@ -721,7 +756,7 @@ this.onEntityRemoved(p_72973_1_); } -@@ -1408,40 +1897,58 @@ +@@ -1408,40 +1909,58 @@ public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_) { this.collidingBoundingBoxes.clear(); @@ -794,7 +829,7 @@ for (int j2 = 0; j2 < list.size(); ++j2) { -@@ -1797,11 +2304,22 @@ +@@ -1797,11 +2316,22 @@ Entity entity; CrashReport crashreport; CrashReportCategory crashreportcategory; @@ -817,7 +852,7 @@ try { ++entity.ticksExisted; -@@ -1862,10 +2380,13 @@ +@@ -1862,10 +2392,14 @@ this.unloadedEntityList.clear(); this.theProfiler.endStartSection("regular"); @@ -825,15 +860,17 @@ + timings.entityTick.startTiming(); // Spigot - for (i = 0; i < this.loadedEntityList.size(); ++i) -+ // CraftBukkit start - Use field for loop variable -+ for (this.tickPosition = 0; this.tickPosition < this.loadedEntityList.size(); ++this.tickPosition) - { +- { - entity = (Entity)this.loadedEntityList.get(i); ++ int entitiesThisCycle = 0; ++ if (tickPosition < 0) tickPosition = 0; ++ for (entityLimiter.initTick(); entitiesThisCycle < loadedEntityList.size() && (entitiesThisCycle % 10 == 0 || entityLimiter.shouldContinue()); tickPosition++, entitiesThisCycle++) { ++ tickPosition = (tickPosition < loadedEntityList.size()) ? tickPosition : 0; + entity = (Entity)this.loadedEntityList.get(this.tickPosition); if (entity.ridingEntity != null) { -@@ -1884,7 +2405,9 @@ +@@ -1884,7 +2418,9 @@ { try { @@ -843,7 +880,7 @@ } catch (Throwable throwable1) { -@@ -1917,29 +2440,56 @@ +@@ -1917,29 +2453,67 @@ this.getChunkFromChunkCoords(j, l).removeEntity(entity); } @@ -859,9 +896,13 @@ this.theProfiler.endStartSection("blockEntities"); + timings.tileEntityTick.startTiming(); // Spigot this.field_147481_N = true; +- Iterator iterator = this.loadedTileEntityList.iterator(); +- +- while (iterator.hasNext()) + // CraftBukkit start - From below, clean up tile entities before ticking them + if (!this.field_147483_b.isEmpty()) -+ { + { +- TileEntity tileentity = (TileEntity)iterator.next(); + for (Object tile : field_147483_b) + { + ((TileEntity) tile).onChunkUnload(); @@ -870,23 +911,34 @@ + this.field_147483_b.clear(); + } + // CraftBukkit end - Iterator iterator = this.loadedTileEntityList.iterator(); - - while (iterator.hasNext()) - { - TileEntity tileentity = (TileEntity)iterator.next(); - if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)) ++ int tilesThisCycle = 0; ++ for (tileLimiter.initTick(); tilesThisCycle < loadedTileEntityList.size() && (tilesThisCycle % 10 == 0 || tileLimiter.shouldContinue()); tileTickPosition++, tilesThisCycle++) { ++ tileTickPosition = (tileTickPosition < loadedTileEntityList.size()) ? tileTickPosition : 0; ++ TileEntity tileentity = (TileEntity) this.loadedTileEntityList.get(tileTickPosition); ++ + // Spigot start + if (tileentity == null) { + getServer().getLogger().severe("Cauldron has detected a null entity and has removed it, preventing a crash"); -+ iterator.remove(); ++ tilesThisCycle--; ++ this.loadedTileEntityList.remove(tileTickPosition--); + continue; + } + // Spigot end ++ ++ if (tileentity.isInvalid()) { ++ tilesThisCycle--; ++ this.loadedTileEntityList.remove(tileTickPosition--); ++ if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) { ++ Chunk chunk = this.getChunkFromChunkCoords(tileentity.xCoord >> 4, tileentity.zCoord >> 4); ++ if (chunk != null) chunk.removeInvalidTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15); ++ } ++ continue; ++ } + -+ if (!tileentity.isInvalid() && tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this) ++ if (tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this) + && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)) + { try @@ -902,8 +954,25 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1972,6 +2522,11 @@ +@@ -1955,23 +2529,13 @@ + } + } } +- +- if (tileentity.isInvalid()) +- { +- iterator.remove(); +- +- if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) +- { +- Chunk chunk = this.getChunkFromChunkCoords(tileentity.xCoord >> 4, tileentity.zCoord >> 4); +- +- if (chunk != null) +- { +- chunk.removeInvalidTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15); +- } +- } +- } } + timings.tileEntityTick.stopTiming(); // Spigot @@ -914,7 +983,7 @@ if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2536,7 @@ +@@ -1981,6 +2545,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -922,7 +991,7 @@ this.field_147481_N = false; -@@ -2016,17 +2572,23 @@ +@@ -2016,17 +2581,23 @@ this.addedTileEntityList.clear(); } @@ -949,7 +1018,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2041,16 +2603,27 @@ +@@ -2041,16 +2612,27 @@ boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4)); byte b0 = isForced ? (byte)0 : 32; boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0); @@ -978,7 +1047,7 @@ p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosZ = p_72866_1_.posZ; -@@ -2134,6 +2707,7 @@ +@@ -2134,6 +2716,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -986,7 +1055,7 @@ } } -@@ -2570,7 +3144,7 @@ +@@ -2570,7 +3153,7 @@ return; } @@ -995,7 +1064,7 @@ { if (this.field_147481_N) { -@@ -2718,7 +3292,15 @@ +@@ -2718,7 +3301,15 @@ if (i <= 0) { @@ -1012,7 +1081,7 @@ } } -@@ -2754,7 +3336,15 @@ +@@ -2754,7 +3345,15 @@ if (j <= 0) { @@ -1029,7 +1098,7 @@ } } -@@ -2777,8 +3367,41 @@ +@@ -2777,8 +3376,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1072,7 +1141,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3411,28 @@ +@@ -2788,17 +3420,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1107,7 +1176,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3444,7 @@ +@@ -2810,7 +3453,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1116,7 +1185,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3284,8 +3918,21 @@ +@@ -3284,8 +3927,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); @@ -1139,7 +1208,7 @@ ++i; } } -@@ -3314,8 +3961,17 @@ +@@ -3314,8 +3970,17 @@ public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) { Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); @@ -1158,7 +1227,7 @@ } public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) -@@ -3464,6 +4120,12 @@ +@@ -3464,6 +4129,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1171,7 +1240,7 @@ double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_); if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4)) -@@ -3489,7 +4151,12 @@ +@@ -3489,7 +4160,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1185,7 +1254,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4327,18 @@ +@@ -3660,6 +4336,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1204,7 +1273,7 @@ public float getWeightedThunderStrength(float p_72819_1_) { return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); -@@ -3932,8 +4611,8 @@ +@@ -3932,8 +4620,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1215,7 +1284,7 @@ { dest.add(entity); } -@@ -4029,4 +4708,60 @@ +@@ -4029,4 +4717,67 @@ } return count; } @@ -1275,4 +1344,11 @@ + return this.spigotConfig; + } + // Cauldron end ++ ++ // Spigot start ++ private void initLimiter() { ++ entityLimiter = new TickLimiter(spigotConfig.entityMaxTickTime); ++ tileLimiter = new TickLimiter(spigotConfig.tileMaxTickTime); ++ } ++ // Spigot end } diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java index b51971d..a9ab410 100644 --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -278,4 +278,13 @@ public class SpigotWorldConfig maxCollisionsPerEntity = getInt( "max-entity-collisions", 8 ); log( "Max Entity Collisions: " + maxCollisionsPerEntity ); } + + public int tileMaxTickTime; + public int entityMaxTickTime; + private void maxTickTimes() + { + tileMaxTickTime = getInt("max-tick-time.tile", 50); + entityMaxTickTime = getInt("max-tick-time.entity", 50); + log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms"); + } } diff --git a/src/main/java/org/spigotmc/TickLimiter.java b/src/main/java/org/spigotmc/TickLimiter.java new file mode 100644 index 0000000..74ac1fb --- /dev/null +++ b/src/main/java/org/spigotmc/TickLimiter.java @@ -0,0 +1,18 @@ +package org.spigotmc; + +public class TickLimiter { + private final int maxTime; + private long startTime; + + public TickLimiter(int maxTime) { + this.maxTime = maxTime; + } + + public void initTick() { + startTime = System.currentTimeMillis(); + } + + public boolean shouldContinue() { + return System.currentTimeMillis() - startTime < maxTime; + } +}