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 ac3448b7..97ff11e6 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java @@ -1,14 +1,9 @@ package org.mvplugins.multiverse.core.commands; import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.CommandIssuer; 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.Description; -import co.aikar.commands.annotation.Flags; -import co.aikar.commands.annotation.Subcommand; -import co.aikar.commands.annotation.Syntax; +import co.aikar.commands.annotation.*; import com.dumptruckman.minecraft.util.Logging; import jakarta.inject.Inject; import org.bukkit.entity.Player; @@ -39,7 +34,6 @@ class SpawnCommand extends MultiverseCommand { @CommandAlias("mvspawn") @Subcommand("spawn") - @CommandPermission("multiverse.core.spawn") @CommandCompletion("@players") @Syntax("[player]") @Description("{@@mv-core.spawn.description}") @@ -50,12 +44,17 @@ class SpawnCommand extends MultiverseCommand { @Syntax("[player]") @Description("{@@mv-core.spawn.player.description}") Player player) { - // TODO: Check for relevant self/others teleport permissions + // TODO: Better handling of permission checking with CorePermissionsChecker + String permission = player.equals(issuer.getPlayer()) ? "multiverse.core.spawn.self" : "multiverse.core.spawn.other"; + if (!issuer.hasPermission(permission)) { + issuer.sendMessage("You do not have permission to use this command!"); + return; + } - // The player is in the world, so it must be loaded - LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld().getName()).getOrNull(); + LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld()).getOrNull(); if (world == null) { issuer.sendMessage("The world the player you are trying to teleport is in, is not a multiverse world"); + return; } // Teleport the player @@ -89,4 +88,10 @@ class SpawnCommand extends MultiverseCommand { } return issuer.getIssuer().getName(); } + + @Override + public boolean hasPermission(CommandIssuer issuer) { + // TODO: Fix autocomplete showing even if the player doesn't have permission + return issuer.hasPermission("multiverse.core.spawn.self") || issuer.hasPermission("multiverse.core.spawn.other"); + } }