package de.codebucket.witchmania.util;
import org.bukkit.Bukkit;
import org.bukkit.Location;
public class GameLocation
{
private String world;
private Double x;
private Double y;
private Double z;
private Float yaw;
private Float pitch;
private LocationType type;
public GameLocation(String world, Double x, Double y, Double z)
{
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.type = LocationType.ENTITY;
}
public GameLocation(String world, Double x, Double y, Double z, Float yaw, Float pitch)
{
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
this.type = LocationType.PLAYER;
}
public String getWorld()
{
return world;
}
public void setWorld(String world)
{
this.world = world;
}
public Double getX()
{
return x;
}
public void setX(Double x)
{
this.x = x;
}
public Double getY()
{
return y;
}
public void setY(Double y)
{
this.y = y;
}
public Double getZ()
{
return z;
}
public void setZ(Double z)
{
this.z = z;
}
public Float getYaw()
{
return yaw;
}
public void setYaw(Float yaw)
{
this.yaw = yaw;
}
public Float getPitch()
{
return pitch;
}
public void setPitch(Float pitch)
{
this.pitch = pitch;
}
public Location serialize()
{
if(type == LocationType.ENTITY)
{
return new Location(Bukkit.getWorld(world), x, y, z);
new Loc
}
else if(type == LocationType.PLAYER)
{
return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
}
return null;
}
public void deserialize(Location location)
{
this.world = location.getWorld().getName();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
public GameLocation clone()
{
if(type == LocationType.ENTITY)
{
return new GameLocation(world, x, y, z);
}
else if(type == LocationType.PLAYER)
{
return new GameLocation(world, x, y, z, yaw, pitch);
}
return null;
}
public enum LocationType
{
ENTITY,
PLAYER;
}
}