diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java index 8f576620..a29cc7a8 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DeleteCommand.java @@ -1,11 +1,14 @@ package org.mvplugins.multiverse.core.commands; +import java.util.concurrent.CompletableFuture; + import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Conditions; import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Optional; import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; @@ -17,48 +20,81 @@ import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; +import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; +import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.commandtools.queue.QueuedCommand; import org.mvplugins.multiverse.core.utils.MVCorei18n; +import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; import org.mvplugins.multiverse.core.worldnew.WorldManager; +import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter; @Service @CommandAlias("mv") class DeleteCommand extends MultiverseCommand { private final WorldManager worldManager; + private final PlayerWorldTeleporter playerWorldTeleporter; + + private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players") + .addAlias("-r") + .build()); @Inject - DeleteCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + DeleteCommand( + @NotNull MVCommandManager commandManager, + @NotNull WorldManager worldManager, + @NotNull PlayerWorldTeleporter playerWorldTeleporter) { super(commandManager); this.worldManager = worldManager; + this.playerWorldTeleporter = playerWorldTeleporter; } @Subcommand("delete") @CommandPermission("multiverse.core.delete") - @CommandCompletion("@mvworlds:scope=both") + @CommandCompletion("@mvworlds:scope=loaded @flags:groupName=mvdeletecommand") @Syntax("") @Description("{@@mv-core.delete.description}") void onDeleteCommand( MVCommandIssuer issuer, @Single - @Conditions("worldname:scope=both") + @Conditions("worldname:scope=loaded") @Syntax("") @Description("The world you want to delete.") - String worldName) { + LoadedMultiverseWorld world, + + @Optional + @Syntax("[--remove-players]") + @Description("") + String[] flags) { + ParsedCommandFlags parsedFlags = parseFlags(flags); + this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand( issuer.getIssuer(), () -> { - issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", worldName); - worldManager.deleteWorld(worldName) - .onSuccess(deletedWorldName -> { - Logging.fine("World delete success: " + deletedWorldName); - issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, "{world}", deletedWorldName); - }).onFailure(failure -> { - Logging.fine("World delete failure: " + failure); - issuer.sendError(failure.getFailureMessage()); - }); + runDeleteCommand(issuer, world, parsedFlags); }, this.commandManager.formatMessage( - issuer, MessageType.INFO, MVCorei18n.DELETE_PROMPT, "{world}", worldName))); + issuer, MessageType.INFO, MVCorei18n.DELETE_PROMPT, "{world}", world.getName()))); + } + + private void runDeleteCommand(MVCommandIssuer issuer, LoadedMultiverseWorld world, ParsedCommandFlags parsedFlags) { + issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", world.getName()); + + CompletableFuture future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG) + ? CompletableFuture.allOf(playerWorldTeleporter.removeFromWorld(world)) + : CompletableFuture.completedFuture(null); + + future.thenRun(() -> doWorldDeleting(issuer, world)); + } + + private void doWorldDeleting(MVCommandIssuer issuer, LoadedMultiverseWorld world) { + worldManager.deleteWorld(world) + .onSuccess(deletedWorldName -> { + Logging.fine("World delete success: " + deletedWorldName); + issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, "{world}", deletedWorldName); + }).onFailure(failure -> { + Logging.fine("World delete failure: " + failure); + issuer.sendError(failure.getFailureMessage()); + }); } } diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java index 591188da..716100c5 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RegenCommand.java @@ -1,7 +1,9 @@ package org.mvplugins.multiverse.core.commands; import java.util.Collections; +import java.util.List; import java.util.Random; +import java.util.concurrent.CompletableFuture; import co.aikar.commands.MessageType; import co.aikar.commands.annotation.CommandAlias; @@ -13,6 +15,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; @@ -26,6 +29,7 @@ import org.mvplugins.multiverse.core.commandtools.queue.QueuedCommand; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; import org.mvplugins.multiverse.core.worldnew.WorldManager; +import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter; import org.mvplugins.multiverse.core.worldnew.options.RegenWorldOptions; @Service @@ -33,6 +37,7 @@ import org.mvplugins.multiverse.core.worldnew.options.RegenWorldOptions; class RegenCommand extends MultiverseCommand { private final WorldManager worldManager; + private final PlayerWorldTeleporter playerWorldTeleporter; private final CommandValueFlag SEED_FLAG = flag(CommandValueFlag.builder("--seed", String.class) .addAlias("-s") @@ -51,10 +56,18 @@ class RegenCommand extends MultiverseCommand { .addAlias("-wb") .build()); + private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players") + .addAlias("-r") + .build()); + @Inject - RegenCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + RegenCommand( + @NotNull MVCommandManager commandManager, + @NotNull WorldManager worldManager, + @NotNull PlayerWorldTeleporter playerWorldTeleporter) { super(commandManager); this.worldManager = worldManager; + this.playerWorldTeleporter = playerWorldTeleporter; } @Subcommand("regen") @@ -77,23 +90,43 @@ class RegenCommand extends MultiverseCommand { this.commandManager.getCommandQueueManager().addToQueue(new QueuedCommand( issuer.getIssuer(), - () -> { - issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, "{world}", world.getName()); - worldManager.regenWorld(RegenWorldOptions.world(world) - .randomSeed(parsedFlags.hasFlag(SEED_FLAG)) - .seed(parsedFlags.flagValue(SEED_FLAG)) - .keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG)) - .keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG)) - .keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG)) - ).onSuccess(newWorld -> { - Logging.fine("World regen success: " + newWorld); - issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", newWorld.getName()); - }).onFailure(failure -> { - Logging.fine("World regen failure: " + failure); - issuer.sendError(failure.getFailureMessage()); - }); - }, + () -> runRegenCommand(issuer, world, parsedFlags), this.commandManager.formatMessage( issuer, MessageType.INFO, MVCorei18n.REGEN_PROMPT, "{world}", world.getName()))); } + + private void runRegenCommand(MVCommandIssuer issuer, LoadedMultiverseWorld world, ParsedCommandFlags parsedFlags) { + issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, "{world}", world.getName()); + List worldPlayers = world.getPlayers().getOrElse(Collections.emptyList()); + + CompletableFuture future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG) + ? CompletableFuture.allOf(playerWorldTeleporter.removeFromWorld(world)) + : CompletableFuture.completedFuture(null); + + future.thenRun(() -> doWorldRegening(issuer, world, parsedFlags, worldPlayers)); + } + + private void doWorldRegening( + MVCommandIssuer issuer, + LoadedMultiverseWorld world, + ParsedCommandFlags parsedFlags, + List worldPlayers) { + RegenWorldOptions regenWorldOptions = RegenWorldOptions.world(world) + .randomSeed(parsedFlags.hasFlag(SEED_FLAG)) + .seed(parsedFlags.flagValue(SEED_FLAG)) + .keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG)) + .keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG)) + .keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG)); + + worldManager.regenWorld(regenWorldOptions).onSuccess(newWorld -> { + Logging.fine("World regen success: " + newWorld); + issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", newWorld.getName()); + if (parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)) { + playerWorldTeleporter.teleportPlayersToWorld(worldPlayers, newWorld); + } + }).onFailure(failure -> { + Logging.fine("World regen failure: " + failure); + issuer.sendError(failure.getFailureMessage()); + }); + } } diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java index dcfd9a44..d4fa4433 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/RemoveCommand.java @@ -1,10 +1,13 @@ package org.mvplugins.multiverse.core.commands; +import java.util.concurrent.CompletableFuture; + import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Conditions; import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Optional; import co.aikar.commands.annotation.Single; import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; @@ -16,19 +19,31 @@ import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; +import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; +import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.worldnew.WorldManager; +import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter; @Service @CommandAlias("mv") class RemoveCommand extends MultiverseCommand { private final WorldManager worldManager; + private final PlayerWorldTeleporter playerWorldTeleporter; + + private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players") + .addAlias("-r") + .build()); @Inject - RemoveCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + RemoveCommand( + @NotNull MVCommandManager commandManager, + @NotNull WorldManager worldManager, + @NotNull PlayerWorldTeleporter playerWorldTeleporter) { super(commandManager); this.worldManager = worldManager; + this.playerWorldTeleporter = playerWorldTeleporter; } @Subcommand("remove") @@ -40,10 +55,27 @@ class RemoveCommand extends MultiverseCommand { MVCommandIssuer issuer, @Single - @Conditions("mvworlds:scope=both") + @Conditions("mvworlds:scope=both @flags:groupName=mvremovecommand") @Syntax("") @Description("{@@mv-core.remove.world.description}") - String worldName) { + String worldName, + + @Optional + @Syntax("[--remove-players]") + @Description(/* TODO */"") + String[] flags) { + ParsedCommandFlags parsedFlags = parseFlags(flags); + + CompletableFuture future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG) + ? worldManager.getLoadedWorld(worldName) + .map(world -> CompletableFuture.allOf(playerWorldTeleporter.removeFromWorld(world))) + .getOrElse(CompletableFuture.completedFuture(null)) + : CompletableFuture.completedFuture(null); + + future.thenRun(() -> doWorldRemoving(issuer, worldName)); + } + + private void doWorldRemoving(MVCommandIssuer issuer, String worldName) { worldManager.removeWorld(worldName) .onSuccess(removedWorldName -> { Logging.fine("World remove success: " + removedWorldName); diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java index b9c2a0b5..de1c7e23 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/TeleportCommand.java @@ -72,10 +72,10 @@ class TeleportCommand extends MultiverseCommand { issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS, "{player}", playerName, "{destination}", destination.toString()); - CompletableFuture.allOf(Arrays.stream(players) - .map(player -> safetyTeleporter.teleportSafely(issuer.getIssuer(), player, destination)) - .toArray(CompletableFuture[]::new)) - .thenRun(() -> Logging.finer("Async teleport completed.")); + CompletableFuture + .allOf(safetyTeleporter.teleportSafely(issuer.getIssuer(), Arrays.stream(players).toList(), + destination)) + .thenAccept(result -> Logging.fine("Async teleport result: %s", result)); } @Override diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java index 9507e19e..9bf95285 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/UnloadCommand.java @@ -1,5 +1,7 @@ package org.mvplugins.multiverse.core.commands; +import java.util.concurrent.CompletableFuture; + import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -20,6 +22,7 @@ import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.worldnew.LoadedMultiverseWorld; import org.mvplugins.multiverse.core.worldnew.WorldManager; +import org.mvplugins.multiverse.core.worldnew.helpers.PlayerWorldTeleporter; import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions; @Service @@ -27,6 +30,7 @@ import org.mvplugins.multiverse.core.worldnew.options.UnloadWorldOptions; class UnloadCommand extends MultiverseCommand { private final WorldManager worldManager; + private final PlayerWorldTeleporter playerWorldTeleporter; private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players") .addAlias("-r") @@ -37,9 +41,13 @@ class UnloadCommand extends MultiverseCommand { .build()); @Inject - UnloadCommand(@NotNull MVCommandManager commandManager, @NotNull WorldManager worldManager) { + UnloadCommand( + @NotNull MVCommandManager commandManager, + @NotNull WorldManager worldManager, + @NotNull PlayerWorldTeleporter playerWorldTeleporter) { super(commandManager); this.worldManager = worldManager; + this.playerWorldTeleporter = playerWorldTeleporter; } @Subcommand("unload") @@ -61,8 +69,16 @@ class UnloadCommand extends MultiverseCommand { ParsedCommandFlags parsedFlags = parseFlags(flags); issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING, "{world}", world.getAlias()); + + CompletableFuture future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG) + ? CompletableFuture.allOf(playerWorldTeleporter.removeFromWorld(world)) + : CompletableFuture.completedFuture(null); + + future.thenRun(() -> doWorldUnloading(issuer, world, parsedFlags)); + } + + private void doWorldUnloading(MVCommandIssuer issuer, LoadedMultiverseWorld world, ParsedCommandFlags parsedFlags) { UnloadWorldOptions unloadWorldOptions = UnloadWorldOptions.world(world) - .removePlayers(parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)) .saveBukkitWorld(!parsedFlags.hasFlag(NO_SAVE_FLAG)); worldManager.unloadWorld(unloadWorldOptions) .onSuccess(loadedWorld -> { diff --git a/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java b/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java index 443e36bb..3a6fffc9 100644 --- a/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java +++ b/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java @@ -19,6 +19,7 @@ import org.mvplugins.multiverse.core.api.BlockSafety; import org.mvplugins.multiverse.core.destination.ParsedDestination; import org.mvplugins.multiverse.core.utils.result.Result; +@SuppressWarnings("unchecked") @Service public class AsyncSafetyTeleporter { private final BlockSafety blockSafety; @@ -38,6 +39,15 @@ public class AsyncSafetyTeleporter { return teleportSafely(null, teleportee, destination); } + public CompletableFuture>[] teleportSafely( + @Nullable CommandSender teleporter, + @NotNull List teleportees, + @Nullable ParsedDestination destination) { + return teleportees.stream() + .map(teleportee -> teleportSafely(teleporter, teleportee, destination)) + .toArray(CompletableFuture[]::new); + } + public CompletableFuture> teleportSafely( @Nullable CommandSender teleporter, @NotNull Entity teleportee, @@ -70,12 +80,12 @@ public class AsyncSafetyTeleporter { return teleport(teleporter, teleportee, safeLocation); } - public List>> teleport( + public CompletableFuture>[] teleport( @NotNull List teleportees, @Nullable ParsedDestination destination) { return teleportees.stream() .map(teleportee -> teleport(teleportee, destination)) - .toList(); + .toArray(CompletableFuture[]::new); } public CompletableFuture> teleport( @@ -94,12 +104,12 @@ public class AsyncSafetyTeleporter { return teleport(teleporter, teleportee, destination.getLocation(teleportee)); } - public List>> teleport( + public CompletableFuture>[] teleport( @NotNull List teleportees, @Nullable Location location) { return teleportees.stream() .map(teleportee -> teleport(teleportee, location)) - .toList(); + .toArray(CompletableFuture[]::new); } public CompletableFuture> teleport( diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java index 961997a9..1266680c 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/worldnew/WorldManager.java @@ -371,10 +371,6 @@ public class WorldManager { return worldActionResult(UnloadFailureReason.WORLD_ALREADY_UNLOADING, world.getName()); } - if (options.removePlayers()) { - playerWorldActions.removeFromWorld(world); - } - return unloadBukkitWorld(world.getBukkitWorld().getOrNull(), options.saveBukkitWorld()).fold( exception -> worldActionResult(UnloadFailureReason.BUKKIT_UNLOAD_FAILED, world.getName(), exception), @@ -426,7 +422,7 @@ public class WorldManager { */ public Attempt removeWorld(@NotNull LoadedMultiverseWorld loadedWorld) { // TODO: Config option on removePlayers - return unloadWorld(UnloadWorldOptions.world(loadedWorld).removePlayers(true)) + return unloadWorld(UnloadWorldOptions.world(loadedWorld)) .transform(RemoveFailureReason.UNLOAD_FAILED) .mapAttempt(this::removeWorldFromConfig); } @@ -588,7 +584,6 @@ public class WorldManager { */ public Attempt regenWorld(@NotNull RegenWorldOptions options) { LoadedMultiverseWorld world = options.world(); - List playersInWorld = world.getPlayers().getOrElse(Collections.emptyList()); DataTransfer dataTransfer = transferData(options, world); boolean shouldKeepSpawnLocation = options.keepWorldConfig() && options.seed() == world.getSeed(); Location spawnLocation = world.getSpawnLocation(); @@ -611,7 +606,6 @@ public class WorldManager { // different seed. newWorld.setSpawnLocation(spawnLocation); } - playerWorldActions.teleportPlayersToWorld(playersInWorld, newWorld); saveWorldsConfig(); }); } diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java index 858ed13e..d3963df7 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java +++ b/src/main/java/org/mvplugins/multiverse/core/worldnew/helpers/PlayerWorldTeleporter.java @@ -34,7 +34,7 @@ public class PlayerWorldTeleporter { * * @param world The world to remove all players from. */ - public List>> + public CompletableFuture>[] removeFromWorld(@NotNull LoadedMultiverseWorld world) { // TODO: Better handling of fallback world World toWorld = Bukkit.getWorlds().get(0); @@ -47,7 +47,7 @@ public class PlayerWorldTeleporter { * @param from The world to transfer players from. * @param to The location to transfer players to. */ - public List>> + public CompletableFuture>[] transferFromWorldTo(@NotNull LoadedMultiverseWorld from, @NotNull LoadedMultiverseWorld to) { return transferAllFromWorldToLocation(from, to.getSpawnLocation()); } @@ -58,7 +58,7 @@ public class PlayerWorldTeleporter { * @param from The world to transfer players from. * @param to The world to transfer players to. */ - public List>> + public CompletableFuture>[] transferFromWorldTo(@NotNull LoadedMultiverseWorld from, @NotNull World to) { return transferAllFromWorldToLocation(from, to.getSpawnLocation()); } @@ -70,11 +70,11 @@ public class PlayerWorldTeleporter { * @param location The location to transfer players to. * @return A list of futures that represent the teleportation of each player. */ - public List>> + public CompletableFuture>[] transferAllFromWorldToLocation(@NotNull LoadedMultiverseWorld world, @NotNull Location location) { return world.getPlayers() .map(players -> safetyTeleporter.teleport(players, location)) - .getOrElse(Collections.emptyList()); + .getOrElse(new CompletableFuture[0]); } /** @@ -83,7 +83,7 @@ public class PlayerWorldTeleporter { * @param players The players to teleport. * @param world The world to teleport players to. */ - public List>> + public CompletableFuture>[] teleportPlayersToWorld(@NotNull List players, @NotNull LoadedMultiverseWorld world) { Location spawnLocation = world.getSpawnLocation(); return safetyTeleporter.teleport(players, spawnLocation); diff --git a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java b/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java index 27824c3b..9bbb3daa 100644 --- a/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java +++ b/src/main/java/org/mvplugins/multiverse/core/worldnew/options/UnloadWorldOptions.java @@ -18,7 +18,6 @@ public class UnloadWorldOptions { } private final LoadedMultiverseWorld world; - private boolean removePlayers = false; private boolean saveBukkitWorld = true; UnloadWorldOptions(LoadedMultiverseWorld world) { @@ -34,26 +33,6 @@ public class UnloadWorldOptions { return world; } - /** - * Sets whether to teleport the players out from the world before unloading. - * - * @param removePlayersInput Whether to remove players from the world before unloading. - * @return This {@link UnloadWorldOptions} instance. - */ - public UnloadWorldOptions removePlayers(boolean removePlayersInput) { - this.removePlayers = removePlayersInput; - return this; - } - - /** - * Gets whether to teleport the players out from the world before unloading. - * - * @return Whether to remove players from the world before unloading. - */ - public boolean removePlayers() { - return removePlayers; - } - /** * Sets whether to save the bukkit world before unloading. *