mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 06:28:49 +00:00
Database design, start callback-based implementation planning
This commit is contained in:
1 parent
0446db39c5
commit
8e7d5e74a0
17 files changed
+672
-92
No files matched your search
@@ -3,6 +3,8 @@ package net.william278.huskhomes.position;
|
||||
import net.william278.huskhomes.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a home set by a {@link Player}
|
||||
*/
|
||||
@@ -21,10 +23,16 @@ public class Home extends SavedPosition {
|
||||
|
||||
public Home(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull Server server,
|
||||
@NotNull PositionMeta positionMeta,
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid,
|
||||
@NotNull Player owner, boolean isPublic) {
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta);
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta, uuid);
|
||||
this.owner = owner;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
public Home(Position position, PositionMeta meta, @NotNull Player owner) {
|
||||
super(position, meta);
|
||||
this.owner = owner;
|
||||
this.isPublic = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Location {
|
||||
|
||||
/**
|
||||
* The double-precision defined x coordinate of the location
|
||||
*/
|
||||
public double x;
|
||||
|
||||
/**
|
||||
* The double-precision defined y coordinate of the location
|
||||
*/
|
||||
public double y;
|
||||
|
||||
/**
|
||||
* The double-precision defined z coordinate of the location
|
||||
*/
|
||||
public double z;
|
||||
|
||||
/**
|
||||
* The float-precision defined yaw facing of the location
|
||||
*/
|
||||
public float yaw;
|
||||
|
||||
/**
|
||||
* The float-precision defined pitch facing of the location
|
||||
*/
|
||||
public float pitch;
|
||||
|
||||
/**
|
||||
* The {@link World} the location is on
|
||||
*/
|
||||
@NotNull
|
||||
public World world;
|
||||
|
||||
public Location(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,41 +2,12 @@ package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a position somewhere on the proxy network or server
|
||||
* Represents a position - a location somewhere on the proxy network or server
|
||||
*/
|
||||
public class Position {
|
||||
|
||||
/**
|
||||
* The double-precision defined x coordinate of the position
|
||||
*/
|
||||
public double x;
|
||||
|
||||
/**
|
||||
* The double-precision defined y coordinate of the position
|
||||
*/
|
||||
public double y;
|
||||
|
||||
/**
|
||||
* The double-precision defined z coordinate of the position
|
||||
*/
|
||||
public double z;
|
||||
|
||||
/**
|
||||
* The float-precision defined yaw facing of the position
|
||||
*/
|
||||
public float yaw;
|
||||
|
||||
/**
|
||||
* The float-precision defined pitch facing of the position
|
||||
*/
|
||||
public float pitch;
|
||||
|
||||
/**
|
||||
* The {@link World} the position is within
|
||||
*/
|
||||
@NotNull
|
||||
public World world;
|
||||
public class Position extends Location {
|
||||
|
||||
/**
|
||||
* The {@link Server} the position is on
|
||||
@@ -44,13 +15,9 @@ public class Position {
|
||||
@NotNull
|
||||
public Server server;
|
||||
|
||||
public Position(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull Server server) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.world = world;
|
||||
public Position(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull Server server) {
|
||||
super(x, y, z, yaw, pitch, world);
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,26 +2,40 @@ package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* Represents metadata about a {@link Position}, used in {@link SavedPosition} implementations
|
||||
*/
|
||||
public class PositionMeta {
|
||||
|
||||
/**
|
||||
* The name of this position
|
||||
* The name of a position
|
||||
*/
|
||||
@NotNull
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* A description of this position
|
||||
* A description of a position
|
||||
*/
|
||||
@NotNull
|
||||
public String description;
|
||||
|
||||
/**
|
||||
* The epoch timestamp of a position's creation
|
||||
*/
|
||||
public long timestamp;
|
||||
|
||||
public PositionMeta(@NotNull String name, @NotNull String description, long timestamp) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public PositionMeta(@NotNull String name, @NotNull String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.timestamp = Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,22 +2,44 @@ package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a persistently-saved {@link Position}
|
||||
*/
|
||||
public class SavedPosition extends Position {
|
||||
public abstract class SavedPosition extends Position {
|
||||
|
||||
/**
|
||||
* Metadata about this position (name, description)
|
||||
*/
|
||||
@NotNull
|
||||
public final PositionMeta positionMeta;
|
||||
public final PositionMeta meta;
|
||||
|
||||
public SavedPosition(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull Server server,
|
||||
@NotNull PositionMeta positionMeta) {
|
||||
/**
|
||||
* A unique ID representing this position
|
||||
*/
|
||||
@NotNull
|
||||
public final UUID uuid;
|
||||
|
||||
protected SavedPosition(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull Server server,
|
||||
@NotNull PositionMeta meta, @NotNull UUID uuid) {
|
||||
super(x, y, z, yaw, pitch, world, server);
|
||||
this.positionMeta = positionMeta;
|
||||
this.meta = meta;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link SavedPosition} from a {@link Position} and {@link PositionMeta}
|
||||
*
|
||||
* @param position The {@link Position} to save
|
||||
* @param meta {@link PositionMeta} information about this position
|
||||
*/
|
||||
protected SavedPosition(@NotNull Position position, @NotNull PositionMeta meta) {
|
||||
super(position.x, position.y, position.z, position.yaw, position.pitch,
|
||||
position.world, position.server);
|
||||
this.meta = meta;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a server on a proxied network
|
||||
*/
|
||||
@@ -8,9 +10,10 @@ public class Server {
|
||||
/**
|
||||
* Proxy-defined identifier of this server
|
||||
*/
|
||||
@NotNull
|
||||
public String id;
|
||||
|
||||
public Server(String id) {
|
||||
public Server(@NotNull String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a server warp
|
||||
*/
|
||||
@@ -9,8 +11,18 @@ public class Warp extends SavedPosition {
|
||||
|
||||
public Warp(double x, double y, double z, float yaw, float pitch,
|
||||
@NotNull World world, @NotNull Server server,
|
||||
@NotNull PositionMeta positionMeta) {
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta);
|
||||
@NotNull PositionMeta positionMeta, @NotNull UUID uuid) {
|
||||
super(x, y, z, yaw, pitch, world, server, positionMeta, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Warp} from a {@link Position} and {@link PositionMeta}
|
||||
*
|
||||
* @param position The {@link Position} to save as a warp
|
||||
* @param meta {@link PositionMeta} information about this position
|
||||
*/
|
||||
public Warp(Position position, PositionMeta meta) {
|
||||
super(position, meta);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.william278.huskhomes.position;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -10,14 +12,16 @@ public class World {
|
||||
/**
|
||||
* The name of this world, as defined by the world directory name
|
||||
*/
|
||||
@NotNull
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* UUID of this world, as defined by the {@code uid.dat} file in the world directory
|
||||
*/
|
||||
@NotNull
|
||||
public UUID uuid;
|
||||
|
||||
public World(String name, UUID uuid) {
|
||||
public World(@NotNull String name, @NotNull UUID uuid) {
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user