1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-03 03:32:42 +02:00

Fix StoredLocation

This commit is contained in:
snowleo
2012-07-22 13:11:00 +02:00
parent a181e6d7b2
commit b76f5c71a3

View File

@@ -1,16 +1,14 @@
package net.ess3.storage; package net.ess3.storage;
import net.ess3.api.server.World;
import net.ess3.api.server.Location;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.UUID; import net.ess3.api.server.Location;
import net.ess3.api.server.World;
public class StoredLocation public class StoredLocation
{ {
private WeakReference<Location> location; private WeakReference<Location> location;
private final String worldname; private final String worldname;
private UUID worldUID = null;
private final double x; private final double x;
private final double y; private final double y;
private final double z; private final double z;
@@ -21,7 +19,6 @@ public class StoredLocation
{ {
location = new WeakReference<Location>(loc); location = new WeakReference<Location>(loc);
worldname = loc.getWorld().getName(); worldname = loc.getWorld().getName();
worldUID = loc.getWorld().getUID();
x = loc.getX(); x = loc.getX();
y = loc.getY(); y = loc.getY();
z = loc.getZ(); z = loc.getZ();
@@ -55,20 +52,7 @@ public class StoredLocation
Location loc = location == null ? null : location.get(); Location loc = location == null ? null : location.get();
if (loc == null) if (loc == null)
{ {
World world = null; loc = Location.create(worldname, getX(), getY(), getZ(), getYaw(), getPitch());
if (worldUID != null)
{
world = Bukkit.getWorld(worldUID);
}
if (world == null)
{
world = Bukkit.getWorld(worldname);
}
if (world == null)
{
throw new WorldNotLoadedException(worldname);
}
loc = Location.create(world, getX(), getY(), getZ(), getYaw(), getPitch());
location = new WeakReference<Location>(loc); location = new WeakReference<Location>(loc);
} }
return loc; return loc;