3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/Spigot-Server-Patches/0123-remove-null-possibility-for-getServer-singleton.patch

40 Zeilen
1.9 KiB
Diff

2017-08-03 16:36:06 +02:00
From ddf26e44e9968aadbbfbaabbf0e0dbc9ea2196d7 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-08-03 16:36:06 +02:00
index f5d284ca3..948a04491 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2017-08-03 16:36:06 +02:00
@@ -53,6 +53,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
2017-05-14 20:05:01 +02:00
public abstract class MinecraftServer implements ICommandListener, Runnable, 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;
2017-08-03 16:36:06 +02:00
@@ -124,6 +125,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
2017-01-31 05:33:54 +01:00
// Spigot 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 03:23:38 +01:00
this.V = yggdrasilauthenticationservice;
2017-08-03 16:36:06 +02:00
@@ -1636,7 +1638,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
// CraftBukkit start
@Deprecated
public static MinecraftServer getServer() {
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
+ return SERVER;
}
// CraftBukkit end
}
--
2017-08-03 16:36:06 +02:00
2.13.3.windows.1