3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 04:50:06 +01:00

Fixed uuid code that was prematurely pushed.

Dieser Commit ist enthalten in:
Warren Loo 2011-07-13 01:16:59 -04:00
Ursprung 9e49127c7d
Commit eb19e4e8dc
5 geänderte Dateien mit 36 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -980,24 +980,26 @@ public abstract class Entity {
// CraftBukkit end // CraftBukkit end
// CraftBukkit start - reset world // CraftBukkit start - reset world
org.bukkit.Server server = Bukkit.getServer(); if (this instanceof EntityPlayer) {
org.bukkit.World bworld = null; org.bukkit.Server server = Bukkit.getServer();
org.bukkit.World bworld = null;
// TODO: Remove World related checks, replaced with WorldUID. // TODO: Remove World related checks, replaced with WorldUID.
String worldName = nbttagcompound.getString("World"); String worldName = nbttagcompound.getString("World");
if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
bworld = server.getWorld(uid); bworld = server.getWorld(uid);
} else { } else {
bworld = server.getWorld(worldName); 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 // CraftBukkit end
} }

Datei anzeigen

@ -2,7 +2,7 @@ package net.minecraft.server;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID; // CraftBukkit
public interface IDataManager { public interface IDataManager {
@ -22,5 +22,5 @@ public interface IDataManager {
File b(String s); File b(String s);
UUID getUUID(); UUID getUUID(); // CraftBukkit
} }

Datei anzeigen

@ -9,9 +9,10 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.UUID; // CraftBukkit
public class PlayerNBTManager implements PlayerFileData, IDataManager { public class PlayerNBTManager implements PlayerFileData, IDataManager {
private static final Logger a = Logger.getLogger("Minecraft"); 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 c;
private final File d; private final File d;
private final long e = System.currentTimeMillis(); private final long e = System.currentTimeMillis();
private UUID uuid = null; // CraftBukkit
public PlayerNBTManager(File file1, String s, boolean flag) { public PlayerNBTManager(File file1, String s, boolean flag) {
this.b = new File(file1, s); this.b = new File(file1, s);
@ -223,20 +225,22 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager {
// CraftBukkit start // CraftBukkit start
public UUID getUUID() { public UUID getUUID() {
if (uuid != null) return uuid;
try { try {
File file1 = new File(this.b, "uid.dat"); File file1 = new File(this.b, "uid.dat");
UUID id; if (!file1.exists()) {
if(!file1.exists()) {
DataOutputStream dos = new DataOutputStream(new FileOutputStream(file1)); DataOutputStream dos = new DataOutputStream(new FileOutputStream(file1));
id = UUID.randomUUID(); uuid = UUID.randomUUID();
dos.writeLong(id.getMostSignificantBits()); dos.writeLong(uuid.getMostSignificantBits());
dos.writeLong(id.getLeastSignificantBits()); dos.writeLong(uuid.getLeastSignificantBits());
dos.close();
} }
else { else {
DataInputStream dis = new DataInputStream(new FileInputStream(file1)); 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) { catch (IOException ex) {
return null; return null;

Datei anzeigen

@ -8,9 +8,10 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID;
// CraftBukkit start // CraftBukkit start
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@ -2415,4 +2416,5 @@ public class World implements IBlockAccess {
public UUID getUUID() { public UUID getUUID() {
return this.w.getUUID(); return this.w.getUUID();
} }
// CraftBukkit end
} }

Datei anzeigen

@ -4,9 +4,10 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
// CraftBukkit start // CraftBukkit start
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;