From e9ec81cf044bfe93933196faa3ea92bbb8b0e784 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Thu, 24 Jan 2013 20:48:36 +0100 Subject: [PATCH] Allow Integer and Double as valid numbers read from YAML. --- .../gates/util/LocationSerializer.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/de/craftinc/gates/util/LocationSerializer.java b/src/de/craftinc/gates/util/LocationSerializer.java index cf46581..36ba1a2 100644 --- a/src/de/craftinc/gates/util/LocationSerializer.java +++ b/src/de/craftinc/gates/util/LocationSerializer.java @@ -48,9 +48,30 @@ public class LocationSerializer public static Location deserializeLocation(Map map) throws Exception { World w = getWorld((String)map.get(worldKey)); - double x = (Double) map.get(xKey); - double y = (Double) map.get(yKey); - double z = (Double) map.get(zKey); + + + // verbose loading of coordinates (they might be Double or Integer) + Object objX = map.get(xKey); + Object objY = map.get(yKey); + Object objZ = map.get(zKey); + + double x,y,z; + + if (objX instanceof Integer) + x = (double)(Integer)objX; + else + x = (Double)objX; + + if (objY instanceof Integer) + y = (double)(Integer)objY; + else + y = (Double)objY; + + if (objZ instanceof Integer) + z = (double)(Integer)objZ; + else + z = (Double)objZ; + return new Location(w, x, y, z); }