mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Implements a World UID.
This commit is contained in:
parent
5515ce1ff6
commit
9ced39421f
@ -910,7 +910,7 @@ public abstract class Entity {
|
|||||||
nbttagcompound.a("Air", (short) this.airTicks);
|
nbttagcompound.a("Air", (short) this.airTicks);
|
||||||
nbttagcompound.a("OnGround", this.onGround);
|
nbttagcompound.a("OnGround", this.onGround);
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
nbttagcompound.setString("World", this.world.worldData.name);
|
nbttagcompound.setLong("WorldUID", this.world.worldData.getWorldUID());
|
||||||
nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
|
nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
|
||||||
nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
|
nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -982,17 +982,24 @@ public abstract class Entity {
|
|||||||
org.bukkit.Server server = Bukkit.getServer();
|
org.bukkit.Server server = Bukkit.getServer();
|
||||||
org.bukkit.World bworld = null;
|
org.bukkit.World bworld = null;
|
||||||
|
|
||||||
|
// TODO: Remove World related checks, replaced with WorldUID.
|
||||||
if (this instanceof EntityPlayer) {
|
if (this instanceof EntityPlayer) {
|
||||||
EntityPlayer entityPlayer = (EntityPlayer) this;
|
EntityPlayer entityPlayer = (EntityPlayer) this;
|
||||||
String worldName = nbttagcompound.getString("World");
|
String worldName = nbttagcompound.getString("World");
|
||||||
|
|
||||||
if (worldName == "") {
|
if (nbttagcompound.hasKey("WorldUID")) {
|
||||||
|
bworld = server.getWorld(nbttagcompound.getLong("WorldUID"));
|
||||||
|
} else if ("".equals(worldName)) {
|
||||||
bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld();
|
bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld();
|
||||||
} else {
|
} else {
|
||||||
bworld = server.getWorld(worldName);
|
bworld = server.getWorld(worldName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bworld = server.getWorld(nbttagcompound.getString("World"));
|
if (nbttagcompound.hasKey("WorldUID")) {
|
||||||
|
bworld = server.getWorld(nbttagcompound.getLong("WorldUID"));
|
||||||
|
} else {
|
||||||
|
bworld = server.getWorld(nbttagcompound.getString("World"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.spawnIn(bworld == null ? null : ((org.bukkit.craftbukkit.CraftWorld) bworld).getHandle());
|
this.spawnIn(bworld == null ? null : ((org.bukkit.craftbukkit.CraftWorld) bworld).getHandle());
|
||||||
|
@ -19,6 +19,7 @@ public class WorldData {
|
|||||||
private int m;
|
private int m;
|
||||||
private boolean n;
|
private boolean n;
|
||||||
private int o;
|
private int o;
|
||||||
|
private long worldUID; // CraftBukkit
|
||||||
|
|
||||||
public WorldData(NBTTagCompound nbttagcompound) {
|
public WorldData(NBTTagCompound nbttagcompound) {
|
||||||
this.a = nbttagcompound.getLong("RandomSeed");
|
this.a = nbttagcompound.getLong("RandomSeed");
|
||||||
@ -38,11 +39,20 @@ public class WorldData {
|
|||||||
this.h = nbttagcompound.k("Player");
|
this.h = nbttagcompound.k("Player");
|
||||||
this.i = this.h.e("Dimension");
|
this.i = this.h.e("Dimension");
|
||||||
}
|
}
|
||||||
|
// CraftBukkit start
|
||||||
|
if (nbttagcompound.hasKey("WorldUID")) {
|
||||||
|
this.worldUID = nbttagcompound.getLong("WorldUID");
|
||||||
|
} else {
|
||||||
|
this.worldUID = (System.nanoTime() << 20) + this.a;
|
||||||
|
nbttagcompound.setLong("WorldUID", this.worldUID);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldData(long i, String s) {
|
public WorldData(long i, String s) {
|
||||||
this.a = i;
|
this.a = i;
|
||||||
this.name = s;
|
this.name = s;
|
||||||
|
this.worldUID = (System.nanoTime() << 20) + this.a; // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldData(WorldData worlddata) {
|
public WorldData(WorldData worlddata) {
|
||||||
@ -105,6 +115,7 @@ public class WorldData {
|
|||||||
if (nbttagcompound1 != null) {
|
if (nbttagcompound1 != null) {
|
||||||
nbttagcompound.a("Player", nbttagcompound1);
|
nbttagcompound.a("Player", nbttagcompound1);
|
||||||
}
|
}
|
||||||
|
nbttagcompound.setLong("WorldUID", this.worldUID); // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSeed() {
|
public long getSeed() {
|
||||||
@ -192,4 +203,10 @@ public class WorldData {
|
|||||||
public void setWeatherDuration(int i) {
|
public void setWeatherDuration(int i) {
|
||||||
this.m = i;
|
this.m = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
public long getWorldUID() {
|
||||||
|
return this.worldUID;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -490,6 +490,16 @@ public final class CraftServer implements Server {
|
|||||||
return worlds.get(name.toLowerCase());
|
return worlds.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World getWorld(long uid) {
|
||||||
|
for (String worldName : worlds.keySet()) {
|
||||||
|
org.bukkit.World world = worlds.get(worldName);
|
||||||
|
if (world.getUID() == uid) {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void addWorld(World world) {
|
public void addWorld(World world) {
|
||||||
worlds.put(world.getName().toLowerCase(), world);
|
worlds.put(world.getName().toLowerCase(), world);
|
||||||
}
|
}
|
||||||
|
@ -395,10 +395,15 @@ public class CraftWorld implements World {
|
|||||||
return world.worldData.name;
|
return world.worldData.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return world.worldData.getSeed();
|
return world.worldData.getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getUID() {
|
||||||
|
return world.worldData.getWorldUID();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftWorld{name=" + getName() + '}';
|
return "CraftWorld{name=" + getName() + '}';
|
||||||
|
Loading…
Reference in New Issue
Block a user