From 8e7b180fbea799fb7a6ff9a7838b9b8f706f4c61 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sat, 9 Feb 2013 21:02:22 +0100 Subject: [PATCH] Persist yaw and pitch at location and exit of gates. --- src/de/craftinc/gates/Gate.java | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java index 97d41c2..de99344 100644 --- a/src/de/craftinc/gates/Gate.java +++ b/src/de/craftinc/gates/Gate.java @@ -61,12 +61,16 @@ public class Gate extends BaseGate implements ConfigurationSerializable /* * INTERFACE: ConfigurationSerializable */ - static String idKey = "id"; - static String locationKey = "location"; - static String gateBlocksKey = "gateBlocks"; - static String exitKey = "exit"; - static String isHiddenKey = "hidden"; - static String isOpenKey = "open"; + static protected String idKey = "id"; + static protected String locationKey = "location"; + static protected String gateBlocksKey = "gateBlocks"; + static protected String exitKey = "exit"; + static protected String isHiddenKey = "hidden"; + static protected String isOpenKey = "open"; + static protected String locationYawKey = "locationYaw"; + static protected String locationPitchKey = "locationPitch"; + static protected String exitYawKey = "exitYaw"; + static protected String exitPitchKey = "exitPitch"; @SuppressWarnings("unchecked") @@ -80,6 +84,14 @@ public class Gate extends BaseGate implements ConfigurationSerializable location = LocationSerializer.deserializeLocation((Map) map.get(locationKey)); exit = LocationSerializer.deserializeLocation((Map) map.get(exitKey)); + if (exit != null) { + exit.setPitch(((Double)map.get(exitPitchKey)).floatValue()); + exit.setYaw(((Double)map.get(exitYawKey)).floatValue()); + } + + location.setPitch(((Double)map.get(locationPitchKey)).floatValue()); + location.setYaw(((Double)map.get(locationYawKey)).floatValue()); + gateBlockLocations = new HashSet(); List> serializedGateBlocks = (List>)map.get(gateBlocksKey); @@ -116,6 +128,14 @@ public class Gate extends BaseGate implements ConfigurationSerializable retVal.put(isHiddenKey, isHidden); retVal.put(isOpenKey, isOpen); + if (exit != null) { + retVal.put(exitPitchKey, exit.getPitch()); + retVal.put(exitYawKey, exit.getYaw()); + } + + retVal.put(locationPitchKey, location.getPitch()); + retVal.put(locationYawKey, location.getYaw()); + List> serializedGateBlocks = new ArrayList>(); for (Location l : gateBlockLocations) {