mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Message and setting loading
This commit is contained in:
1 parent
704e4b12f8
commit
10e3345b38
16 files changed
+821
-25
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package net.william278.huskhomes.teleport;
|
||||
|
||||
import net.william278.huskhomes.player.Player;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a teleport in the process of being executed
|
||||
*/
|
||||
public class Teleport {
|
||||
|
||||
/**
|
||||
* The player involved in the teleport
|
||||
*/
|
||||
@NotNull
|
||||
public Player player;
|
||||
|
||||
/**
|
||||
* The target position for the player
|
||||
*/
|
||||
@NotNull
|
||||
public Position target;
|
||||
|
||||
public Teleport(@NotNull Player player, @NotNull Position target) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.william278.huskhomes.teleport;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.Player;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Cross-platform teleportation manager
|
||||
*/
|
||||
public abstract class TeleportManager {
|
||||
|
||||
/**
|
||||
* Instance of the implementing plugin
|
||||
*/
|
||||
@NotNull
|
||||
private final HuskHomes plugin;
|
||||
|
||||
/**
|
||||
* {@link Set} of currently processing teleports
|
||||
*/
|
||||
@NotNull
|
||||
private final Set<CompletableFuture<Teleport>> processingTeleports;
|
||||
|
||||
public TeleportManager(@NotNull HuskHomes plugin) {
|
||||
this.plugin = plugin;
|
||||
this.processingTeleports = new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public CompletableFuture<TeleportResult> teleport(Player player, Position position) {
|
||||
if (position.server.equals(plugin.getServerData())) {
|
||||
return teleportLocally(new Teleport(player, position));
|
||||
} else {
|
||||
return teleportCrossServer(new Teleport(player, position));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract CompletableFuture<TeleportResult> teleportLocally(Teleport teleport);
|
||||
|
||||
private CompletableFuture<TeleportResult> teleportCrossServer(Teleport teleport) {
|
||||
return null; //todo dispatch cross-server message here!
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,31 +4,31 @@ import net.william278.huskhomes.position.Position;
|
||||
import net.william278.huskhomes.position.World;
|
||||
|
||||
/**
|
||||
* Represents the result of a completed teleport
|
||||
* Represents the result of a completed {@link Teleport}
|
||||
*/
|
||||
public enum TeleportResult {
|
||||
|
||||
/**
|
||||
* Returns if the teleport completed successfully
|
||||
* Returns if the {@link Teleport} completed successfully
|
||||
*/
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* Returns if the teleport failed because the {@link World} of the
|
||||
* Returns if the {@link 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
|
||||
* Returns if the {@link 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
|
||||
* Returns if the {@link Teleport} failed because the coordinates of the
|
||||
* target {@link Position} were outside the world border limits
|
||||
* <p>
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user