filled method in LocationSerializer
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user