Version 3.0 setup

This commit is contained in:
William committed 2022-05-20 17:27:14 +01:00
1 parent e122816613
commit 58ffaa0641
23 files changed
+874 -2

No files matched your search

@@ -0,0 +1,27 @@
package net.william278.huskhomes;
import net.william278.huskhomes.player.Player;
import net.william278.huskhomes.util.Logger;
import java.util.Set;
/**
* Represents a cross-platform instance of the plugin
*/
public interface HuskHomes {
/**
* Returns the platform plugin console logger
*
* @return the {@link Logger} implementation to use
*/
Logger getLogger();
/**
* Returns a {@link Set} of online {@link Player}s on this server
*
* @return a {@link Set} of currently online {@link Player}s
*/
Set<Player> getOnlinePlayers();
}
@@ -0,0 +1,58 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.player.Player;
import java.util.List;
/**
* Represents an abstract cross-platform representation for a plugin command
*/
public abstract class CommandBase {
/**
* The input string to match for this command
*/
public final String command;
/**
* The permission node required to use this command
*/
public final String permission;
/**
* Alias input strings for this command
*/
public final String[] aliases;
/**
* Instance of the proxy plugin implementor
*/
public final HuskHomes implementor;
public CommandBase(String command, String permission, HuskHomes implementingPlugin, String... aliases) {
this.command = command;
this.permission = permission;
this.implementor = implementingPlugin;
this.aliases = aliases;
}
/**
* Fires when the command is executed
*
* @param player {@link Player} executing the command
* @param args Command arguments
*/
public abstract void onExecute(Player player, String[] args);
/**
* What should be returned when the player attempts to TAB complete the command
*
* @param player {@link Player} doing the TAB completion
* @param args Current command arguments
* @return List of String arguments to offer TAB suggestions
*/
public abstract List<String> onTabComplete(Player player, String[] args);
}
@@ -0,0 +1,67 @@
package net.william278.huskhomes.player;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.TeleportResult;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
/**
* A cross-platform representation of a player
*/
public interface Player {
/**
* Return the player's name
*
* @return the player's name
*/
String getName();
/**
* Return the player's {@link UUID}
*
* @return the player {@link UUID}
*/
UUID getUuid();
/**
* Returns the current {@link Position} of this player
*
* @return the player's current {@link Position}
*/
Position getPosition();
/**
* Returns if the player has the permission node
*
* @param node The permission node string
* @return {@code true} if the player has the node; {@code false} otherwise
*/
boolean hasPermission(String node);
void sendMessage();
/**
* Returns the maximum number of homes this player can set
*
* @return a {@link CompletableFuture} providing the max number of homes this player can set
*/
CompletableFuture<Integer> getMaxHomes();
/**
* Returns the number of homes this player can set for free
*
* @return a {@link CompletableFuture} providing the max number of homes this player can set
*/
CompletableFuture<Integer> getFreeHomes();
/**
* Teleport the player to a specified {@link Position}
*
* @param position the target {@link Position} to teleport to
* @return A {@link CompletableFuture} callback returning the {@link TeleportResult} of completing the teleport
*/
CompletableFuture<TeleportResult> teleport(Position position);
}
@@ -0,0 +1,30 @@
package net.william278.huskhomes.position;
import net.william278.huskhomes.player.Player;
import org.jetbrains.annotations.NotNull;
/**
* Represents a home set by a {@link Player}
*/
public class Home extends SavedPosition {
/**
* The {@link Player} who owns this home
*/
@NotNull
public final Player owner;
/**
* {@code true} if this home is public
*/
public boolean isPublic;
public Home(double x, double y, double z, float yaw, float pitch,
@NotNull World world, @NotNull Server server,
@NotNull PositionMeta positionMeta,
@NotNull Player owner, boolean isPublic) {
super(x, y, z, yaw, pitch, world, server, positionMeta);
this.owner = owner;
this.isPublic = isPublic;
}
}
@@ -0,0 +1,57 @@
package net.william278.huskhomes.position;
import org.jetbrains.annotations.NotNull;
/**
* Represents a position 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;
/**
* The {@link Server} the position is on
*/
@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;
this.server = server;
}
}
@@ -0,0 +1,27 @@
package net.william278.huskhomes.position;
import org.jetbrains.annotations.NotNull;
/**
* Represents metadata about a {@link Position}, used in {@link SavedPosition} implementations
*/
public class PositionMeta {
/**
* The name of this position
*/
@NotNull
public String name;
/**
* A description of this position
*/
@NotNull
public String description;
public PositionMeta(@NotNull String name, @NotNull String description) {
this.name = name;
this.description = description;
}
}
@@ -0,0 +1,16 @@
package net.william278.huskhomes.position;
import org.jetbrains.annotations.NotNull;
public class SavedPosition extends Position {
@NotNull
public final PositionMeta positionMeta;
public SavedPosition(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);
this.positionMeta = positionMeta;
}
}
@@ -0,0 +1,20 @@
package net.william278.huskhomes.position;
import java.util.UUID;
/**
* Represents a server on a proxied network
*/
public class Server {
/**
* Proxy-defined identifier of this server
*/
public String id;
/**
* Plugin-assigned identifier of this server
*/
public UUID uuid;
}
@@ -0,0 +1,16 @@
package net.william278.huskhomes.position;
import org.jetbrains.annotations.NotNull;
/**
* Represents a server warp
*/
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);
}
}
@@ -0,0 +1,25 @@
package net.william278.huskhomes.position;
import java.util.UUID;
/**
* Represents a world on a server
*/
public class World {
/**
* The name of this world, as defined by the world directory name
*/
public String name;
/**
* UUID of this world, as defined by the {@code uid.dat} file in the world directory
*/
public UUID uuid;
public World(String name, UUID uuid) {
this.name = name;
this.uuid = uuid;
}
}
@@ -0,0 +1,46 @@
package net.william278.huskhomes.teleport;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.World;
/**
* Represents the result of a completed teleport
*/
public enum TeleportResult {
/**
* Returns if the teleport completed successfully
*/
SUCCESS(true),
/**
* Returns if the teleport failed because the {@link World} of the
* target {@link Position} could not be found
* <p>
*/
FAILED_INVALID_WORLD(false),
/**
* Returns if the teleport failed because the server of the target
* {@link Position} was invalid or not online
* <p>
*/
FAILED_INVALID_SERVER(false),
/**
* Returns if the teleport failed because the coordinates of the
* target {@link Position} were outside the world border limits
* <p>
*/
FAILED_INVALID_COORDINATES(false);
/**
* Is {@code true} if the teleport was a success
*/
public final boolean successful;
TeleportResult(boolean successful) {
this.successful = successful;
}
}
@@ -0,0 +1,17 @@
package net.william278.huskhomes.util;
import java.util.logging.Level;
public interface Logger {
void log(Level level, String message, Exception e);
void log(Level level, String message);
void info(String message);
void severe(String message);
void config(String message);
}