diff --git a/Essentials/src/main/java/com/earth2me/essentials/Jails.java b/Essentials/src/main/java/com/earth2me/essentials/Jails.java index 0942ed455..c40c9959e 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Jails.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Jails.java @@ -63,7 +63,7 @@ public class Jails implements net.ess3.api.IJails { if (worldId == null || worldId.isEmpty()) { continue; } - jails.put(entry.getKey().toLowerCase(Locale.ENGLISH), new LazyLocation(worldId, jailNode.node("x").getDouble(), jailNode.node("y").getDouble(), + jails.put(entry.getKey().toLowerCase(Locale.ENGLISH), new LazyLocation(worldId, jailNode.node("world-name").getString(""), jailNode.node("x").getDouble(), jailNode.node("y").getDouble(), jailNode.node("z").getDouble(), jailNode.node("yaw").getFloat(), jailNode.node("pitch").getFloat())); } checkRegister(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/config/entities/LazyLocation.java b/Essentials/src/main/java/com/earth2me/essentials/config/entities/LazyLocation.java index a99a3fa2d..6fa5e29d6 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/config/entities/LazyLocation.java +++ b/Essentials/src/main/java/com/earth2me/essentials/config/entities/LazyLocation.java @@ -10,15 +10,17 @@ import java.util.UUID; * Represents a Location but doesn't parse the location until it is requested via {@link LazyLocation#location()}. */ public class LazyLocation { - private final String world; + private String world; + private String worldName; private final double x; private final double y; private final double z; private final float yaw; private final float pitch; - public LazyLocation(String world, double x, double y, double z, float yaw, float pitch) { - this.world = world; + public LazyLocation(String worldId, String worldName, double x, double y, double z, float yaw, float pitch) { + this.world = worldId; + this.worldName = worldName; this.x = x; this.y = y; this.z = z; @@ -30,6 +32,10 @@ public class LazyLocation { return world; } + public String worldName() { + return worldName; + } + public double x() { return x; } @@ -67,14 +73,22 @@ public class LazyLocation { world = Bukkit.getWorld(this.world); } + if (world == null && this.worldName != null && !this.worldName.isEmpty()) { + world = Bukkit.getWorld(this.worldName); + } + if (world == null) { return null; } + this.world = world.getUID().toString(); + this.worldName = world.getName(); + return new Location(world, x, y, z, yaw, pitch); } public static LazyLocation fromLocation(final Location location) { - return new LazyLocation(location.getWorld().getUID().toString(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + //noinspection ConstantConditions + return new LazyLocation(location.getWorld().getUID().toString(), location.getWorld().getName(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } } diff --git a/Essentials/src/main/java/com/earth2me/essentials/config/serializers/LocationTypeSerializer.java b/Essentials/src/main/java/com/earth2me/essentials/config/serializers/LocationTypeSerializer.java index a50cdc12f..9e563e54b 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/config/serializers/LocationTypeSerializer.java +++ b/Essentials/src/main/java/com/earth2me/essentials/config/serializers/LocationTypeSerializer.java @@ -21,6 +21,7 @@ public class LocationTypeSerializer implements TypeSerializer { return new LazyLocation( worldValue, + node.node("world-name").getString(""), node.node("x").getDouble(), node.node("y").getDouble(), node.node("z").getDouble(), @@ -36,6 +37,7 @@ public class LocationTypeSerializer implements TypeSerializer { } node.node("world").set(String.class, value.world()); + node.node("world-name").set(String.class, value.worldName()); node.node("x").set(Double.class, value.x()); node.node("y").set(Double.class, value.y()); node.node("z").set(Double.class, value.z());