From ed9aa2fa0942b47b0288d55c312a3021d48ba6a4 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Thu, 27 Dec 2012 11:44:35 +0100 Subject: [PATCH] Let location serialization throw exceptions if a given world does not exist anymore. --- .../craftinc/gates/util/LocationSerializer.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/de/craftinc/gates/util/LocationSerializer.java b/src/de/craftinc/gates/util/LocationSerializer.java index 0fa0dd8..cf46581 100644 --- a/src/de/craftinc/gates/util/LocationSerializer.java +++ b/src/de/craftinc/gates/util/LocationSerializer.java @@ -5,8 +5,6 @@ import java.util.Map; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.WorldCreator; import de.craftinc.gates.Plugin; @@ -20,17 +18,14 @@ public class LocationSerializer protected static String xKey = "x"; protected static String yKey = "y"; protected static String zKey = "z"; - - protected static World getWorld(String name) + + protected static World getWorld(String name) throws Exception { World world = Plugin.instance.getServer().getWorld(name); - // TODO: Creating a world silently in the background is not a good thing I think. No one expects a Gate - // Plugin to do that. It would be better to handle gates which point to non-existing worlds safely (not - // teleporting at all) if (world == null) { - world = Plugin.instance.getServer().createWorld(new WorldCreator(name).environment(Environment.NORMAL)); + throw new Exception("World '" + name + "' does not exists anymore! Cannot get instance!"); } return world; @@ -49,8 +44,8 @@ public class LocationSerializer return serializedLocation; } - - public static Location deserializeLocation(Map map) + + public static Location deserializeLocation(Map map) throws Exception { World w = getWorld((String)map.get(worldKey)); double x = (Double) map.get(xKey);