Persist yaw and pitch at location and exit of gates.

This commit is contained in:
Tobias Ottenweller 2013-02-09 21:02:22 +01:00
parent 56d0b8bf1c
commit 8e7b180fbe

View File

@ -61,12 +61,16 @@ public class Gate extends BaseGate implements ConfigurationSerializable
/* /*
* INTERFACE: ConfigurationSerializable * INTERFACE: ConfigurationSerializable
*/ */
static String idKey = "id"; static protected String idKey = "id";
static String locationKey = "location"; static protected String locationKey = "location";
static String gateBlocksKey = "gateBlocks"; static protected String gateBlocksKey = "gateBlocks";
static String exitKey = "exit"; static protected String exitKey = "exit";
static String isHiddenKey = "hidden"; static protected String isHiddenKey = "hidden";
static String isOpenKey = "open"; 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") @SuppressWarnings("unchecked")
@ -80,6 +84,14 @@ public class Gate extends BaseGate implements ConfigurationSerializable
location = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(locationKey)); location = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(locationKey));
exit = LocationSerializer.deserializeLocation((Map<String, Object>) map.get(exitKey)); exit = LocationSerializer.deserializeLocation((Map<String, Object>) 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<Location>(); gateBlockLocations = new HashSet<Location>();
List<Map<String, Object>> serializedGateBlocks = (List<Map<String, Object>>)map.get(gateBlocksKey); List<Map<String, Object>> serializedGateBlocks = (List<Map<String, Object>>)map.get(gateBlocksKey);
@ -116,6 +128,14 @@ public class Gate extends BaseGate implements ConfigurationSerializable
retVal.put(isHiddenKey, isHidden); retVal.put(isHiddenKey, isHidden);
retVal.put(isOpenKey, isOpen); 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<Map<String, Object>> serializedGateBlocks = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> serializedGateBlocks = new ArrayList<Map<String, Object>>();
for (Location l : gateBlockLocations) { for (Location l : gateBlockLocations) {