Improve mid tick chunk loading, Fix Oversleep, other improvements

Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.

Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.

This guarantees that your chunk will load with at most around 1ms delay.

Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...

Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.

Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.

This is now fixed.

Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.

Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".

This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.

It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.

We solve this by ensuring new additions do not enter the currently iterated queue.

Each depth level will have its own queue.

Fixes #3220
This commit is contained in:
Aikar 2020-04-25 23:47:29 -04:00
parent ab36835ca0
commit fcf89e852e
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
25 changed files with 329 additions and 280 deletions

View file

@ -1,4 +1,4 @@
From b633da3b27d8d9d4be6dad68c36f7c9cfed403cb Mon Sep 17 00:00:00 2001
From 983b67ed126cac183574f9d8832b247327386df4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2
@ -6,7 +6,7 @@ Subject: [PATCH] Timings v2
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
new file mode 100644
index 0000000000..69e26a8267
index 0000000000..223d3b1125
--- /dev/null
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -0,0 +1,141 @@
@ -144,7 +144,7 @@ index 0000000000..69e26a8267
+ }*/
+
+ public static Timing getPacketTiming(Packet packet) {
+ return Timings.ofSafe("## Packet - " + packet.getClass().getSimpleName(), packetProcessTimer);
+ return Timings.ofSafe("## Packet - " + packet.getClass().getName(), packetProcessTimer);
+ }
+
+ public static Timing getCommandFunctionTiming(CustomFunction function) {
@ -749,7 +749,7 @@ index 1f350e3352..35e3f1c78d 100644
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index b4a0bd7951..456d03be22 100644
index b4a0bd7951..67bdd57747 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -63,7 +63,7 @@ import org.bukkit.craftbukkit.CraftServer;
@ -780,11 +780,16 @@ index b4a0bd7951..456d03be22 100644
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
@@ -884,6 +885,16 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -881,9 +882,21 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private boolean canSleepForTick() {
// CraftBukkit start
+ if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick);
}
+ // Paper start
+ boolean isOversleep = false;
+ private boolean canOversleep() {
+ return this.hasExecutedTask() && SystemUtils.getMonotonicMillis() < this.getTickOversleepMaxTime();
+ }
@ -797,7 +802,7 @@ index b4a0bd7951..456d03be22 100644
private void executeModerately() {
this.executeAll();
java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
@@ -891,9 +902,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -891,9 +904,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit end
protected void sleepForTick() {
@ -809,7 +814,7 @@ index b4a0bd7951..456d03be22 100644
});
}
@@ -976,10 +987,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -976,10 +989,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
protected void exit() {}
protected void a(BooleanSupplier booleansupplier) {
@ -819,17 +824,17 @@ index b4a0bd7951..456d03be22 100644
long i = SystemUtils.getMonotonicNanos();
+ // Paper start - move oversleep into full server tick
+ MinecraftTimings.serverOversleep.startTiming();
+ isOversleep = true;MinecraftTimings.serverOversleep.startTiming();
+ this.awaitTasks(() -> {
+ return !this.canOversleep();
+ });
+ MinecraftTimings.serverOversleep.stopTiming();
+ isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
+ // Paper end
+
++this.ticks;
this.b(booleansupplier);
if (i - this.Z >= 5000000000L) {
@@ -997,14 +1016,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -997,14 +1018,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
@ -844,7 +849,7 @@ index b4a0bd7951..456d03be22 100644
}
this.methodProfiler.enter("snooper");
@@ -1017,6 +1034,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1017,6 +1036,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
this.methodProfiler.exit();
@ -858,7 +863,7 @@ index b4a0bd7951..456d03be22 100644
this.methodProfiler.enter("tallying");
long l = this.f[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
@@ -1027,30 +1051,29 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1027,30 +1053,29 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
this.slackActivityAccountant.tickEnded(l); // Spigot
@ -897,7 +902,7 @@ index b4a0bd7951..456d03be22 100644
// Send time updates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
@@ -1058,7 +1081,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1058,7 +1083,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time
}
}
@ -906,7 +911,7 @@ index b4a0bd7951..456d03be22 100644
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
@@ -1101,24 +1124,24 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1101,24 +1126,24 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
this.methodProfiler.exitEnter("connection");
@ -1862,5 +1867,5 @@ index ca7789b5e0..4423839697 100644
}
}
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 4d48a37c0c99a45cff782138493194d06df4dc42 Mon Sep 17 00:00:00 2001
From ed104341e483f582e18953637c84f2c805fc5b3a Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 1 Mar 2016 14:32:43 -0600
Subject: [PATCH] Show 'Paper' in client crashes, server lists, and Mojang
@ -6,7 +6,7 @@ Subject: [PATCH] Show 'Paper' in client crashes, server lists, and Mojang
diff --git a/src/main/java/net/minecraft/server/EULA.java b/src/main/java/net/minecraft/server/EULA.java
index 3f35a28ba..cf00f35a5 100644
index 3f35a28ba1..cf00f35a5b 100644
--- a/src/main/java/net/minecraft/server/EULA.java
+++ b/src/main/java/net/minecraft/server/EULA.java
@@ -70,7 +70,7 @@ public class EULA {
@ -19,10 +19,10 @@ index 3f35a28ba..cf00f35a5 100644
throwable = throwable1;
throw throwable1;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 456d03be2..35b226cd5 100644
index 67bdd57747..e71ee0fb33 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1343,7 +1343,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1345,7 +1345,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
public String getServerModName() {
@ -32,7 +32,7 @@ index 456d03be2..35b226cd5 100644
public CrashReport b(CrashReport crashreport) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f3eacb181..99a6b3d44 100644
index f3eacb1819..99a6b3d443 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -199,7 +199,7 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
@ -45,7 +45,7 @@ index f3eacb181..99a6b3d44 100644
private final String bukkitVersion = Versioning.getBukkitVersion();
private final Logger logger = Logger.getLogger("Minecraft");
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 0d8668d34..ba0fe4ae2 100644
index 0d8668d34d..ba0fe4ae2c 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -201,12 +201,25 @@ public class Main {
@ -76,7 +76,7 @@ index 0d8668d34..ba0fe4ae2 100644
MinecraftServer.main(options);
} catch (Throwable t) {
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 54fa83c12..73fa74e3c 100644
index 54fa83c127..73fa74e3cc 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -19,7 +19,7 @@ public class WatchdogThread extends Thread
@ -116,5 +116,5 @@ index 54fa83c12..73fa74e3c 100644
log.log( Level.SEVERE, "------------------------------" );
//
--
2.26.0
2.26.2

View file

@ -1,4 +1,4 @@
From 66cb7186fb398829970cb0df184ef6a1050c969c Mon Sep 17 00:00:00 2001
From f8b2b0e30d6bfb90e265a6d91ee8b96729761fda Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 1 Mar 2016 23:09:29 -0600
Subject: [PATCH] Further improve server tick loop
@ -12,7 +12,7 @@ Previous implementation did not calculate TPS correctly.
Switch to a realistic rolling average and factor in std deviation as an extra reporting variable
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2b3844ae5a..7b8c523e6d 100644
index e71ee0fb33..53d0a98d00 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -160,7 +160,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -162,7 +162,7 @@ index 99a6b3d443..e3939387e7 100644
{
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
index be2e31deae..6d21c32692 100644
index be2e31deae..387af9d5c0 100644
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
@@ -1,8 +1,5 @@
@ -174,7 +174,7 @@ index be2e31deae..6d21c32692 100644
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -26,18 +23,20 @@ public class TicksPerSecondCommand extends Command
@@ -26,20 +23,22 @@ public class TicksPerSecondCommand extends Command
return true;
}
@ -201,7 +201,10 @@ index be2e31deae..6d21c32692 100644
+ private static String format(double tps) // Paper - Made static
{
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
+ ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
- + ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
+ + ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
}
}
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 7c796e60234f3887773d5a6d827c214b1303fdf6 Mon Sep 17 00:00:00 2001
From 6b503392be4decc2138d29182e99bdd03145f7e3 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 11:59:48 -0600
Subject: [PATCH] Optimize explosions
@ -10,7 +10,7 @@ This patch adds a per-tick cache that is used for storing and retrieving
an entity's exposure during an explosion.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 50dec5cb5..f038d3f7d 100644
index 50dec5cb5e..f038d3f7dc 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -150,4 +150,10 @@ public class PaperWorldConfig {
@ -25,7 +25,7 @@ index 50dec5cb5..f038d3f7d 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index a063d1bfa..5583860f1 100644
index a063d1bfaa..5583860f15 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -177,7 +177,7 @@ public class Explosion {
@ -123,10 +123,10 @@ index a063d1bfa..5583860f1 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 91ea693bc..c9eb13119 100644
index 53d0a98d00..11f81ab364 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1179,6 +1179,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1181,6 +1181,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.exit();
this.methodProfiler.exit();
@ -135,7 +135,7 @@ index 91ea693bc..c9eb13119 100644
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1bb362015..460463457 100644
index 1bb3620154..4604634577 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -80,6 +80,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@ -147,5 +147,5 @@ index 1bb362015..460463457 100644
public CraftWorld getWorld() {
return this.world;
--
2.26.0
2.26.2

View file

@ -1,4 +1,4 @@
From ca8bdf972dc165aa852e053bb5912feceead2fad Mon Sep 17 00:00:00 2001
From 3847e222ad04802370aa46da6a280fdfa8a55500 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 19:55:45 -0400
Subject: [PATCH] Only process BlockPhysicsEvent if a plugin has a listener
@ -6,7 +6,7 @@ Subject: [PATCH] Only process BlockPhysicsEvent if a plugin has a listener
Saves on some object allocation and processing when no plugin listens to this
diff --git a/src/main/java/net/minecraft/server/BlockPlant.java b/src/main/java/net/minecraft/server/BlockPlant.java
index ed1da4f4b..a6891b9fa 100644
index ed1da4f4ba..a6891b9fa7 100644
--- a/src/main/java/net/minecraft/server/BlockPlant.java
+++ b/src/main/java/net/minecraft/server/BlockPlant.java
@@ -16,7 +16,7 @@ public class BlockPlant extends Block {
@ -19,7 +19,7 @@ index ed1da4f4b..a6891b9fa 100644
}
}
diff --git a/src/main/java/net/minecraft/server/BlockTallPlant.java b/src/main/java/net/minecraft/server/BlockTallPlant.java
index 42e86881b..6cdce1158 100644
index 42e86881bd..6cdce11581 100644
--- a/src/main/java/net/minecraft/server/BlockTallPlant.java
+++ b/src/main/java/net/minecraft/server/BlockTallPlant.java
@@ -55,7 +55,7 @@ public class BlockTallPlant extends BlockPlant {
@ -32,10 +32,10 @@ index 42e86881b..6cdce1158 100644
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c9eb13119..1d3f1be24 100644
index 11f81ab364..773f93edb7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1145,6 +1145,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1147,6 +1147,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
@ -44,7 +44,7 @@ index c9eb13119..1d3f1be24 100644
this.methodProfiler.a(() -> {
return worldserver.getWorldData().getName() + " " + IRegistry.DIMENSION_TYPE.getKey(worldserver.worldProvider.getDimensionManager());
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 6b1ff8f64..1edd03086 100644
index 6b1ff8f64f..1edd030865 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -369,7 +369,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@ -66,7 +66,7 @@ index 6b1ff8f64..1edd03086 100644
this.getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 96ed2da1f..9d0edf538 100644
index 96ed2da1f8..9d0edf5382 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -75,6 +75,7 @@ public class WorldServer extends World {
@ -78,5 +78,5 @@ index 96ed2da1f..9d0edf538 100644
// Add env and gen to constructor
public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
--
2.26.0
2.26.2

View file

@ -1,4 +1,4 @@
From 9feee69060416cf7b59158ec4323bc80e2b2f4eb Mon Sep 17 00:00:00 2001
From 8d22e60952c1d60ef7d029996897a2134b2a5753 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 28 Apr 2016 00:57:27 -0400
Subject: [PATCH] remove null possibility for getServer singleton
@ -6,7 +6,7 @@ Subject: [PATCH] remove null possibility for getServer singleton
to stop IDE complaining about potential NPE
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f82be54cc..54b4172e6 100644
index 36d20d5e3a..a5aa6553cc 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -68,6 +68,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
@ -25,7 +25,7 @@ index f82be54cc..54b4172e6 100644
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
this.craftingManager = new CraftingManager();
this.tagRegistry = new TagRegistry();
@@ -2184,7 +2186,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -2186,7 +2188,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Deprecated
public static MinecraftServer getServer() {
@ -35,5 +35,5 @@ index f82be54cc..54b4172e6 100644
// CraftBukkit end
}
--
2.26.0
2.26.2

View file

@ -1,4 +1,4 @@
From a47a0f46d7c03f9ce3c5888be99993111aab36de Mon Sep 17 00:00:00 2001
From bd039fe4f27ea8f45a60714fb121a7e639eb0b94 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Fri, 9 Jun 2017 19:03:43 +0200
Subject: [PATCH] Use TerminalConsoleAppender for console improvements
@ -19,7 +19,7 @@ Other changes:
configuration
diff --git a/pom.xml b/pom.xml
index 3dc6c2a3..b1f00873 100644
index 3dc6c2a3f5..b1f008738b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,10 +41,27 @@
@ -75,7 +75,7 @@ index 3dc6c2a3..b1f00873 100644
<groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
new file mode 100644
index 00000000..cd6e2592
index 0000000000..cd6e259239
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
@@ -0,0 +1,40 @@
@ -121,7 +121,7 @@ index 00000000..cd6e2592
+}
diff --git a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
new file mode 100644
index 00000000..685deaa0
index 0000000000..685deaa0e5
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
@@ -0,0 +1,17 @@
@ -143,7 +143,7 @@ index 00000000..685deaa0
+
+}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 4b1f8c53..d34f772f 100644
index 4b1f8c5373..d34f772fae 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -86,6 +86,9 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@ -185,7 +185,7 @@ index 4b1f8c53..d34f772f 100644
System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index af2fa93d..94f9201f 100644
index 8d6a089007..284793e4bf 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -57,7 +57,7 @@ import org.apache.commons.lang3.Validate;
@ -234,7 +234,7 @@ index af2fa93d..94f9201f 100644
} catch (Exception ignored) {
}
// CraftBukkit end
@@ -1473,7 +1477,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1475,7 +1479,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Override
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
@ -244,7 +244,7 @@ index af2fa93d..94f9201f 100644
public KeyPair getKeyPair() {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 56266a77..77f1ddc8 100644
index 56266a7729..77f1ddc8a8 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -76,8 +76,7 @@ public abstract class PlayerList {
@ -258,7 +258,7 @@ index 56266a77..77f1ddc8 100644
this.k = new GameProfileBanList(PlayerList.b);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2e0f443d..742c2148 100644
index 2e0f443d9f..742c21480a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -42,7 +42,6 @@ import java.util.logging.Level;
@ -284,7 +284,7 @@ index 2e0f443d..742c2148 100644
@Override
public PluginCommand getPluginCommand(String name) {
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 93fcfd5f..0e76e346 100644
index 93fcfd5f39..0e76e34664 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -13,7 +13,7 @@ import java.util.logging.Logger;
@ -335,7 +335,7 @@ index 93fcfd5f..0e76e346 100644
} catch (Throwable t) {
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
deleted file mode 100644
index fdf2f075..00000000
index fdf2f075e2..0000000000
--- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java
+++ /dev/null
@@ -1,72 +0,0 @@
@ -412,7 +412,7 @@ index fdf2f075..00000000
- }
-}
diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
index befcc19f..5510266f 100644
index befcc19f9b..5510266fb1 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
@@ -4,20 +4,31 @@ import java.util.Collections;
@ -495,7 +495,7 @@ index befcc19f..5510266f 100644
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
index 70f8d429..449e99d1 100644
index 70f8d42992..449e99d1b6 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
@@ -17,7 +17,7 @@ public class ServerShutdownThread extends Thread {
@ -509,7 +509,7 @@ index 70f8d429..449e99d1 100644
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
deleted file mode 100644
index 99564fed..00000000
index 99564fed7c..0000000000
--- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java
+++ /dev/null
@@ -1,58 +0,0 @@
@ -573,13 +573,13 @@ index 99564fed..00000000
-}
diff --git a/src/main/resources/log4j2.component.properties b/src/main/resources/log4j2.component.properties
new file mode 100644
index 00000000..0694b214
index 0000000000..0694b21465
--- /dev/null
+++ b/src/main/resources/log4j2.component.properties
@@ -0,0 +1 @@
+log4j.skipJansi=true
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
index 722ca849..620b9490 100644
index 722ca84968..620b9490e5 100644
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
@@ -1,17 +1,14 @@
@ -617,5 +617,5 @@ index 722ca849..620b9490 100644
</Loggers>
</Configuration>
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 210d72e066a073c2bcce64032a1a0037641c369d Mon Sep 17 00:00:00 2001
From 8a6737ec1d8a570f928e92e023d0edb85c27cc0a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 15 Jan 2018 22:11:48 -0500
Subject: [PATCH] Basic PlayerProfile API
@ -7,7 +7,7 @@ Establishes base extension of profile systems for future edits too
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
new file mode 100644
index 00000000..b151a13c
index 0000000000..b151a13c1b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -0,0 +1,280 @@
@ -293,7 +293,7 @@ index 00000000..b151a13c
+}
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java
new file mode 100644
index 00000000..25836b97
index 0000000000..25836b975b
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperAuthenticationService.java
@@ -0,0 +1,30 @@
@ -329,7 +329,7 @@ index 00000000..25836b97
+}
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java
new file mode 100644
index 00000000..3bcdb8f9
index 0000000000..3bcdb8f93f
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java
@@ -0,0 +1,17 @@
@ -352,7 +352,7 @@ index 00000000..3bcdb8f9
+}
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
new file mode 100644
index 00000000..4b2a6742
index 0000000000..4b2a67423f
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
@@ -0,0 +1,29 @@
@ -387,7 +387,7 @@ index 00000000..4b2a6742
+}
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java
new file mode 100644
index 00000000..3aceb0ea
index 0000000000..3aceb0ea8a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperUserAuthentication.java
@@ -0,0 +1,11 @@
@ -403,7 +403,7 @@ index 00000000..3aceb0ea
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 48f88eab..9d0b0c9f 100644
index 48f88eaba4..9d0b0c9fc3 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -1,7 +1,10 @@
@ -429,10 +429,10 @@ index 48f88eab..9d0b0c9f 100644
* Calculates distance between 2 entities
* @param e1
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 94f9201f..ae939c9b 100644
index 284793e4bf..1f27939670 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1299,7 +1299,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1301,7 +1301,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
DispenserRegistry.init();
DispenserRegistry.c();
File s = (File) optionset.valueOf("universe"); // CraftBukkit
@ -441,7 +441,7 @@ index 94f9201f..ae939c9b 100644
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(s, MinecraftServer.b.getName()));
@@ -1764,6 +1764,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1766,6 +1766,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.H = i;
}
@ -450,7 +450,7 @@ index 94f9201f..ae939c9b 100644
return this.minecraftSessionService;
}
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
index 581199e6..a072222b 100644
index 581199e6dc..a072222bc5 100644
--- a/src/main/java/net/minecraft/server/UserCache.java
+++ b/src/main/java/net/minecraft/server/UserCache.java
@@ -43,7 +43,7 @@ public class UserCache {
@ -486,7 +486,7 @@ index 581199e6..a072222b 100644
private UserCacheEntry(GameProfile gameprofile, Date date) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1f1af567..8d23eb0e 100644
index 1f1af567b4..8d23eb0e7b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -199,6 +199,9 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
@ -525,5 +525,5 @@ index 1f1af567..8d23eb0e 100644
// Paper end
}
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From eee8827333c0691fa54044406451dd2c626b43a0 Mon Sep 17 00:00:00 2001
From 769b835f34f38d93a90bc879831d7ab7e9a40109 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Wed, 11 Oct 2017 15:56:26 +0200
Subject: [PATCH] Implement extended PaperServerListPingEvent
@ -6,7 +6,7 @@ Subject: [PATCH] Implement extended PaperServerListPingEvent
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
new file mode 100644
index 00000000..c1a8e295
index 0000000000..c1a8e295b6
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
@@ -0,0 +1,31 @@
@ -43,7 +43,7 @@ index 00000000..c1a8e295
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
new file mode 100644
index 00000000..a2a409e6
index 0000000000..a2a409e635
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
@@ -0,0 +1,11 @@
@ -60,7 +60,7 @@ index 00000000..a2a409e6
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
new file mode 100644
index 00000000..a85466bc
index 0000000000..a85466bc7e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
@@ -0,0 +1,112 @@
@ -177,7 +177,7 @@ index 00000000..a85466bc
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ae939c9b..b292e504 100644
index 1f27939670..c502aedb8d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1,6 +1,9 @@
@ -190,7 +190,7 @@ index ae939c9b..b292e504 100644
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
@@ -1090,7 +1093,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1092,7 +1095,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
if (i - this.Z >= 5000000000L) {
this.Z = i;
this.serverPing.setPlayerSample(new ServerPing.ServerPingPlayerSample(this.getMaxPlayers(), this.getPlayerCount()));
@ -200,7 +200,7 @@ index ae939c9b..b292e504 100644
for (int k = 0; k < agameprofile.length; ++k) {
diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java
index 658ea609..4bb21c48 100644
index 658ea609cb..4bb21c48bd 100644
--- a/src/main/java/net/minecraft/server/PacketStatusListener.java
+++ b/src/main/java/net/minecraft/server/PacketStatusListener.java
@@ -37,6 +37,8 @@ public class PacketStatusListener implements PacketStatusInListener {
@ -223,7 +223,7 @@ index 658ea609..4bb21c48 100644
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/ServerPing.java b/src/main/java/net/minecraft/server/ServerPing.java
index aa125a52..ea52e89b 100644
index aa125a52dc..ea52e89bd9 100644
--- a/src/main/java/net/minecraft/server/ServerPing.java
+++ b/src/main/java/net/minecraft/server/ServerPing.java
@@ -29,6 +29,7 @@ public class ServerPing {
@ -248,7 +248,7 @@ index aa125a52..ea52e89b 100644
this.c = agameprofile;
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 6d77bbc5..1cf214ea 100644
index 6d77bbc5aa..1cf214eaca 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -285,7 +285,7 @@ public class SpigotConfig
@ -261,5 +261,5 @@ index 6d77bbc5..1cf214ea 100644
}
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 0ba45a336be648a77a19ac85a38592499dc56dfd Mon Sep 17 00:00:00 2001
From a9c88692d81b76abc1d47c7e59d2d1d760367b65 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 2 Nov 2018 23:11:51 -0400
Subject: [PATCH] Optimize World Time Updates
@ -8,10 +8,10 @@ the updates per world, so that we can re-use the same packet
object for every player unless they have per-player time enabled.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e7197f20..4d604bd0 100644
index c97bbe933d..3d9cc2ce67 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1164,12 +1164,24 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1166,12 +1166,24 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
// Send time updates to everyone, it will get the right time from the world the player is in.
@ -41,5 +41,5 @@ index e7197f20..4d604bd0 100644
while (iterator.hasNext()) {
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From d5938a4f8bed275a0bf78723ef2e8ed82f8bdeb0 Mon Sep 17 00:00:00 2001
From 9346fa320e8ab02cfb8a9d94c5bdccc6dcc8e964 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Mar 2019 22:48:45 -0400
Subject: [PATCH] Server Tick Events
@ -6,18 +6,18 @@ Subject: [PATCH] Server Tick Events
Fires event at start and end of a server tick
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 4d604bd0..2a8e097f 100644
index 3d9cc2ce67..249eaf56bc 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1087,6 +1087,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1089,6 +1089,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
});
MinecraftTimings.serverOversleep.stopTiming();
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
// Paper end
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.ticks+1).callEvent(); // Paper
++this.ticks;
this.b(booleansupplier);
@@ -1130,6 +1131,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1132,6 +1133,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
// Paper end
@ -31,5 +31,5 @@ index 4d604bd0..2a8e097f 100644
long l = this.f[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 6464e6fdba6fb4db306218b2e5f9073ba75c2131 Mon Sep 17 00:00:00 2001
From 15b80c69702bd35edf18d4b7c07cb12d0e7cdca3 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 13 May 2019 21:10:59 -0700
Subject: [PATCH] Fix CraftServer#isPrimaryThread and MinecraftServer
@ -16,10 +16,10 @@ handling that should have been handled synchronously will be handled
synchronously when the server gets shut down.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2a8e097f..91af2563 100644
index 249eaf56bc..45882ee30f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2215,7 +2215,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -2217,7 +2217,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit start
@Override
public boolean isMainThread() {
@ -29,7 +29,7 @@ index 2a8e097f..91af2563 100644
@Deprecated
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 30dd66b8..0df49581 100644
index 30dd66b81a..0df49581fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1705,7 +1705,7 @@ public final class CraftServer implements Server {
@ -42,5 +42,5 @@ index 30dd66b8..0df49581 100644
@Override
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 9d12499485c97ba0067afecd7f644a91352c2477 Mon Sep 17 00:00:00 2001
From 091bb341d99cb858ab390bed371b416a7126b959 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 9 Jun 2019 03:53:22 +0100
Subject: [PATCH] incremental chunk saving
@ -62,7 +62,7 @@ index b7a2cd7342..0dd873a5dd 100644
public void close() throws IOException {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e9841ef58d..7ca4a7cca8 100644
index 0ee1d8e486..7ecf781263 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -168,6 +168,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -73,7 +73,7 @@ index e9841ef58d..7ca4a7cca8 100644
public File bukkitDataPackFolder;
public CommandDispatcher vanillaCommandDispatcher;
private boolean forceTicks;
@@ -1111,14 +1112,28 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1113,14 +1114,28 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.serverPing.b().a(agameprofile);
}
@ -319,5 +319,5 @@ index 389c9d03a1..62c2275098 100644
this.checkSession();
this.worldProvider.i();
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 0f9018c23eb7702412e86293191b5a69d3da7131 Mon Sep 17 00:00:00 2001
From 90a9b4ac3b0535d33c1f632104a5334f8e9ce64f Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 13 Jul 2019 09:23:10 -0700
Subject: [PATCH] Asynchronous chunk IO and loading
@ -3022,7 +3022,7 @@ index 2dcecc1bbd..d9941b38ca 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7ca4a7cca8..61fc659ed2 100644
index 7ecf781263..26be349870 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -777,6 +777,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -3113,7 +3113,7 @@ index f1620ba80e..74e6b8b973 100644
completablefuture = (CompletableFuture) this.statusFutures.get(i);
if (completablefuture != null) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index b4c9d544fe..7e5fa016c7 100644
index b4c9d544fe..c4fb0c68dd 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -63,7 +63,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -3293,21 +3293,21 @@ index b4c9d544fe..7e5fa016c7 100644
-
- if (nbttagcompound != null) {
- boolean flag = nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8);
-
- if (flag) {
- ProtoChunk protochunk = ChunkRegionLoader.loadChunk(this.world, this.definedStructureManager, this.m, chunkcoordintpair, nbttagcompound);
+ if (ioThrowable != null) {
+ com.destroystokyo.paper.io.IOUtil.rethrow(ioThrowable);
+ }
- protochunk.setLastSaved(this.world.getTime());
- return Either.left(protochunk);
- }
- if (flag) {
- ProtoChunk protochunk = ChunkRegionLoader.loadChunk(this.world, this.definedStructureManager, this.m, chunkcoordintpair, nbttagcompound);
+ this.getVillagePlace().loadInData(chunkcoordintpair, chunkHolder.poiData);
+ chunkHolder.tasks.forEach(Runnable::run);
+ // Paper - async load completes this
+ // Paper end
- protochunk.setLastSaved(this.world.getTime());
- return Either.left(protochunk);
- }
-
- PlayerChunkMap.LOGGER.error("Chunk file at {} is missing level data, skipping", chunkcoordintpair);
+ // Paper start - This is done async
+ if (chunkHolder.protoChunk != null) {
@ -3318,7 +3318,7 @@ index b4c9d544fe..7e5fa016c7 100644
} catch (ReportedException reportedexception) {
Throwable throwable = reportedexception.getCause();
@@ -604,7 +676,27 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -604,7 +676,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
return Either.left(new ProtoChunk(chunkcoordintpair, ChunkConverter.a, this.world)); // Paper - Anti-Xray
@ -3328,8 +3328,13 @@ index b4c9d544fe..7e5fa016c7 100644
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> ret = new CompletableFuture<>();
+
+ Consumer<ChunkRegionLoader.InProgressChunkHolder> chunkHolderConsumer = (ChunkRegionLoader.InProgressChunkHolder holder) -> {
+ PlayerChunkMap.this.executor.addTask(() -> {
+ ret.complete(syncLoadComplete.apply(holder, null));
+ // Go into the chunk load queue and not server task queue so we can be popped out even faster.
+ com.destroystokyo.paper.io.chunk.ChunkTaskManager.queueChunkWaitTask(() -> {
+ try {
+ ret.complete(syncLoadComplete.apply(holder, null));
+ } catch (Exception e) {
+ ret.completeExceptionally(e);
+ }
+ });
+ };
+
@ -3347,7 +3352,7 @@ index b4c9d544fe..7e5fa016c7 100644
}
private CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> b(PlayerChunk playerchunk, ChunkStatus chunkstatus) {
@@ -822,18 +914,43 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -822,18 +919,43 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return this.u.get();
}
@ -3399,7 +3404,7 @@ index b4c9d544fe..7e5fa016c7 100644
ichunkaccess.setLastSaved(this.world.getTime());
ichunkaccess.setNeedsSaving(false);
@@ -844,28 +961,35 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -844,28 +966,35 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
NBTTagCompound nbttagcompound;
if (chunkstatus.getType() != ChunkStatus.Type.LEVELCHUNK) {
@ -3437,7 +3442,7 @@ index b4c9d544fe..7e5fa016c7 100644
}
protected void setViewDistance(int i) {
@@ -969,6 +1093,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -969,6 +1098,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
}
@ -3480,7 +3485,7 @@ index b4c9d544fe..7e5fa016c7 100644
@Nullable
public NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { // Paper - private -> public
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
@@ -991,33 +1151,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -991,33 +1156,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper start - chunk status cache "api"
public ChunkStatus getChunkStatusOnDiskIfCached(ChunkCoordIntPair chunkPos) {
@ -3547,7 +3552,7 @@ index b4c9d544fe..7e5fa016c7 100644
}
public IChunkAccess getUnloadingChunk(int chunkX, int chunkZ) {
@@ -1026,6 +1208,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1026,6 +1213,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
// Paper end
@ -3587,7 +3592,7 @@ index b4c9d544fe..7e5fa016c7 100644
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
// Spigot start
return isOutsideOfRange(chunkcoordintpair, false);
@@ -1371,6 +1586,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1371,6 +1591,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
@ -4170,5 +4175,5 @@ index 07936eeba2..5bdcdcf9e8 100644
log.log( Level.SEVERE, "------------------------------" );
//
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 30b5dc4b6adee3603770473e1799d48e597b14c9 Mon Sep 17 00:00:00 2001
From 590aedc1bb3a7452d665965d965a1f4e41f53c9a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Apr 2016 22:09:52 -0400
Subject: [PATCH] Optimize Hoppers
@ -73,10 +73,10 @@ index d953cdef14..d6e43313bf 100644
itemstack.d(this.C());
if (this.tag != null) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 61fc659ed2..177d1445ad 100644
index 26be349870..63db74993c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1217,6 +1217,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1219,6 +1219,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
WorldServer worldserver = (WorldServer) iterator.next();
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
@ -385,5 +385,5 @@ index 568e04faa3..9e161746f2 100644
int i = MathHelper.floor((axisalignedbb.minX - 2.0D) / 16.0D);
int j = MathHelper.f((axisalignedbb.maxX + 2.0D) / 16.0D);
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 5372ac364bf598a98dc866d750ddba5123f3033a Mon Sep 17 00:00:00 2001
From ee5f32adf9899ad77d47aa5e49d30b2175533a6b Mon Sep 17 00:00:00 2001
From: froobynooby <froobynooby@froobworld.com>
Date: Thu, 20 Feb 2020 15:50:49 +0930
Subject: [PATCH] Reduce entity tracker updates on move
@ -40,7 +40,7 @@ packets often show up as a major contributor to TPS loss in
servers with large player counts
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 7ca67a4a..e93176d8 100644
index 7ca67a4aa5..e93176d8f2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -668,4 +668,9 @@ public class PaperWorldConfig {
@ -54,7 +54,7 @@ index 7ca67a4a..e93176d8 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 24545b33..828ba458 100644
index 24545b3349..828ba4584b 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -86,6 +86,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -69,7 +69,7 @@ index 24545b33..828ba458 100644
// CraftBukkit start
public String displayName;
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index f564502f..0186ab9e 100644
index 70c4bf7287..f570c40496 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -133,6 +133,39 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -120,7 +120,7 @@ index f564502f..0186ab9e 100644
}
public void updatePlayerMobTypeMap(Entity entity) {
@@ -1334,8 +1368,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1339,8 +1373,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
public void movePlayer(EntityPlayer entityplayer) {
@ -141,7 +141,7 @@ index f564502f..0186ab9e 100644
while (objectiterator.hasNext()) {
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
@@ -1345,6 +1390,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1350,6 +1395,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunkmap_entitytracker.updatePlayer(entityplayer);
}
}
@ -149,7 +149,7 @@ index f564502f..0186ab9e 100644
int i = MathHelper.floor(entityplayer.locX()) >> 4;
int j = MathHelper.floor(entityplayer.locZ()) >> 4;
@@ -1486,12 +1532,21 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1491,12 +1537,21 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunkmap_entitytracker.clear(entityplayer);
}
@ -171,7 +171,7 @@ index f564502f..0186ab9e 100644
}
entity.tracker = null; // Paper - We're no longer tracked
}
@@ -1532,7 +1587,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1537,7 +1592,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
world.timings.tracker2.stopTiming(); // Paper
}
@ -180,7 +180,7 @@ index f564502f..0186ab9e 100644
}
@@ -1581,6 +1636,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1586,6 +1641,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
}
}
@ -188,7 +188,7 @@ index f564502f..0186ab9e 100644
Iterator iterator;
Entity entity1;
@@ -1677,6 +1733,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1682,6 +1738,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
org.spigotmc.AsyncCatcher.catchOp("player tracker clear"); // Spigot
if (this.trackedPlayers.remove(entityplayer)) {
this.trackerEntry.a(entityplayer);
@ -196,7 +196,7 @@ index f564502f..0186ab9e 100644
}
}
@@ -1713,9 +1770,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1718,9 +1775,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
if (flag1 && this.trackedPlayerMap.putIfAbsent(entityplayer, true) == null) { // Paper
this.trackerEntry.b(entityplayer);
@ -209,5 +209,5 @@ index f564502f..0186ab9e 100644
}
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From feee85c5270a67f4b6c53789ecf8509aeaf81ec3 Mon Sep 17 00:00:00 2001
From 6a1574bd21ab6847006a7442f92ec0d6ec49e974 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 2 Apr 2020 01:42:39 -0400
Subject: [PATCH] Prevent Double PlayerChunkMap adds crashing server
@ -7,10 +7,10 @@ Suspected case would be around the technique used in .stopRiding
Stack will identify any causer of this and warn instead of crashing.
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 0186ab9e40..e1e4ea793a 100644
index f570c40496..be75b9dd14 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1484,6 +1484,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1489,6 +1489,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
protected void addEntity(Entity entity) {
org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot
@ -47,5 +47,5 @@ index b3e1e3686b..142770bcd6 100644
if (entity.origin == null) {
entity.origin = entity.getBukkitEntity().getLocation();
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From ce1db781f0616e0667f80d3395381026b1107547 Mon Sep 17 00:00:00 2001
From cbbb713b9977ebf9c0df1bbc3b8f23112867da14 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 8 Apr 2020 03:06:30 -0400
Subject: [PATCH] Optimize PlayerChunkMap memory use for visibleChunks
@ -76,7 +76,7 @@ index d9941b38ca..71ab65e00f 100644
List<PlayerChunk> allChunks = new ArrayList<>(visibleChunks.values());
List<EntityPlayer> players = world.players;
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index e1e4ea793a..e61ddeb1ff 100644
index be75b9dd14..90e4811157 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -55,8 +55,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -197,7 +197,7 @@ index e1e4ea793a..e61ddeb1ff 100644
this.updatingChunksModified = false;
return true;
}
@@ -1104,12 +1163,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1109,12 +1168,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
protected Iterable<PlayerChunk> f() {
@ -271,5 +271,5 @@ index 051506fce8..630d6470a4 100644
return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.server.Chunk::getBukkitChunk).toArray(Chunk[]::new);
}
--
2.25.1
2.26.2

View file

@ -1,7 +1,8 @@
From df60dff93009e0cf28dc3e5b984d1a5afbf93bd2 Mon Sep 17 00:00:00 2001
From fb41ea17cc836804549b69cb7112416be1b156c0 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 9 Apr 2020 00:09:26 -0400
Subject: [PATCH] Speed up processing of chunk loads and generation
Subject: [PATCH] Mid Tick Chunk Tasks - Speed up processing of chunk loads and
generation
Credit to Spotted for the idea
@ -24,16 +25,12 @@ looking for work to do.
We do this in a fair method that considers all worlds, not just the one being
ticked, so that each world can get 1 task procesed each before the next pass.
We also cap the throughput of these task processes to 1 per world per 0.1ms or
200 max per tick, to ensure that high volume of tasks do not overload the current
tick time.
In a view distance of 15, chunk loading performance was visually faster on the client.
Flying at high speed in spectator mode was able to keep up with chunk loading (as long as they are already generated)
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
index 69e26a8267..434833d50e 100644
index 223d3b1125..37341d2d2e 100644
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -13,6 +13,7 @@ import java.util.Map;
@ -44,8 +41,22 @@ index 69e26a8267..434833d50e 100644
public static final Timing playerListTimer = Timings.ofSafe("Player List");
public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 6916ed30c4..1e186f149c 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -428,4 +428,9 @@ public class PaperConfig {
*/
}
}
+
+ public static int midTickChunkTasks = 1000;
+ private static void midTickChunkTasks() {
+ midTickChunkTasks = getInt("settings.chunk-tasks-per-tick", midTickChunkTasks);
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 3d79e756d9..5fea6e56d5 100644
index 3d79e756d9..98ce805a64 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -683,6 +683,7 @@ public class ChunkProviderServer extends IChunkProvider {
@ -81,37 +92,40 @@ index 3d79e756d9..5fea6e56d5 100644
}
}
});
@@ -974,6 +977,38 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -974,6 +977,41 @@ public class ChunkProviderServer extends IChunkProvider {
super.executeTask(runnable);
}
+ // Paper start
+ private long lastChunkTask = 0;
+ private long lastMidTickChunkTask = 0;
+ public boolean pollChunkLoadTasks() {
+ if (com.destroystokyo.paper.io.chunk.ChunkTaskManager.pollChunkWaitQueue() || ChunkProviderServer.this.world.asyncChunkTaskManager.pollNextChunkTask()) {
+ try {
+ ChunkProviderServer.this.tickDistanceManager();
+ } finally {
+ // from below: process pending Chunk loadCallback() and unloadCallback() after each run task
+ playerChunkMap.callbackExecutor.run();
+ }
+ return true;
+ }
+ return false;
+ }
+ public void midTickLoadChunks() {
+ MinecraftServer server = ChunkProviderServer.this.world.getMinecraftServer();
+ try (co.aikar.timings.Timing ignored = co.aikar.timings.MinecraftTimings.midTickChunkTasks.startTiming()) {
+ while (server.canSleepForTick()) {
+ try {
+ // always try to load chunks as long as we aren't falling behind, restrain generation/other updates only.
+ boolean execChunkTask = com.destroystokyo.paper.io.chunk.ChunkTaskManager.pollChunkWaitQueue() || ChunkProviderServer.this.world.asyncChunkTaskManager.pollNextChunkTask(); // Paper
+ if (ChunkProviderServer.this.tickDistanceManager() || execChunkTask) {
+ continue;
+ }
+ long now = System.nanoTime();
+ // cap to 1 task every 0.1ms per world and max 200 tasks per tick.
+ // Anything that doesn't make it past this can load during sleep
+ // we do not want to use this.executeNext as that also processes chunk loads and might count against task counter.
+ // We also have already ticked the distance manager above too.
+ if (server.chunksTasksRan < 200 && now - lastChunkTask > 100000 && super.executeNext()) {
+ ChunkProviderServer.this.lightEngine.queueUpdate();
+ server.chunksTasksRan++;
+ lastChunkTask = now;
+ }
+ break;
+ } finally {
+ // from below: process pending Chunk loadCallback() and unloadCallback() after each run task
+ playerChunkMap.callbackExecutor.run();
+ }
+ // always try to load chunks, restrain generation/other updates only. don't count these towards tick count
+ //noinspection StatementWithEmptyBody
+ while (pollChunkLoadTasks()) {}
+
+ if (System.nanoTime() - lastMidTickChunkTask < 1000000) {
+ return;
+ }
+
+ for (;server.midTickChunksTasksRan < com.destroystokyo.paper.PaperConfig.midTickChunkTasks && server.canSleepForTick();) {
+ if (this.executeNext()) {
+ server.midTickChunksTasksRan++;
+ lastMidTickChunkTask = System.nanoTime();
+ } else {
+ break;
+ }
+ }
+ }
@ -121,14 +135,14 @@ index 3d79e756d9..5fea6e56d5 100644
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e35bacac71..2f424e6e8b 100644
index 77adc64e30..3c25436f15 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -907,6 +907,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper end
tickSection = curTime;
}
+ chunksTasksRan = 0; // Paper
+ midTickChunksTasksRan = 0; // Paper
// Spigot end
//MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time
@ -139,22 +153,25 @@ index e35bacac71..2f424e6e8b 100644
- private boolean canSleepForTick() {
+ public boolean canSleepForTick() { // Paper
// CraftBukkit start
if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick);
}
@@ -1005,6 +1006,20 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1007,6 +1008,23 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
});
}
+ // Paper start
+ public int chunksTasksRan = 0;
+ public int midTickChunksTasksRan = 0;
+ private long midTickLastRan = 0;
+ public void midTickLoadChunks() {
+ if (!this.canSleepForTick()) {
+ if (!isMainThread() || System.nanoTime() - midTickLastRan < 250000) {
+ // only check once per 0.25ms incase this code is called in a hot method
+ return;
+ }
+
+ Iterator<WorldServer> iterator = this.getWorlds().iterator();
+ while (this.canSleepForTick() && iterator.hasNext()) {
+ iterator.next().getChunkProvider().serverThreadQueue.midTickLoadChunks();
+ try (co.aikar.timings.Timing ignored = co.aikar.timings.MinecraftTimings.midTickChunkTasks.startTiming()) {
+ for (WorldServer value : this.getWorlds()) {
+ value.getChunkProvider().serverThreadQueue.midTickLoadChunks();
+ }
+ midTickLastRan = System.nanoTime();
+ }
+ }
+ // Paper end
@ -162,21 +179,54 @@ index e35bacac71..2f424e6e8b 100644
@Override
protected TickTask postToMainThread(Runnable runnable) {
return new TickTask(this.ticks, runnable);
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index e61ddeb1ff..92c9ab43d7 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -793,7 +793,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> ret = new CompletableFuture<>();
@@ -1093,6 +1111,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper start - move oversleep into full server tick
isOversleep = true;MinecraftTimings.serverOversleep.startTiming();
this.awaitTasks(() -> {
+ midTickLoadChunks(); // will only do loads since we are still considered !canSleepForTick
return !this.canOversleep();
});
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
@@ -1175,13 +1194,16 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
Consumer<ChunkRegionLoader.InProgressChunkHolder> chunkHolderConsumer = (ChunkRegionLoader.InProgressChunkHolder holder) -> {
- PlayerChunkMap.this.executor.addTask(() -> {
+ com.destroystokyo.paper.io.chunk.ChunkTaskManager.queueChunkWaitTask(() -> {
ret.complete(syncLoadComplete.apply(holder, null));
});
};
protected void b(BooleanSupplier booleansupplier) {
+ midTickLoadChunks(); // Paper
MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper
+ midTickLoadChunks(); // Paper
this.methodProfiler.enter("commandFunctions");
MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper
this.getFunctionData().tick();
MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper
+ midTickLoadChunks(); // Paper
this.methodProfiler.exitEnter("levels");
Iterator iterator = this.getWorlds().iterator();
@@ -1192,7 +1214,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
processQueue.remove().run();
}
MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
-
+ midTickLoadChunks(); // Paper
MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
// Send time updates to everyone, it will get the right time from the world the player is in.
// Paper start - optimize time updates
@@ -1235,9 +1257,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.enter("tick");
try {
+ midTickLoadChunks(); // Paper
worldserver.timings.doTick.startTiming(); // Spigot
worldserver.doTick(booleansupplier);
worldserver.timings.doTick.stopTiming(); // Spigot
+ midTickLoadChunks(); // Paper
} catch (Throwable throwable) {
// Spigot Start
CrashReport crashreport;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 33de08a8ac..4a63536dee 100644
index 142770bcd6..3f62fe2bb1 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -420,6 +420,7 @@ public class WorldServer extends World {
@ -203,16 +253,14 @@ index 33de08a8ac..4a63536dee 100644
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
while ((entity = (Entity) this.entitiesToAdd.poll()) != null) {
@@ -527,7 +530,9 @@ public class WorldServer extends World {
@@ -527,6 +530,7 @@ public class WorldServer extends World {
gameprofilerfiller.exit();
timings.tickEntities.stopTiming(); // Spigot
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
this.tickBlockEntities();
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
}
gameprofilerfiller.exit();
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 048cb4331912704eb3734c0389859539b5dcba26 Mon Sep 17 00:00:00 2001
From a1b5e7896867af0ae6ef0cddc1b68e5b7d7981bf Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sun, 5 Apr 2020 22:23:14 -0500
Subject: [PATCH] Add tick times API and /mspt command
@ -6,7 +6,7 @@ Subject: [PATCH] Add tick times API and /mspt command
diff --git a/src/main/java/com/destroystokyo/paper/MSPTCommand.java b/src/main/java/com/destroystokyo/paper/MSPTCommand.java
new file mode 100644
index 00000000..d0211d4f
index 0000000000..d0211d4f39
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/MSPTCommand.java
@@ -0,0 +1,64 @@
@ -75,7 +75,7 @@ index 00000000..d0211d4f
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 6916ed30..1c4cd363 100644
index 1e186f149c..13d8934508 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -70,6 +70,7 @@ public class PaperConfig {
@ -87,7 +87,7 @@ index 6916ed30..1c4cd363 100644
version = getInt("config-version", 20);
set("config-version", 20);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2f424e6e..7bfadb35 100644
index a1d662f1e3..01534d19d4 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -106,6 +106,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -102,7 +102,7 @@ index 2f424e6e..7bfadb35 100644
@Nullable
private KeyPair I;
@Nullable
@@ -1180,6 +1185,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1186,6 +1191,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.av = this.av * 0.8F + (float) l / 1000000.0F * 0.19999999F;
long i1 = SystemUtils.getMonotonicNanos();
@ -115,7 +115,7 @@ index 2f424e6e..7bfadb35 100644
this.circularTimer.a(i1 - i);
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
@@ -2261,4 +2272,30 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -2272,4 +2283,30 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
return SERVER; // Paper
}
// CraftBukkit end
@ -147,7 +147,7 @@ index 2f424e6e..7bfadb35 100644
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b9a398bc..53b71b79 100644
index b9a398bc57..53b71b7915 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2052,6 +2052,16 @@ public final class CraftServer implements Server {
@ -168,5 +168,5 @@ index b9a398bc..53b71b79 100644
private final Spigot spigot = new Spigot()
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 98260d8a7b814a9c1fbdd4002c40e7182e36ecf6 Mon Sep 17 00:00:00 2001
From 3bdf52eb971e76f98beef7dd5bc361e55fce2232 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 11 Apr 2020 03:56:07 -0400
Subject: [PATCH] Implement Chunk Priority / Urgency System for World Gen
@ -16,7 +16,7 @@ lots of chunks already.
This massively reduces the lag spikes from sync chunk gens.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 5fea6e56d5..bcf59beed6 100644
index 98ce805a64..640265c3bd 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -308,6 +308,7 @@ public class ChunkProviderServer extends IChunkProvider {
@ -197,7 +197,7 @@ index 04b97cec29..568fbbd5f2 100644
private void d(int i) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 92c9ab43d7..c38d31fafe 100644
index 90e4811157..0de3f6029c 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -324,6 +324,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -216,7 +216,7 @@ index 92c9ab43d7..c38d31fafe 100644
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = playerchunk.a(chunkstatus, this);
list.add(completablefuture);
@@ -799,23 +801,28 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -804,23 +806,28 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
};
CompletableFuture<NBTTagCompound> chunkSaveFuture = this.world.asyncChunkTaskManager.getChunkSaveFuture(chunkcoordintpair.x, chunkcoordintpair.z);
@ -250,7 +250,7 @@ index 92c9ab43d7..c38d31fafe 100644
this.world.getMethodProfiler().c(() -> {
return "chunkGenerate " + chunkstatus.d();
@@ -843,6 +850,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -848,6 +855,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
});
}, (runnable) -> {
@ -258,7 +258,7 @@ index 92c9ab43d7..c38d31fafe 100644
this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
});
}
@@ -855,6 +863,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -860,6 +868,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}));
}
@ -266,7 +266,7 @@ index 92c9ab43d7..c38d31fafe 100644
private ChunkStatus a(ChunkStatus chunkstatus, int i) {
ChunkStatus chunkstatus1;
@@ -979,9 +988,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -984,9 +993,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public CompletableFuture<Either<Chunk, PlayerChunk.Failure>> a(PlayerChunk playerchunk) {
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
@ -280,5 +280,5 @@ index 92c9ab43d7..c38d31fafe 100644
return either.flatMap((list) -> {
Chunk chunk = (Chunk) list.get(list.size() / 2);
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From 6a79fcb39fedf8d5f398026e6da8c616d34470f4 Mon Sep 17 00:00:00 2001
From 2f634c7ef7576d0011a745b806127c13c4856c14 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 12 Apr 2020 15:50:48 -0400
Subject: [PATCH] Forced Watchdog Crash support and Improve Async Shutdown
@ -73,7 +73,7 @@ index cfe43e882e..2632c7c3ec 100644
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7bfadb35d2..1086d1caac 100644
index 01534d19d4..94daf684b1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -144,6 +144,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@ -164,7 +164,7 @@ index 7bfadb35d2..1086d1caac 100644
}
}
@@ -1027,6 +1051,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1032,6 +1056,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Override
protected TickTask postToMainThread(Runnable runnable) {
@ -203,7 +203,7 @@ index dc6d030621..bc8b904660 100644
SystemUtils.c.shutdown();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index d554d4cf0f..46e19d916c 100644
index 5e6481f115..d530508b61 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -786,6 +786,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@ -345,5 +345,5 @@ index 5bdcdcf9e8..fe4b8caf28 100644
break;
} // Paper end
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From d4150f3df14622ffc4ad49ff655ba6aaa23114bb Mon Sep 17 00:00:00 2001
From 4922e0520435d838eabc020f440b9c95e7e4b0de Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Apr 2020 04:36:11 -0400
Subject: [PATCH] Fix Chunk Post Processing deadlock risk
@ -25,43 +25,22 @@ This successfully fixed a reoccurring and highly reproduceable crash
for heightmaps.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 15bd3cacb3..2d4d7250f2 100644
index 8f4d4f2283..e63333fcab 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -1019,6 +1019,7 @@ public class ChunkProviderServer extends IChunkProvider {
// we do not want to use this.executeNext as that also processes chunk loads and might count against task counter.
// We also have already ticked the distance manager above too.
if (server.chunksTasksRan < 200 && now - lastChunkTask > 100000 && super.executeNext()) {
+ ChunkProviderServer.this.playerChunkMap.chunkLoadConversionCallbackExecutor.run(); // run immediately after a task is potentially queued
ChunkProviderServer.this.lightEngine.queueUpdate();
server.chunksTasksRan++;
lastChunkTask = now;
@@ -1042,7 +1043,11 @@ public class ChunkProviderServer extends IChunkProvider {
return true;
} else {
ChunkProviderServer.this.lightEngine.queueUpdate();
- return super.executeNext() || execChunkTask; // Paper
+ // Paper start - Add chunk load conversion callback executor to prevent deadlock due to recursion in the chunk task queue sorter
+ boolean executed = super.executeNext();
+ ChunkProviderServer.this.playerChunkMap.chunkLoadConversionCallbackExecutor.run(); // run immediately after a task is potentially queued
+ return executed || execChunkTask;
+ // Paper end - Add chunk load conversion callback executor to prevent deadlock due to recursion in the chunk task queue sorter
@@ -1048,6 +1048,7 @@ public class ChunkProviderServer extends IChunkProvider {
return super.executeNext() || execChunkTask; // Paper
}
} finally {
+ playerChunkMap.chunkLoadConversionCallbackExecutor.run(); // Paper - Add chunk load conversion callback executor to prevent deadlock due to recursion in the chunk task queue sorter
playerChunkMap.callbackExecutor.run();
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index c38d31fafe..e19342eb89 100644
index 0de3f6029c..f5a28e9322 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -92,6 +92,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@Override
public void execute(Runnable runnable) {
if (queued != null) {
+ MinecraftServer.LOGGER.fatal("Failed to schedule runnable", new IllegalStateException("Already queued")); // Paper - make sure this is printed
throw new IllegalStateException("Already queued");
}
queued = runnable;
@@ -108,6 +109,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -108,6 +108,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
};
// CraftBukkit end
@ -70,7 +49,7 @@ index c38d31fafe..e19342eb89 100644
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<EntityPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@@ -1002,7 +1005,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1007,7 +1009,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return Either.left(chunk);
});
}, (runnable) -> {
@ -80,5 +59,5 @@ index c38d31fafe..e19342eb89 100644
completablefuture1.thenAcceptAsync((either) -> {
--
2.25.1
2.26.2

View file

@ -1,4 +1,4 @@
From ecc9b88983b43be7ef71207cfc8dbfbe37af3933 Mon Sep 17 00:00:00 2001
From 86c75a3c0ae4e295e196d3faf1e43f12e9f10782 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 19 Apr 2020 00:05:46 -0400
Subject: [PATCH] Fix Longstanding Broken behavior of PlayerJoinEvent
@ -28,7 +28,7 @@ receives a deterministic result, and should no longer require 1 tick
delays anymore.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index f3928b8f..686fd4cb 100644
index f3928b8f6f..686fd4cbad 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -104,6 +104,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -40,10 +40,10 @@ index f3928b8f..686fd4cb 100644
// CraftBukkit end
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index e19342eb..8b2eed10 100644
index f5a28e9322..9425b36403 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1565,6 +1565,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1569,6 +1569,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
.printStackTrace();
return;
}
@ -52,7 +52,7 @@ index e19342eb..8b2eed10 100644
if (!(entity instanceof EntityComplexPart)) {
if (!(entity instanceof EntityLightning)) {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 7403be0b..ec45c30d 100644
index 7403be0b25..ec45c30dd3 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -175,6 +175,12 @@ public abstract class PlayerList {
@ -101,5 +101,5 @@ index 7403be0b..ec45c30d 100644
// Paper start - Add to collideRule team if needed
final Scoreboard scoreboard = this.getServer().getWorldServer(DimensionManager.OVERWORLD).getScoreboard();
--
2.25.1.windows.1
2.26.2

View file

@ -1,4 +1,4 @@
From 0f4ba3f787e0860be4e312a4eaaa2a9556624bf8 Mon Sep 17 00:00:00 2001
From 74c25fa52e0597b02faef91663c35c1279a33369 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 21 Apr 2020 03:51:53 -0400
Subject: [PATCH] Allow multiple callbacks to schedule for Callback Executor
@ -11,35 +11,44 @@ needed within a single tick of ChunkMapDistance
Use an ArrayDeque to store this Queue
We make sure to also implement a pattern that is recursion safe too.
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 8b2eed10..ee0cabad 100644
index 2ea06224f3..99b490374d 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -87,25 +87,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -87,24 +87,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
- private Runnable queued;
+ // Paper start - replace impl with Deque - possible multiple is needed in single pass
+ private java.util.Deque<Runnable> queued = new java.util.ArrayDeque<>();
+ // Paper start - replace impl with recursive safe multi entry queue
+ // it's possible to schedule multiple tasks currently, so it's vital we change this impl
+ // If we recurse into the executor again, we will append to another queue, ensuring task order consistency
+ private java.util.ArrayDeque<Runnable> queued = new java.util.ArrayDeque<>();
@Override
public void execute(Runnable runnable) {
- if (queued != null) {
- MinecraftServer.LOGGER.fatal("Failed to schedule runnable", new IllegalStateException("Already queued")); // Paper - make sure this is printed
- throw new IllegalStateException("Already queued");
- }
+ if (queued == null) {
+ queued = new java.util.ArrayDeque<>();
}
- queued = runnable;
+ queued.add(runnable); // Paper
+ queued.add(runnable);
}
@Override
public void run() {
- Runnable task = queued;
- queued = null;
+ if (queued == null) {
+ return;
+ }
+ java.util.ArrayDeque<Runnable> queue = queued;
queued = null;
- if (task != null) {
+ Runnable task;
+ while ((task = queued.pollFirst()) != null) {
+ while ((task = queue.pollFirst()) != null) {
task.run();
}
}
@ -48,5 +57,5 @@ index 8b2eed10..ee0cabad 100644
// CraftBukkit end
--
2.25.1.windows.1
2.26.2