diff --git a/.classpath b/.classpath
index ab57551..0315c37 100644
--- a/.classpath
+++ b/.classpath
@@ -2,10 +2,6 @@
-
-
-
-
-
+
diff --git a/src/org/mcteam/ancientgates/BaseGate.java b/src/org/mcteam/ancientgates/BaseGate.java
index 83239a6..ee51f90 100644
--- a/src/org/mcteam/ancientgates/BaseGate.java
+++ b/src/org/mcteam/ancientgates/BaseGate.java
@@ -93,14 +93,14 @@ public abstract class BaseGate
if (!isHidden) {
fillGate();
}
-
- validate();
}
else if (isOpen == false && this.isOpen == true) {
emptyGate();
}
this.isOpen = isOpen;
+
+ validate();
}
@@ -131,7 +131,7 @@ public abstract class BaseGate
protected void emptyGate()
{
for (Location l : gateBlockLocations) {
- if (l.getBlock().getType() == Material.PORTAL) {
+ if (l != null && l.getBlock().getType() == Material.PORTAL) {
l.getBlock().setType(Material.AIR);
}
}
diff --git a/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java b/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java
index 860406a..eb3d5bb 100644
--- a/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java
+++ b/src/org/mcteam/ancientgates/listeners/PluginPlayerListener.java
@@ -45,7 +45,7 @@ public class PluginPlayerListener implements Listener
// Check if the gate is open and useable
World gateWorld = gate.getLocation().getWorld();
- if (gate.getLocation() == null || gate.getExit() == null || gate.isOpen() == false || !gateWorld.equals(playerWorld)) {
+ if (gate.isOpen() == false || !gateWorld.equals(playerWorld)) {
continue;
}
diff --git a/src/org/mcteam/ancientgates/util/LocationSerializer.java b/src/org/mcteam/ancientgates/util/LocationSerializer.java
index 9a6eb2d..85447d1 100644
--- a/src/org/mcteam/ancientgates/util/LocationSerializer.java
+++ b/src/org/mcteam/ancientgates/util/LocationSerializer.java
@@ -1,19 +1,58 @@
package org.mcteam.ancientgates.util;
+import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.World.Environment;
+import org.bukkit.WorldCreator;
+import org.mcteam.ancientgates.Plugin;
+
+/**
+ * NOTE: We do not care about yaw and pitch for gate locations. So we won't serialize them.
+ */
public class LocationSerializer
{
+ protected static String worldKey = "world";
+ protected static String xKey = "x";
+ protected static String yKey = "y";
+ protected static String zKey = "z";
+
+
+ protected static World getWorld(String name)
+ {
+ World world = Plugin.instance.getServer().getWorld(name);
+
+ if (world == null) {
+ world = Plugin.instance.getServer().createWorld(new WorldCreator(name).environment(Environment.NORMAL));
+ }
+
+ return world;
+ }
+
+
public static Map serializeLocation(Location l)
{
- return null;
+ Map serializedLocation = new HashMap();
+
+ serializedLocation.put(worldKey, l.getWorld().getName());
+ serializedLocation.put(xKey, l.getX());
+ serializedLocation.put(yKey, l.getY());
+ serializedLocation.put(zKey, l.getZ());
+
+ return serializedLocation;
}
public static Location deserializeLocation(Map map)
{
- return null;
+ 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);
+
+ return new Location(w, x, y, z);
}
}