papermc/Spigot-Server-Patches/0126-remove-null-possibility-for-getServer-singleton.patch

40 lines
1.9 KiB
Diff
Raw Normal View History

2017-01-20 11:21:44 +00:00
From 0196e4e2f059d3adacb627a7647e84fcb3898fa0 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
2017-01-06 21:45:59 +00:00
index 8eef9c4..631a87f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2016-11-17 02:23:38 +00:00
@@ -51,6 +51,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;
2016-11-17 02:23:38 +00:00
@@ -119,6 +120,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;
2016-11-17 02:23:38 +00:00
this.V = yggdrasilauthenticationservice;
2017-01-06 21:45:59 +00:00
@@ -1625,7 +1627,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
}
--
2016-12-10 23:50:31 +00:00
2.9.3