2018-08-06 07:46:43 +08:00
|
|
|
From f45a5c9addc227e73e61f4afd6fe88ff3bf4f92c Mon Sep 17 00:00:00 2001
|
2016-04-30 08:04:12 +08:00
|
|
|
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
|
2018-08-06 07:46:43 +08:00
|
|
|
index 67c60be6f7..b41e7badff 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -68,6 +68,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
|
2016-04-30 08:04:12 +08:00
|
|
|
|
2018-07-16 23:34:55 +08:00
|
|
|
public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
|
2016-04-30 08:04:12 +08:00
|
|
|
|
|
|
|
+ private static MinecraftServer SERVER; // Paper
|
|
|
|
public static final Logger LOGGER = LogManager.getLogger();
|
|
|
|
public static final File a = new File("usercache.json");
|
|
|
|
public Convertable convertable;
|
2018-07-22 13:27:46 +08:00
|
|
|
@@ -154,6 +155,8 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
2017-01-31 12:33:54 +08:00
|
|
|
// Spigot end
|
2016-04-30 08:04:12 +08:00
|
|
|
|
2018-07-16 23:34:55 +08:00
|
|
|
public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
|
2016-04-30 08:04:12 +08:00
|
|
|
+ SERVER = this; // Paper - better singleton
|
2018-07-22 04:03:10 +08:00
|
|
|
+ this.commandDispatcher = commanddispatcher; // CraftBukkit
|
2018-07-16 23:34:55 +08:00
|
|
|
this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA);
|
|
|
|
this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new);
|
2018-07-22 04:03:10 +08:00
|
|
|
this.ag = new CraftingManager();
|
2018-07-23 07:53:01 +08:00
|
|
|
@@ -1811,7 +1814,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
2016-04-30 08:04:12 +08:00
|
|
|
// CraftBukkit start
|
|
|
|
@Deprecated
|
|
|
|
public static MinecraftServer getServer() {
|
|
|
|
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
|
|
|
+ return SERVER;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2016-06-10 10:43:32 +08:00
|
|
|
}
|
2016-04-30 08:04:12 +08:00
|
|
|
--
|
2018-07-19 12:42:43 +08:00
|
|
|
2.18.0
|
2016-04-30 08:04:12 +08:00
|
|
|
|