diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/SetSpawnCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/SetSpawnCommand.java index 93e288a3..41defdcf 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/SetSpawnCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/SetSpawnCommand.java @@ -13,11 +13,9 @@ import jakarta.inject.Inject; import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import org.jvnet.hk2.annotations.Service; -import org.mvplugins.multiverse.core.api.BlockSafety; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; -import org.mvplugins.multiverse.core.world.WorldManager; @Service @CommandAlias("mv") @@ -28,6 +26,7 @@ public class SetSpawnCommand extends MultiverseCommand { super(commandManager); } + @CommandAlias("mvsetspawn") @Subcommand("setspawn") @CommandPermission("multiverse.core.setspawn") @CommandCompletion("@nothing @mvworlds:scope=loaded ") // TODO: Use Brigadier to show above in chat like the vanilla TP command @@ -46,9 +45,7 @@ public class SetSpawnCommand extends MultiverseCommand { @Flags("resolve=issuerAware") @Syntax("") @Description("{@@mv-core.setspawn.world.description}") - LoadedMultiverseWorld world - ) { - + LoadedMultiverseWorld world) { // TODO: Use a flag to do this, no clue how to edit an inbuilt ACF flag though // Get the Location if (location == null) { diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java index ceafc938..ac3448b7 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java @@ -14,6 +14,7 @@ import jakarta.inject.Inject; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; 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.teleportation.AsyncSafetyTeleporter; @@ -36,36 +37,45 @@ class SpawnCommand extends MultiverseCommand { this.safetyTeleporter = safetyTeleporter; } + @CommandAlias("mvspawn") @Subcommand("spawn") @CommandPermission("multiverse.core.spawn") @CommandCompletion("@players") @Syntax("[player]") @Description("{@@mv-core.spawn.description}") void onSpawnTpCommand( - BukkitCommandIssuer issuer, + MVCommandIssuer issuer, @Flags("resolve=issuerAware") @Syntax("[player]") @Description("{@@mv-core.spawn.player.description}") - Player player - ) { + Player player) { + // TODO: Check for relevant self/others teleport permissions + // The player is in the world, so it must be loaded LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld().getName()).getOrNull(); if (world == null) { issuer.sendMessage("The world the player you are trying to teleport is in, is not a multiverse world"); } - // TODO: Log when the player cannot be teleported there. No clue how to detect that // Teleport the player - safetyTeleporter.teleportSafely(issuer.getIssuer(), player, world.getSpawnLocation()); - - player.sendMessage(commandManager.formatMessage( - issuer, - MessageType.INFO, - MVCorei18n.SPAWN_MESSAGE, - "{teleporter}", - getTeleporterName(issuer, player) - )); + // TODO: Different message for teleporting self vs others + safetyTeleporter.teleportSafely(issuer.getIssuer(), player, world.getSpawnLocation()) + .onSuccess(() -> player.sendMessage(commandManager.formatMessage( + issuer, + MessageType.INFO, + MVCorei18n.SPAWN_SUCCESS, + "{teleporter}", + getTeleporterName(issuer, player) + ))) + .onFailure(failure -> { + issuer.sendError( + MVCorei18n.SPAWN_FAILED, + "{teleporter}", + getTeleporterName(issuer, player) + ); + issuer.sendError(failure.getFailureMessage()); + }); Logging.fine("Teleported " + player.getName() + " to " + world.getSpawnLocation().getX() + ", " + world.getSpawnLocation().getY() + ", " + world.getSpawnLocation().getZ()); } diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java index e24acf1e..2707a2ce 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java @@ -97,7 +97,8 @@ public enum MVCorei18n implements MessageKeyProvider { // spawn tp command SPAWN_DESCRIPTION, SPAWN_PLAYER_DESCRIPTION, - SPAWN_MESSAGE, + SPAWN_SUCCESS, + SPAWN_FAILED, SPAWN_CONSOLENAME, SPAWN_YOU, diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties index 06146827..9df2939d 100644 --- a/src/main/resources/multiverse-core_en.properties +++ b/src/main/resources/multiverse-core_en.properties @@ -131,6 +131,11 @@ mv-core.spawn.message={teleporter} just sent you to spawn! mv-core.spawn.consolename=The console mv-core.spawn.you=You +# /mv setspawn +mv-core.setspawn.description=Sets the spawn location of the specified world +mv-core.setspawn.location.description=Location of the new spawn +mv-core.setspawn.world.description=Target world to set spawn of (defaults to player's current world) + # /mv tp mv-core.teleport.description=Allows you to teleport to a location on your server! mv-core.teleport.player.description=Target player to teleport.