From aff5924a9a8620c7c5df00a1c59c7e6948da74ca Mon Sep 17 00:00:00 2001 From: Aikar 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 index 9675d5a100..ca5e4cd65a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -73,6 +73,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; @@ -162,6 +163,8 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati // 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 + this.commandDispatcher = commanddispatcher; // CraftBukkit this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA); this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new); this.ag = new CraftingManager(); @@ -1824,7 +1827,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