Paper/Spigot-Server-Patches/0096-remove-null-possibility-for-getServer-singleton.patch
Spottedleaf 19de9af63c 1.15.2 update (#2887)
Functional GUI fix added by billygalbreath
2020-01-21 20:02:07 -06:00

40 Zeilen
2.2 KiB
Diff

From 6e2d54dddc8e295098bb5d4afdd38e777ef62fc3 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
index deffa2ddb..f45c65877 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -68,6 +68,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
+ private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogManager.getLogger();
public static final File b = new File("usercache.json");
private static final CompletableFuture<Unit> i = CompletableFuture.completedFuture(Unit.INSTANCE);
@@ -178,6 +179,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) {
super("Server");
this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread);
+ SERVER = this; // Paper - better singleton
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
this.craftingManager = new CraftingManager();
this.tagRegistry = new TagRegistry();
@@ -2181,7 +2183,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Deprecated
public static MinecraftServer getServer() {
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+ return SERVER; // Paper
}
// CraftBukkit end
}
--
2.25.0.windows.1