3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0095-remove-null-possibility-for-getServer-singleton.patch

37 Zeilen
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 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
2020-06-25 13:00:35 +02:00
index 04429bb6f4d75800425087d8a5463ab9f4f4cef3..17846ca9190c63671ad616c668aa1fe1367bcac1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2020-06-25 13:00:35 +02:00
@@ -69,6 +69,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
2020-06-25 13:00:35 +02:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
+ private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogManager.getLogger();
2019-04-27 05:05:36 +02:00
public static final File b = new File("usercache.json");
2020-06-25 13:00:35 +02:00
public static final WorldSettings c = new WorldSettings("Demo World", EnumGamemode.SURVIVAL, false, EnumDifficulty.NORMAL, false, new GameRules(), DataPackConfiguration.a);
@@ -176,6 +177,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository<ResourcePackLoader> resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
2019-04-27 05:05:36 +02:00
super("Server");
+ SERVER = this; // Paper - better singleton
2020-06-25 13:00:35 +02:00
this.m = new GameProfilerSwitcher(SystemUtils.a, this::ag);
this.methodProfiler = GameProfilerDisabled.a;
this.serverPing = new ServerPing();
@@ -2033,7 +2035,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-27 05:05:36 +02:00
@Deprecated
public static MinecraftServer getServer() {
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
2019-04-27 05:05:36 +02:00
+ return SERVER; // Paper
}
// CraftBukkit end
2020-06-25 13:00:35 +02:00