aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0109-remove-null-possibility-for-getServer-singleton.patch
blob: f34a1632f86f294dc84a921e625e8c50049ae527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 67dbf6e8151d0938692306062ad09bdc3fd830bc 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 b87520d834..78b60d0e35 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;
@@ -157,6 +158,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();
@@ -1825,7 +1828,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.20.1