New API methods, refactor position object to use static creators

This commit is contained in:
William278 committed 2023-03-22 19:55:59 +00:00
1 parent 42adc13425
commit 6b8c515b61
42 files changed
+587 -232

No files matched your search

@@ -1,5 +1,6 @@
package net.william278.huskhomes.position;
import com.google.gson.annotations.Expose;
import net.william278.huskhomes.teleport.Target;
import org.jetbrains.annotations.NotNull;
@@ -8,15 +9,15 @@ import org.jetbrains.annotations.NotNull;
*/
public class Position extends Location implements Target {
@Expose
private String server;
public Position(double x, double y, double z, float yaw, float pitch,
@NotNull World world, @NotNull String server) {
protected Position(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server) {
super(x, y, z, yaw, pitch, world);
this.setServer(server);
}
public Position(@NotNull Location location, @NotNull String server) {
protected Position(@NotNull Location location, @NotNull String server) {
super(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), location.getWorld());
this.setServer(server);
}
@@ -25,6 +26,21 @@ public class Position extends Location implements Target {
private Position() {
}
@NotNull
public static Position at(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server) {
return new Position(x, y, z, yaw, pitch, world, server);
}
@NotNull
public static Position at(double x, double y, double z, @NotNull World world, @NotNull String server) {
return Position.at(x, y, z, 0, 0, world, server);
}
@NotNull
public static Position at(@NotNull Location location, @NotNull String server) {
return new Position(location, server);
}
@Override
public void update(@NotNull Position newPosition) {
super.update(newPosition);