diff options
author | Rigby <rigby@onarandombox.com> | 2011-07-26 21:04:18 +0100 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2011-08-05 16:02:02 -0400 |
commit | bb89847632b02d683497193b700a0698768b508e (patch) | |
tree | e4eb46c949f5c05fea89fdc97b6515c0713ca984 /src/main/java/net/minecraft | |
parent | ae43b837b026f2afec55558f83b2a854857270e9 (diff) | |
download | craftbukkit-bb89847632b02d683497193b700a0698768b508e.tar craftbukkit-bb89847632b02d683497193b700a0698768b508e.tar.gz craftbukkit-bb89847632b02d683497193b700a0698768b508e.tar.lz craftbukkit-bb89847632b02d683497193b700a0698768b508e.tar.xz craftbukkit-bb89847632b02d683497193b700a0698768b508e.zip |
Map handling improvements.
Fixed an NPE occurring under certain circumstances.
Made it possible for maps to exist without having to associate them with a world.
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldMap.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index 72a01cd3..ab20cf9b 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -45,15 +45,16 @@ public class WorldMap extends WorldMapBase { if (least != 0L && most != 0L) { this.uniqueId = new UUID(most, least); - } - CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId); - // 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; + + CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId); + // 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; + } } } @@ -110,8 +111,12 @@ public class WorldMap extends WorldMapBase { } } } - nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); - nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits()); + /* Perform a second check to see if a matching world was found, this is a necessary + change incase Maps are forcefully unlinked from a World and lack a UID.*/ + if (this.uniqueId != null) { + nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); + nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits()); + } } // CraftBukkit end nbttagcompound.a("dimension", this.map); |