From eb19e4e8dc33d72cc940081dde7771bb1d900d77 Mon Sep 17 00:00:00 2001 From: Warren Loo Date: Wed, 13 Jul 2011 01:16:59 -0400 Subject: [PATCH] Fixed uuid code that was prematurely pushed. --- .../java/net/minecraft/server/Entity.java | 32 ++++++++++--------- .../net/minecraft/server/IDataManager.java | 4 +-- .../minecraft/server/PlayerNBTManager.java | 20 +++++++----- src/main/java/net/minecraft/server/World.java | 4 ++- .../java/net/minecraft/server/WorldMap.java | 3 +- 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 b94d3f1fd1..1c8a031e32 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 (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()); } - if(bworld == null && this instanceof EntityPlayer) { - 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()); // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/IDataManager.java b/src/main/java/net/minecraft/server/IDataManager.java index 643a1e1a3a..dc72594152 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 99b89fc29f..df762836e2 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 65900c518a..77bffbebf0 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 6f2eff71be..72a01cd3d8 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;