2019-08-05 18:35:40 +02:00
|
|
|
From 5abf16f7dce2b01baec6c3435941df78b58fc9af 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
|
2019-08-05 18:35:40 +02:00
|
|
|
index e3bd80c934..17b9e9a31d 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);
|
|
|
|
@@ -175,6 +176,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-07-20 06:01:24 +02:00
|
|
|
this.ai = new CraftingManager();
|
|
|
|
this.aj = new TagRegistry();
|
2019-08-05 18:35:40 +02:00
|
|
|
@@ -2123,7 +2125,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
|
|
|
}
|
2016-04-30 02:04:12 +02:00
|
|
|
--
|
2019-06-25 03:47:58 +02:00
|
|
|
2.22.0
|
2016-04-30 02:04:12 +02:00
|
|
|
|