2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-04-30 02:04:12 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Thu, 28 Apr 2016 00:57:27 -0400
|
|
|
|
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
|
2020-05-06 11:48:49 +02:00
|
|
|
index 36d20d5e3a622bb944f89c37e8b9050ccea2c86d..a5aa6553cc5d44ad9be41a4f35de73a1c5bf3cb8 100644
|
2016-04-30 02:04:12 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2019-07-20 06:01:24 +02:00
|
|
|
@@ -68,6 +68,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
|
2016-04-30 02:04:12 +02:00
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
|
2016-04-30 02:04:12 +02:00
|
|
|
|
|
|
|
+ private static MinecraftServer SERVER; // Paper
|
|
|
|
public static final Logger LOGGER = LogManager.getLogger();
|
2019-04-27 05:05:36 +02:00
|
|
|
public static final File b = new File("usercache.json");
|
2019-07-20 06:01:24 +02:00
|
|
|
private static final CompletableFuture<Unit> i = CompletableFuture.completedFuture(Unit.INSTANCE);
|
2019-12-11 03:43:21 +01:00
|
|
|
@@ -178,6 +179,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2019-04-27 05:05:36 +02:00
|
|
|
public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) {
|
|
|
|
super("Server");
|
2019-07-20 06:01:24 +02:00
|
|
|
this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread);
|
2016-04-30 02:04:12 +02:00
|
|
|
+ SERVER = this; // Paper - better singleton
|
2019-01-01 04:15:55 +01:00
|
|
|
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
|
2019-12-11 03:43:21 +01:00
|
|
|
this.craftingManager = new CraftingManager();
|
|
|
|
this.tagRegistry = new TagRegistry();
|
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
2020-04-26 05:47:29 +02:00
|
|
|
@@ -2186,7 +2188,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2019-04-27 05:05:36 +02:00
|
|
|
|
2016-04-30 02:04:12 +02:00
|
|
|
@Deprecated
|
|
|
|
public static MinecraftServer getServer() {
|
|
|
|
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
2019-04-27 05:05:36 +02:00
|
|
|
+ return SERVER; // Paper
|
2016-04-30 02:04:12 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2016-06-10 04:43:32 +02:00
|
|
|
}
|