filled method in LocationSerializer
This commit is contained in:
parent
f7a86b3c6f
commit
b43ffd17df
@ -2,10 +2,6 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<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="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">
|
<classpathentry kind="lib" path="/Volumes/Data HD/Users/tobi/Code/bukkit-1.2.5-R1.1.jar"/>
|
||||||
<attributes>
|
|
||||||
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -93,14 +93,14 @@ public abstract class BaseGate
|
|||||||
if (!isHidden) {
|
if (!isHidden) {
|
||||||
fillGate();
|
fillGate();
|
||||||
}
|
}
|
||||||
|
|
||||||
validate();
|
|
||||||
}
|
}
|
||||||
else if (isOpen == false && this.isOpen == true) {
|
else if (isOpen == false && this.isOpen == true) {
|
||||||
emptyGate();
|
emptyGate();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isOpen = isOpen;
|
this.isOpen = isOpen;
|
||||||
|
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public abstract class BaseGate
|
|||||||
protected void emptyGate()
|
protected void emptyGate()
|
||||||
{
|
{
|
||||||
for (Location l : gateBlockLocations) {
|
for (Location l : gateBlockLocations) {
|
||||||
if (l.getBlock().getType() == Material.PORTAL) {
|
if (l != null && l.getBlock().getType() == Material.PORTAL) {
|
||||||
l.getBlock().setType(Material.AIR);
|
l.getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class PluginPlayerListener implements Listener
|
|||||||
// Check if the gate is open and useable
|
// Check if the gate is open and useable
|
||||||
World gateWorld = gate.getLocation().getWorld();
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,58 @@
|
|||||||
package org.mcteam.ancientgates.util;
|
package org.mcteam.ancientgates.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
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
|
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)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user