Add fabric builds for older MC versions & add checkstyle (#449)

* Remove instance getters, improve command logic, register APi

* Publish multiple fabric builds, enforce checkstyle

* Bump guava

* Bump to 4.4.2
This commit is contained in:
William authored and GitHub committed 2023-07-02 13:26:12 +01:00
1 parent 51baf196b3
commit c9f5262292
219 files changed
+8032 -1392

No files matched your search

@@ -25,10 +25,13 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Represents a home set by a {@link User}
* Represents a home set by a {@link User}.
*/
public class Home extends SavedPosition {
/**
* The delimiter used to separate the owner's name from the home name in the home identifier.
*/
public static final String IDENTIFIER_DELIMITER = ".";
private final User owner;
private boolean isPublic;
@@ -46,19 +49,47 @@ public class Home extends SavedPosition {
this.setPublic(false);
}
/**
* Creates a new {@link Home} from a series of coordinates, a viewing angle, a {@link World}, a server name, a
* {@link PositionMeta}, a {@link UUID}, a {@link User} and a boolean representing whether the home is public.
*
* @param x The x coordinate of the home
* @param y The y coordinate of the home
* @param z The z coordinate of the home
* @param yaw The yaw of the home
* @param pitch The pitch of the home
* @param world The {@link World} the home is in
* @param server The name of the server the home is in
* @param positionMeta The {@link PositionMeta} of the home
* @param uuid The {@link UUID} of the home
* @param owner The {@link User} who owns the home
* @param isPublic Whether the home is public
* @return the new {@link Home}
*/
@NotNull
public static Home from(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server,
@NotNull PositionMeta positionMeta, @NotNull UUID uuid, @NotNull User owner, boolean isPublic) {
public static Home from(double x, double y, double z, float yaw, float pitch, @NotNull World world,
@NotNull String server, @NotNull PositionMeta positionMeta, @NotNull UUID uuid,
@NotNull User owner, boolean isPublic) {
return new Home(x, y, z, yaw, pitch, world, server, positionMeta, uuid, owner, isPublic);
}
/**
* Creates a new {@link Home} from a {@link Position} and {@link PositionMeta}.
*
* @param position The {@link Position} to create the home from
* @param meta The {@link PositionMeta} to create the home from
* @param owner The {@link User} who owns the home
* @return the new {@link Home}
*/
@NotNull
public static Home from(@NotNull Position position, @NotNull PositionMeta meta, @NotNull User owner) {
return new Home(position, meta, owner);
}
/**
* The {@link User} who owns this home
* Get the {@link User} who owns this home.
*
* @return the {@link User} who owns this home
*/
@NotNull
public User getOwner() {
@@ -66,22 +97,45 @@ public class Home extends SavedPosition {
}
/**
* {@code true} if this home is public
* Returns whether this home is public.
*
* @return {@code true} if this home is public.
*/
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
/**
* Sets whether this home is public.
*
* @param isPublic {@code true} if this home is public
*/
public void setPublic(boolean isPublic) {
this.isPublic = isPublic;
}
/**
* Get a version of the canonical home identifier string that is safe for use in formatted locales.
* Safe identifiers will only contain alphanumeric ASCII characters (a-z, A-Z, 0-9), underscores and dashes.
*
* <p>This typically consists of the owner's username, a delimiter, and the home {@link #getUuid() UUID}.
*
* @return the locale-safe canonical home identifier string
*/
@NotNull
@Override
public String getSafeIdentifier() {
return getOwner().getUsername() + IDENTIFIER_DELIMITER + super.getSafeIdentifier();
}
/**
* Get the canonical home identifier string.
*
* <p>This typically consists of the owner's username, a delimiter, and the home {@link #getName() name}.
*
* @return the canonical home identifier string
* @see #getSafeIdentifier() #getSafeIdentifier() to get a locale-safe version of this string
*/
@NotNull
@Override
public String getIdentifier() {
@@ -23,9 +23,10 @@ import com.google.gson.annotations.Expose;
import org.jetbrains.annotations.NotNull;
/**
* Represents a local position on this server
* Represents a local position on this server.
*/
public class Location {
@Expose
private double x;
@Expose
@@ -62,7 +63,7 @@ public class Location {
}
/**
* Update the position to match that of another position
* Update the position to match that of another position.
*
* @param position The position to update to
*/
@@ -76,7 +77,7 @@ public class Location {
}
/**
* The double-precision defined x coordinate of the location
* The double-precision defined x coordinate of the location.
*/
public double getX() {
return x;
@@ -87,7 +88,7 @@ public class Location {
}
/**
* The double-precision defined y coordinate of the location
* The double-precision defined y coordinate of the location.
*/
public double getY() {
return y;
@@ -98,7 +99,7 @@ public class Location {
}
/**
* The double-precision defined z coordinate of the location
* The double-precision defined z coordinate of the location.
*/
public double getZ() {
return z;
@@ -109,7 +110,7 @@ public class Location {
}
/**
* The float-precision defined yaw facing of the location
* The float-precision defined yaw facing of the location.
*/
public float getYaw() {
return yaw;
@@ -120,7 +121,7 @@ public class Location {
}
/**
* The float-precision defined pitch facing of the location
* The float-precision defined pitch facing of the location.
*/
public float getPitch() {
return pitch;
@@ -131,7 +132,7 @@ public class Location {
}
/**
* The {@link World} the location is on
* The {@link World} the location is on.
*/
public World getWorld() {
return world;
@@ -140,4 +141,5 @@ public class Location {
public void setWorld(World world) {
this.world = world;
}
}
@@ -24,20 +24,22 @@ import net.william278.huskhomes.teleport.Target;
import org.jetbrains.annotations.NotNull;
/**
* Represents a position - a {@link Location} somewhere on the proxy network or server
* Represents a position - a {@link Location} somewhere on the proxy network or server.
*/
public class Position extends Location implements Target {
@Expose
private String server;
protected 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);
}
protected Position(@NotNull Location location, @NotNull String server) {
super(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), location.getWorld());
super(location.getX(), location.getY(), location.getZ(), location.getYaw(),
location.getPitch(), location.getWorld());
this.setServer(server);
}
@@ -46,12 +48,14 @@ public class Position extends Location implements Target {
}
@NotNull
public static Position at(double x, double y, double z, float yaw, float pitch, @NotNull World world, @NotNull String server) {
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) {
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);
}
@@ -67,7 +71,7 @@ public class Position extends Location implements Target {
}
/**
* The name of the server the position is on
* The name of the server the position is on.
*/
@NotNull
public String getServer() {
@@ -80,10 +84,10 @@ public class Position extends Location implements Target {
@Override
public String toString() {
return "x: " + (int) getX() + ", " +
"y: " + (int) getY() + ", " +
"z: " + (int) getZ() + " " +
"(" + getWorld().getName() + " / " + getServer() + ")";
return "x: " + (int) getX() + ", "
+ "y: " + (int) getY() + ", "
+ "z: " + (int) getZ() + " "
+ "(" + getWorld().getName() + " / " + getServer() + ")";
}
}
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* Represents metadata about a {@link Position}, used in {@link SavedPosition} implementations
* Represents metadata about a {@link Position}, used in {@link SavedPosition} implementations.
*/
public class PositionMeta {
@@ -58,7 +58,7 @@ public class PositionMeta {
}
/**
* Deserialize a JSON string into a {@link Map} of meta tags
* Deserialize a JSON string into a {@link Map} of meta tags.
*
* @param serializedTags The JSON string to deserialize
* @return The deserialized {@link Map}
@@ -78,7 +78,7 @@ public class PositionMeta {
}
/**
* Serialize a {@link Map} of meta tags into a JSON string
* Serialize a {@link Map} of meta tags into a JSON string.
*
* @return The serialized JSON string
*/
@@ -96,7 +96,7 @@ public class PositionMeta {
}
/**
* The name of a position
* The name of a position.
*/
public String getName() {
return name;
@@ -107,7 +107,7 @@ public class PositionMeta {
}
/**
* A description of a position
* A description of a position.
*/
@NotNull
public String getDescription() {
@@ -119,7 +119,7 @@ public class PositionMeta {
}
/**
* Map of metadata tags for a position
* Map of metadata tags for a position.
*/
public Map<String, String> getTags() {
return tags;
@@ -130,7 +130,7 @@ public class PositionMeta {
}
/**
* The time the position was created
* The time the position was created.
*/
@NotNull
public Instant getCreationTime() {
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Represents a persistently-saved {@link Position}
* Represents a persistently-saved {@link Position}.
*/
public abstract class SavedPosition extends Position implements Comparable<SavedPosition> {
@@ -40,7 +40,7 @@ public abstract class SavedPosition extends Position implements Comparable<Saved
}
/**
* Create a new {@link SavedPosition} from a {@link Position} and {@link PositionMeta}
* 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
@@ -53,7 +53,7 @@ public abstract class SavedPosition extends Position implements Comparable<Saved
}
/**
* Metadata about this position (name, description)
* Metadata about this position (name, description).
*/
@NotNull
public PositionMeta getMeta() {
@@ -65,7 +65,7 @@ public abstract class SavedPosition extends Position implements Comparable<Saved
}
/**
* The name of this position. Shortcut for {@link #getMeta()}.{@link PositionMeta#getName()}
* The name of this position. Shortcut for {@link #getMeta()}.{@link PositionMeta#getName()}.
*/
@NotNull
public String getName() {
@@ -73,7 +73,7 @@ public abstract class SavedPosition extends Position implements Comparable<Saved
}
/**
* A unique ID representing this position
* A unique ID representing this position.
*/
@NotNull
public UUID getUuid() {
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Represents a server warp
* Represents a server warp.
*/
public class Warp extends SavedPosition {
@@ -36,7 +36,7 @@ public class Warp extends SavedPosition {
}
/**
* Create a new {@link Warp} from a {@link Position} and {@link PositionMeta}
* 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
@@ -26,7 +26,7 @@ import java.util.Optional;
import java.util.UUID;
/**
* Represents a world on a server
* Represents a world on a server.
*/
public class World {
@@ -56,7 +56,7 @@ public class World {
}
/**
* The name of this world, as defined by the world directory name
* The name of this world, as defined by the world directory name.
*/
@NotNull
public String getName() {
@@ -68,7 +68,7 @@ public class World {
}
/**
* UUID of this world, as defined by the {@code uid.dat} file in the world directory
* UUID of this world, as defined by the {@code uid.dat} file in the world directory.
*/
@NotNull
public UUID getUuid() {
@@ -81,9 +81,9 @@ public class World {
/**
* Environment of the world ({@link Environment#OVERWORLD}, {@link Environment#NETHER}, {@link Environment#THE_END},
* or {@link Environment#CUSTOM})
* <p>
* Will return {@link Environment#OVERWORLD} if the environment is null
* or {@link Environment#CUSTOM}).
*
* <p>Will return {@link Environment#OVERWORLD} if the environment is null
*/
@NotNull
public Environment getEnvironment() {
@@ -95,7 +95,7 @@ public class World {
}
/**
* Identifies the environment of the world
* Identifies the environment of the world.
*/
public enum Environment {
OVERWORLD,