aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0616-Implement-Keyed-on-World.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0616-Implement-Keyed-on-World.patch')
-rw-r--r--patches/server/0616-Implement-Keyed-on-World.patch51
1 files changed, 51 insertions, 0 deletions
diff --git a/patches/server/0616-Implement-Keyed-on-World.patch b/patches/server/0616-Implement-Keyed-on-World.patch
new file mode 100644
index 0000000000..896d602707
--- /dev/null
+++ b/patches/server/0616-Implement-Keyed-on-World.patch
@@ -0,0 +1,51 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Wed, 6 Jan 2021 00:34:04 -0800
+Subject: [PATCH] Implement Keyed on World
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+index 93faeef65f846fdb472204709093ebcdba790dce..28fb73ffd683a45b1d6be4b55116e861d0c2973c 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -1257,7 +1257,7 @@ public final class CraftServer implements Server {
+ } else if (name.equals(levelName + "_the_end")) {
+ worldKey = net.minecraft.world.level.Level.END;
+ } else {
+- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH)));
++ worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
+ }
+
+ ServerLevel internal = (ServerLevel) new ServerLevel(this.console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, this.getServer().progressListenerFactory.create(11),
+@@ -1349,6 +1349,15 @@ public final class CraftServer implements Server {
+ return null;
+ }
+
++ // Paper start
++ @Override
++ public World getWorld(NamespacedKey worldKey) {
++ ServerLevel worldServer = console.getLevel(ResourceKey.create(Registry.DIMENSION_REGISTRY, CraftNamespacedKey.toMinecraft(worldKey)));
++ if (worldServer == null) return null;
++ return worldServer.getWorld();
++ }
++ // Paper end
++
+ public void addWorld(World world) {
+ // Check if a World already exists with the UID.
+ if (this.getWorld(world.getUID()) != null) {
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+index dc182b4ff748661b04e15578ac9e0e1a8062f2c8..96d3f8a312ebe786fe21198d12d9f3294a86d865 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+@@ -1959,6 +1959,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {
+ return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
+ }, net.minecraft.server.MinecraftServer.getServer());
+ }
++
++ @Override
++ public org.bukkit.NamespacedKey getKey() {
++ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().location());
++ }
+ // Paper end
+
+ // Spigot start