From 28fcbec3b1662f42a6a457869bdb43e9b246e615 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 19 Jan 2012 16:09:24 +0000 Subject: [PATCH] Prevent re-use of internal world dimension IDs. This fixes BUKKIT-448. Thanks to snowleo for the PR. --- src/main/java/org/bukkit/craftbukkit/CraftServer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index c4846097f7..f3ed843b22 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -540,6 +540,16 @@ public final class CraftServer implements Server { } int dimension = 10 + console.worlds.size(); + boolean used = false; + do { + for (WorldServer server : console.worlds) { + used = server.dimension == dimension; + if (used) { + dimension++; + break; + } + } + } while(used); boolean hardcore = false; WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), getDefaultGameMode().getValue(), true, hardcore, type), creator.environment(), generator);