From 09ff776905a9378d5c0b45fbb0f58e5772bb7533 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Mon, 22 Apr 2019 19:51:14 +0100 Subject: [PATCH] don't NPE on dimensionmanager toString CraftBukkit uses vanillas DimensionManager, but does not actually register its own dimension types, etc, due to vanilla This causes issues because anything, e.g. command feedback, trying to print information about the world will often attempt to print out the dimension name, which ends up throwing an NPE due to the lack of a registered type, we work around this by just returning the world name, this is not super elegant, but is the only route that promises not to break stuff. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 982dce480..d18a530a4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -997,7 +997,14 @@ public final class CraftServer implements Server { } DimensionManager actualDimension = DimensionManager.a(creator.environment().getId()); - DimensionManager internalDimension = new DimensionManager(dimension, name, name, (w, manager) -> actualDimension.getWorldProvider(w), actualDimension.hasSkyLight()); + // Paper start - override toString + DimensionManager internalDimension = new DimensionManager(dimension, name, name, (w, manager) -> actualDimension.getWorldProvider(w), actualDimension.hasSkyLight()) { + @Override + public String toString() { + return name; + } + }; + // Paper end WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, sdm, worlddata, internalDimension, console.getMethodProfiler(), getServer().worldLoadListenerFactory.create(11), creator.environment(), generator); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { -- 2.21.0