Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
40 Zeilen
1.9 KiB
Diff
40 Zeilen
1.9 KiB
Diff
From 31e86975e071304b48ecb3c603ab1a4774e81720 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 02e8551..3b04681 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -59,6 +59,7 @@ import java.util.Queue;
|
|
|
|
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;
|
|
@@ -127,6 +128,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;
|
|
@@ -1624,7 +1626,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.8.2
|
|
|