diff options
author | Warren Loo <evilseph@gmail.com> | 2011-07-13 01:16:59 -0400 |
---|---|---|
committer | Warren Loo <evilseph@gmail.com> | 2011-07-13 02:19:56 -0400 |
commit | eb19e4e8dc33d72cc940081dde7771bb1d900d77 (patch) | |
tree | 462d1938aa4218af51f7fe7fec32e4868624e3a4 /src/main | |
parent | 9e49127c7d9f81f6932dc4a90a9397a26bbe869d (diff) | |
download | craftbukkit-eb19e4e8dc33d72cc940081dde7771bb1d900d77.tar craftbukkit-eb19e4e8dc33d72cc940081dde7771bb1d900d77.tar.gz craftbukkit-eb19e4e8dc33d72cc940081dde7771bb1d900d77.tar.lz craftbukkit-eb19e4e8dc33d72cc940081dde7771bb1d900d77.tar.xz craftbukkit-eb19e4e8dc33d72cc940081dde7771bb1d900d77.zip |
Fixed uuid code that was prematurely pushed.
Diffstat (limited to 'src/main')
5 files changed, 36 insertions, 27 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index b94d3f1f..1c8a031e 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -980,24 +980,26 @@ public abstract class Entity { // CraftBukkit end // CraftBukkit start - reset world - org.bukkit.Server server = Bukkit.getServer(); - org.bukkit.World bworld = null; + if (this instanceof EntityPlayer) { + org.bukkit.Server server = Bukkit.getServer(); + org.bukkit.World bworld = null; - // TODO: Remove World related checks, replaced with WorldUID. - String worldName = nbttagcompound.getString("World"); + // TODO: Remove World related checks, replaced with WorldUID. + String worldName = nbttagcompound.getString("World"); - if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { - UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); - bworld = server.getWorld(uid); - } else { - bworld = server.getWorld(worldName); - } - if(bworld == null && this instanceof EntityPlayer) { - EntityPlayer entityPlayer = (EntityPlayer) this; - bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld(); - } + if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { + UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); + bworld = server.getWorld(uid); + } else { + bworld = server.getWorld(worldName); + } + if (bworld == null) { + EntityPlayer entityPlayer = (EntityPlayer) this; + bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld(); + } - this.spawnIn(bworld == null ? null : ((org.bukkit.craftbukkit.CraftWorld) bworld).getHandle()); + this.spawnIn(bworld == null ? null : ((org.bukkit.craftbukkit.CraftWorld) bworld).getHandle()); + } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/IDataManager.java b/src/main/java/net/minecraft/server/IDataManager.java index 643a1e1a..dc725941 100644 --- a/src/main/java/net/minecraft/server/IDataManager.java +++ b/src/main/java/net/minecraft/server/IDataManager.java @@ -2,7 +2,7 @@ package net.minecraft.server; import java.io.File; import java.util.List; -import java.util.UUID; +import java.util.UUID; // CraftBukkit public interface IDataManager { @@ -22,5 +22,5 @@ public interface IDataManager { File b(String s); - UUID getUUID(); + UUID getUUID(); // CraftBukkit } diff --git a/src/main/java/net/minecraft/server/PlayerNBTManager.java b/src/main/java/net/minecraft/server/PlayerNBTManager.java index 99b89fc2..df762836 100644 --- a/src/main/java/net/minecraft/server/PlayerNBTManager.java +++ b/src/main/java/net/minecraft/server/PlayerNBTManager.java @@ -9,9 +9,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; -import java.util.UUID; import java.util.logging.Logger; +import java.util.UUID; // CraftBukkit + public class PlayerNBTManager implements PlayerFileData, IDataManager { private static final Logger a = Logger.getLogger("Minecraft"); @@ -19,6 +20,7 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { private final File c; private final File d; private final long e = System.currentTimeMillis(); + private UUID uuid = null; // CraftBukkit public PlayerNBTManager(File file1, String s, boolean flag) { this.b = new File(file1, s); @@ -223,20 +225,22 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { // CraftBukkit start public UUID getUUID() { + if (uuid != null) return uuid; try { File file1 = new File(this.b, "uid.dat"); - UUID id; - if(!file1.exists()) { + if (!file1.exists()) { DataOutputStream dos = new DataOutputStream(new FileOutputStream(file1)); - id = UUID.randomUUID(); - dos.writeLong(id.getMostSignificantBits()); - dos.writeLong(id.getLeastSignificantBits()); + uuid = UUID.randomUUID(); + dos.writeLong(uuid.getMostSignificantBits()); + dos.writeLong(uuid.getLeastSignificantBits()); + dos.close(); } else { DataInputStream dis = new DataInputStream(new FileInputStream(file1)); - id = new UUID(dis.readLong(), dis.readLong()); + uuid = new UUID(dis.readLong(), dis.readLong()); + dis.close(); } - return id; + return uuid; } catch (IOException ex) { return null; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 65900c51..77bffbeb 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -8,9 +8,10 @@ import java.util.List; import java.util.Random; import java.util.Set; import java.util.TreeSet; -import java.util.UUID; // CraftBukkit start +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.generator.ChunkGenerator; @@ -2415,4 +2416,5 @@ public class World implements IBlockAccess { public UUID getUUID() { return this.w.getUUID(); } + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index 6f2eff71..72a01cd3 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -4,9 +4,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; // CraftBukkit start +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; |