Paper/Spigot-Server-Patches/0124-remove-null-possibility-for-getServer-singleton.patch
Aikar 18c3716c49
Current Chunk for Entity and Block Entities, counts by entity type
This enables us a fast reference to the entities current chunk instead
of having to look it up by hashmap lookups.

We also store counts by type to further enable other performance optimizations in later patches.
2018-07-04 03:58:56 -04:00

40 lines
1.9 KiB
Diff

From ce05afd0428918d9eab5599842bc9f2a485120f9 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 b6c4d98fd..45d3dbde2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -53,6 +53,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
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;
@@ -124,6 +125,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
// 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;
this.V = yggdrasilauthenticationservice;
@@ -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
}
--
2.18.0