diff --git a/core/src/main/java/mc/core/WarpPosition.java b/core/src/main/java/mc/core/WarpPosition.java index 6e1aacf..4a0e501 100644 --- a/core/src/main/java/mc/core/WarpPosition.java +++ b/core/src/main/java/mc/core/WarpPosition.java @@ -1,14 +1,90 @@ package mc.core; -import lombok.AllArgsConstructor; -import lombok.Data; +import mc.core.player.ILook; import mc.core.player.Look; +import mc.core.world.World; import java.io.Serializable; +import java.util.Objects; -@Data -@AllArgsConstructor -public class WarpPosition implements Serializable { - private Location location; - private Look look; +public class WarpPosition extends Location implements Serializable, ILook { + private ILook look; + + public WarpPosition(double x, double y, double z, World world) { + super(x, y, z, world); + } + + public WarpPosition(double x, double y, double z, float yaw, float pitch, World world) { + super(x, y, z, world); + this.look = new Look(yaw, pitch); + } + + public WarpPosition(double x, double y, double z) { + super(x, y, z); + } + + public WarpPosition(double x, double y, double z, float yaw, float pitch) { + super(x, y, z); + this.look = new Look(yaw, pitch); + } + + public WarpPosition(long compactValue) { + super(compactValue); + } + + public WarpPosition(Location location) { + super(location.getX(), location.getY(), location.getZ()); + } + + public WarpPosition(Location location, Look look) { + super(location.getX(), location.getY(), location.getZ()); + this.look = look; + } + + public WarpPosition(long compactValue, World world) { + super(compactValue, world); + } + + @Override + public void set(Look look) { + this.look = look; + } + + @Override + public float getYaw() { + return this.look.getYaw(); + } + + @Override + public void setYaw(float yaw) { + this.look.setYaw(yaw); + } + + @Override + public float getPitch() { + return this.look.getPitch(); + } + + @Override + public void setPitch(float pitch) { + this.look.setPitch(pitch); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + WarpPosition that = (WarpPosition) o; + return Objects.equals(look, that.look); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), look); + } + + public boolean hasLook() { + return look != null; + } } diff --git a/core/src/main/java/mc/core/player/ILook.java b/core/src/main/java/mc/core/player/ILook.java new file mode 100644 index 0000000..fdebd51 --- /dev/null +++ b/core/src/main/java/mc/core/player/ILook.java @@ -0,0 +1,15 @@ +package mc.core.player; + +import java.io.Serializable; + +public interface ILook extends Serializable { + void set(Look look); + + float getYaw(); + + float getPitch(); + + void setYaw(float yaw); + + void setPitch(float pitch); +} diff --git a/core/src/main/java/mc/core/player/Look.java b/core/src/main/java/mc/core/player/Look.java index 1c0f7f4..f15f6f7 100644 --- a/core/src/main/java/mc/core/player/Look.java +++ b/core/src/main/java/mc/core/player/Look.java @@ -7,13 +7,12 @@ package mc.core.player; import lombok.AllArgsConstructor; import lombok.Data; -import java.io.Serializable; - @Data @AllArgsConstructor -public class Look implements Serializable{ +public class Look implements ILook { private float yaw, pitch; + @Override public void set(Look look) { this.yaw = look.yaw; this.pitch = look.pitch;