Fixed uuid code that was prematurely pushed.

This commit is contained in:
Warren Loo 2011-07-13 01:16:59 -04:00
parent 9e49127c7d
commit eb19e4e8dc
5 changed files with 36 additions and 27 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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;

View File

@ -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
}

View File

@ -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;