mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Small fixes to server fetching
This commit is contained in:
1 parent
052eb57438
commit
7ac52d747f
3 files changed
+19
-6
No files matched your search
@@ -26,6 +26,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -63,7 +64,8 @@ public class HuskHomesBukkit extends JavaPlugin implements HuskHomes {
|
|||||||
* @param player {@link Player} to request the server
|
* @param player {@link Player} to request the server
|
||||||
* @return The {@link Server} object
|
* @return The {@link Server} object
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<Server> getServer(Player player) {
|
@Override
|
||||||
|
public CompletableFuture<Server> getServer(@NotNull Player player) {
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
return CompletableFuture.supplyAsync(() -> server);
|
return CompletableFuture.supplyAsync(() -> server);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ import net.william278.huskhomes.config.Settings;
|
|||||||
import net.william278.huskhomes.data.Database;
|
import net.william278.huskhomes.data.Database;
|
||||||
import net.william278.huskhomes.player.Player;
|
import net.william278.huskhomes.player.Player;
|
||||||
import net.william278.huskhomes.position.Position;
|
import net.william278.huskhomes.position.Position;
|
||||||
|
import net.william278.huskhomes.position.Server;
|
||||||
import net.william278.huskhomes.util.Logger;
|
import net.william278.huskhomes.util.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a cross-platform instance of the plugin
|
* Represents a cross-platform instance of the plugin
|
||||||
@@ -58,6 +61,12 @@ public interface HuskHomes {
|
|||||||
*/
|
*/
|
||||||
Cache getCache();
|
Cache getCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link Server} this server is on
|
||||||
|
* @return The server
|
||||||
|
*/
|
||||||
|
CompletableFuture<Server> getServer(@NotNull Player requester);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the position is a valid location on the server
|
* Returns true if the position is a valid location on the server
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,11 +31,13 @@ public class TeleportManager {
|
|||||||
*/
|
*/
|
||||||
public CompletableFuture<TeleportResult> teleport(Player player, Position position) {
|
public CompletableFuture<TeleportResult> teleport(Player player, Position position) {
|
||||||
final Teleport teleport = new Teleport(new User(player), position);
|
final Teleport teleport = new Teleport(new User(player), position);
|
||||||
if (position.server.equals(plugin.getServerData())) {
|
return plugin.getServer(player).thenApplyAsync(server -> {
|
||||||
return player.teleport(teleport.target);
|
if (position.server.equals(server)) {
|
||||||
} else {
|
return player.teleport(teleport.target).join();
|
||||||
return teleportCrossServer(teleport);
|
} else {
|
||||||
}
|
return teleportCrossServer(teleport).join();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompletableFuture<TeleportResult> teleportCrossServer(Teleport teleport) {
|
private CompletableFuture<TeleportResult> teleportCrossServer(Teleport teleport) {
|
||||||
|
|||||||
Reference in new issue
Block a user