Refactor bootstrap procedure, use enum for command loading

This commit is contained in:
William committed 2022-08-09 14:18:48 +01:00
1 parent eff21a16d5
commit ec1c0b744f
42 files changed
+982 -718

No files matched your search

@@ -3,7 +3,6 @@ package net.william278.huskhomes.player;
import de.themoep.minedown.MineDown;
import net.william278.huskhomes.position.Location;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.Server;
import net.william278.huskhomes.teleport.TeleportResult;
import net.william278.huskhomes.util.EconomyUnsupportedException;
import org.jetbrains.annotations.NotNull;
@@ -12,44 +11,35 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture;
/**
* A cross-platform representation of a player
* A cross-platform representation of a logged-in {@link User}
*/
public interface Player {
public abstract class OnlineUser extends User {
/**
* Return the player's name
*
* @return the player's name
*/
String getName();
public OnlineUser(@NotNull UUID uuid, @NotNull String username) {
super(uuid, username);
}
/**
* 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}
*/
CompletableFuture<Position> getPosition();
public abstract CompletableFuture<Position> getPosition();
/**
* Returns the current local {@link Location} of this player
*
* @return the player's current {@link Location} on the server
*/
Location getLocation();
public abstract Location getLocation();
/**
* Returns the health of this player
*
* @return the player's health points
*/
double getHealth();
public abstract double getHealth();
/**
* Returns if the player has the permission node
@@ -57,35 +47,43 @@ public interface Player {
* @param node The permission node string
* @return {@code true} if the player has the node; {@code false} otherwise
*/
boolean hasPermission(@NotNull String node);
public abstract boolean hasPermission(@NotNull String node);
/**
* Dispatch a MineDown-formatted message to this player
* Dispatch a MineDown-formatted action bar message to this player
*
* @param mineDown the parsed {@link MineDown} to send
*/
void sendMessage(@NotNull MineDown mineDown);
public abstract void sendActionBar(@NotNull MineDown mineDown);
/**
* Dispatch a MineDown-formatted chat message to this player
*
* @param mineDown the parsed {@link MineDown} to send
*/
public abstract void sendMessage(@NotNull MineDown mineDown);
/**
* Teleport a player to the specified {@link Location}
*
* @param location the {@link Location} to teleport the player to
*/
CompletableFuture<TeleportResult> teleport(Location location);
public abstract CompletableFuture<TeleportResult> teleport(Location location);
/**
* 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();
public abstract 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();
public abstract CompletableFuture<Integer> getFreeHomes();
/**
* Get this player's economy balance
@@ -93,14 +91,14 @@ public interface Player {
* @return the player's economy balance
* @throws EconomyUnsupportedException if the economy integration is not enabled
*/
double getEconomyBalance() throws EconomyUnsupportedException;
public abstract double getEconomyBalance() throws EconomyUnsupportedException;
/**
* Deduct money from this player's economy balance
*
* @throws EconomyUnsupportedException if the economy integration is not enabled
*/
void deductEconomyBalance() throws EconomyUnsupportedException;
public abstract void deductEconomyBalance() throws EconomyUnsupportedException;
}
@@ -5,13 +5,14 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Represents persistently stored {@link User} data about a {@link Player}; uuid and username
* A {@link Player} may be retrieved from a user by the platform implementing classes
* Represents a user who has data saved in the database
*/
public class User {
@NotNull
public final UUID uuid;
@NotNull
public final String username;
/**
@@ -25,13 +26,4 @@ public class User {
this.username = username;
}
/**
* Get a user from an online {@link Player}
*
* @param player the online {@link Player}
*/
public User(Player player) {
this.uuid = player.getUuid();
this.username = player.getName();
}
}