Paper/Spigot-Server-Patches/0111-remove-null-possibility-for-getServer-singleton.patch

41 lines
2.0 KiB
Diff
Raw Normal View History

2018-07-22 04:03:10 +08:00
From c1a4ecfa714d709d6c41f26869d7f52f45e27db2 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
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
2018-07-22 04:03:10 +08:00
index 3c201c2e2..05dc8451e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -68,6 +68,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
+ private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogManager.getLogger();
public static final File a = new File("usercache.json");
public Convertable convertable;
2018-07-22 04:03:10 +08:00
@@ -153,6 +154,8 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
2017-01-31 12:33:54 +08:00
// Spigot end
public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+ SERVER = this; // Paper - better singleton
2018-07-22 04:03:10 +08:00
+ this.commandDispatcher = commanddispatcher; // CraftBukkit
this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA);
this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new);
2018-07-22 04:03:10 +08:00
this.ag = new CraftingManager();
@@ -1742,7 +1745,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
// CraftBukkit start
@Deprecated
public static MinecraftServer getServer() {
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+ return SERVER;
}
// CraftBukkit end
}
--
2.18.0