filled method in LocationSerializer

This commit is contained in:
Tobias Ottenweller 2012-05-15 22:19:18 +02:00
parent f7a86b3c6f
commit b43ffd17df
4 changed files with 46 additions and 11 deletions

View File

@ -2,10 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="/Volumes/Data HD/Users/tobi/Code/bukkit-1.1-R5-20120224.051137-12.jar" sourcepath="/Users/tobi/Desktop/Bukkit">
<attributes>
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Volumes/Data HD/Users/tobi/Code/bukkit-1.2.5-R1.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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<String, Object> serializeLocation(Location l)
{
return null;
Map<String, Object> serializedLocation = new HashMap<String, Object>();
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<String, Object> 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);
}
}