mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-09 06:50:32 +08:00
43ec79a32c
Now everything except waiting for the next tick should be included in timings
40 lines
2.2 KiB
Diff
40 lines
2.2 KiB
Diff
From 2a5c0c28e79e357361e9179b4291881df81cc6c6 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 b4eb53f28a..fbad6a31c1 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -68,6 +68,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
|
|
|
|
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable {
|
|
|
|
+ private static MinecraftServer SERVER; // Paper
|
|
public static final Logger LOGGER = LogManager.getLogger();
|
|
public static final File b = new File("usercache.json");
|
|
private static final CompletableFuture<Unit> i = CompletableFuture.completedFuture(Unit.INSTANCE);
|
|
@@ -175,6 +176,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) {
|
|
super("Server");
|
|
this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread);
|
|
+ SERVER = this; // Paper - better singleton
|
|
this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new);
|
|
this.ai = new CraftingManager();
|
|
this.aj = new TagRegistry();
|
|
@@ -2140,7 +2142,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
|
|
@Deprecated
|
|
public static MinecraftServer getServer() {
|
|
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
|
+ return SERVER; // Paper
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
--
|
|
2.22.1
|
|
|