2019-06-25 01:47:58 +00:00
From aa72827fd9ad7117a8a9fdeb5a4ef07fa6d5bed8 Mon Sep 17 00:00:00 2001
2016-04-30 00:04:12 +00: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-06-25 01:47:58 +00:00
index f88e42423d..f489d47c60 100644
2016-04-30 00:04:12 +00:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-06-25 01:47:58 +00:00
@@ -59,6 +59,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
2016-04-30 00:04:12 +00:00
2019-04-27 03:05:36 +00:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
2016-04-30 00:04:12 +00:00
+ private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogManager.getLogger();
2019-04-27 03:05:36 +00:00
public static final File b = new File("usercache.json");
public static final WorldSettings c = (new WorldSettings((long) "North Carolina".hashCode(), EnumGamemode.SURVIVAL, true, false, WorldType.NORMAL)).a();
2019-06-25 01:47:58 +00:00
@@ -164,6 +165,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 00:04:12 +00:00
2019-04-27 03:05:36 +00: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");
2016-04-30 00:04:12 +00:00
+ SERVER = this; // Paper - better singleton
2019-06-25 01:47:58 +00:00
this.ad = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread);
2019-01-01 03:15:55 +00:00
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
2019-06-25 01:47:58 +00:00
this.ah = new CraftingManager();
@@ -1907,7 +1909,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-27 03:05:36 +00:00
2016-04-30 00:04:12 +00:00
@Deprecated
public static MinecraftServer getServer() {
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
2019-04-27 03:05:36 +00:00
+ return SERVER; // Paper
2016-04-30 00:04:12 +00:00
}
// CraftBukkit end
2016-06-10 02:43:32 +00:00
}
2016-04-30 00:04:12 +00:00
--
2019-06-25 01:47:58 +00:00
2.22.0
2016-04-30 00:04:12 +00:00