mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Proper spawn permission checking
This commit is contained in:
parent
1ec4e4b8f0
commit
f00e2964f3
@ -1,14 +1,9 @@
|
|||||||
package org.mvplugins.multiverse.core.commands;
|
package org.mvplugins.multiverse.core.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BukkitCommandIssuer;
|
import co.aikar.commands.BukkitCommandIssuer;
|
||||||
|
import co.aikar.commands.CommandIssuer;
|
||||||
import co.aikar.commands.MessageType;
|
import co.aikar.commands.MessageType;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import co.aikar.commands.annotation.*;
|
||||||
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 com.dumptruckman.minecraft.util.Logging;
|
import com.dumptruckman.minecraft.util.Logging;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -39,7 +34,6 @@ class SpawnCommand extends MultiverseCommand {
|
|||||||
|
|
||||||
@CommandAlias("mvspawn")
|
@CommandAlias("mvspawn")
|
||||||
@Subcommand("spawn")
|
@Subcommand("spawn")
|
||||||
@CommandPermission("multiverse.core.spawn")
|
|
||||||
@CommandCompletion("@players")
|
@CommandCompletion("@players")
|
||||||
@Syntax("[player]")
|
@Syntax("[player]")
|
||||||
@Description("{@@mv-core.spawn.description}")
|
@Description("{@@mv-core.spawn.description}")
|
||||||
@ -50,12 +44,17 @@ class SpawnCommand extends MultiverseCommand {
|
|||||||
@Syntax("[player]")
|
@Syntax("[player]")
|
||||||
@Description("{@@mv-core.spawn.player.description}")
|
@Description("{@@mv-core.spawn.player.description}")
|
||||||
Player player) {
|
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()).getOrNull();
|
||||||
LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld().getName()).getOrNull();
|
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
issuer.sendMessage("The world the player you are trying to teleport is in, is not a multiverse world");
|
issuer.sendMessage("The world the player you are trying to teleport is in, is not a multiverse world");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teleport the player
|
// Teleport the player
|
||||||
@ -89,4 +88,10 @@ class SpawnCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
return issuer.getIssuer().getName();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user