aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0137-remove-null-possibility-for-getServer-singleton.patch
blob: 87594bc89568640b75eed010d7a30051566890d8 (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
From 4d88a9833dba3f9449be3f9bc0a9d8f773024fc7 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 01325b3..9455475 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -49,6 +49,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
 
 public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
 
+    private static MinecraftServer SERVER; // Paper
     public static final Logger LOGGER = LogManager.getLogger();
     public static final File a = new File("usercache.json");
     public Convertable convertable;
@@ -116,6 +117,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
     // CraftBukkit end
 
     public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+        SERVER = this; // Paper - better singleton
         io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
         this.e = proxy;
         this.U = yggdrasilauthenticationservice;
@@ -1603,7 +1605,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
     // CraftBukkit start
     @Deprecated
     public static MinecraftServer getServer() {
-        return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+        return SERVER;
     }
     // CraftBukkit end
 }
-- 
2.10.1