diff options
author | Rigby <rigby@onarandombox.com> | 2011-07-03 07:42:26 +0100 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-07-07 14:40:27 -0400 |
commit | 4cab8635db4902e0c59cc318f81acf7b5e0b0ce0 (patch) | |
tree | 036b1c19983298fb52df64502b447b8fc7dbcb1d /src/main/java/net | |
parent | 9ced39421f6a4009ffbf6eac4167af68fa64f842 (diff) | |
download | craftbukkit-4cab8635db4902e0c59cc318f81acf7b5e0b0ce0.tar craftbukkit-4cab8635db4902e0c59cc318f81acf7b5e0b0ce0.tar.gz craftbukkit-4cab8635db4902e0c59cc318f81acf7b5e0b0ce0.tar.lz craftbukkit-4cab8635db4902e0c59cc318f81acf7b5e0b0ce0.tar.xz craftbukkit-4cab8635db4902e0c59cc318f81acf7b5e0b0ce0.zip |
Made maps support MultiWorld worlds.
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldMap.java | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index 28388106..92eac2e7 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -5,6 +5,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +// CraftBukkit end + public class WorldMap extends WorldMapBase { public int b; @@ -17,12 +23,35 @@ public class WorldMap extends WorldMapBase { private Map j = new HashMap(); public List i = new ArrayList(); + // CraftBukkit start + private CraftServer server; + private long worldUID = 0L; + // CraftBukkit end + public WorldMap(String s) { super(s); + server = (CraftServer) Bukkit.getServer(); // CraftBukkit } public void a(NBTTagCompound nbttagcompound) { - this.map = nbttagcompound.c("dimension"); + // CraftBukkit start + byte dimension = nbttagcompound.c("dimension"); + + if (dimension >= 10) { + this.worldUID = nbttagcompound.getLong("WorldUID"); + CraftWorld world = (CraftWorld) server.getWorld(this.worldUID); + // Check if the stored world details are correct. + if (world == null) { + /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. + This is to prevent them being corrupted with the wrong map data. */ + dimension = 127; + } else { + dimension = (byte) world.getHandle().dimension; + } + } + + this.map = dimension; + // CraftBukkit end this.b = nbttagcompound.e("xCenter"); this.c = nbttagcompound.e("zCenter"); this.e = nbttagcompound.c("scale"); @@ -63,6 +92,20 @@ public class WorldMap extends WorldMapBase { } public void b(NBTTagCompound nbttagcompound) { + // CraftBukkit start + if (this.map >= 10) { + if (this.worldUID == 0L) { + for (org.bukkit.World world : server.getWorlds()) { + CraftWorld cWorld = (CraftWorld) world; + if (cWorld.getHandle().dimension == this.map) { + this.worldUID = cWorld.getUID(); + break; + } + } + } + nbttagcompound.setLong("WorldUID", this.worldUID); + } + // CraftBukkit end nbttagcompound.a("dimension", this.map); nbttagcompound.a("xCenter", this.b); nbttagcompound.a("zCenter", this.c); |