diff --git a/WindSpigot-Server/src/main/java/ga/windpvp/windspigot/world/WorldTickManager.java b/WindSpigot-Server/src/main/java/ga/windpvp/windspigot/world/WorldTickManager.java index 7839ccd9..0ee6a8df 100644 --- a/WindSpigot-Server/src/main/java/ga/windpvp/windspigot/world/WorldTickManager.java +++ b/WindSpigot-Server/src/main/java/ga/windpvp/windspigot/world/WorldTickManager.java @@ -2,6 +2,9 @@ import java.util.List; import com.google.common.collect.Lists; + +import co.aikar.timings.SpigotTimings; +import ga.windpvp.windspigot.config.WindSpigotConfig; import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldServer; @@ -40,12 +43,30 @@ public void tick() { } private void tickWorlds() { - // Cache world tick runnables if not cached already - this.cacheWorlds(); - - for (WorldTicker ticker : this.worldTickers) { - ticker.run(); - } + // Cache world tick runnables if not cached already + this.cacheWorlds(); + + // Wait for entity tracking if async entity tracking takes this long + if (!WindSpigotConfig.disableTracking) { + for (WorldTicker ticker : this.worldTickers) { + try { + ticker.getLatch().waitTillZero(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + ticker.getLatch().reset(); + } + } + + // Move BukkitScheduler stuff here so async entity tracking does not interfere + SpigotTimings.bukkitSchedulerTimer.startTiming(); // Spigot + // CraftBukkit start + MinecraftServer.getServer().server.getScheduler().mainThreadHeartbeat(MinecraftServer.getServer().at()); + SpigotTimings.bukkitSchedulerTimer.stopTiming(); // Spigot + + for (WorldTicker ticker : this.worldTickers) { + ticker.run(); + } } /* diff --git a/WindSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java b/WindSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java index 0d2fd9ea..465521e2 100644 --- a/WindSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/WindSpigot-Server/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1035,10 +1035,11 @@ public void B() { this.methodProfiler.c("levels"); - SpigotTimings.bukkitSchedulerTimer.startTiming(); // Spigot - // CraftBukkit start - this.server.getScheduler().mainThreadHeartbeat(this.ticks); - SpigotTimings.bukkitSchedulerTimer.stopTiming(); // Spigot + // WindSpigot - move to WorldTickManager +// SpigotTimings.bukkitSchedulerTimer.startTiming(); // Spigot +// // CraftBukkit start +// this.server.getScheduler().mainThreadHeartbeat(this.ticks); +// SpigotTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Run tasks that are waiting on processing SpigotTimings.processQueueTimer.startTiming(); // Spigot