add permissions

This commit is contained in:
2025-11-22 16:22:22 +01:00
parent e6eefc995b
commit 2cb756a7fd
2 changed files with 15 additions and 1 deletions
@@ -2,14 +2,28 @@ package me.youhavetrouble.standin;
import me.youhavetrouble.standin.stand.StandinInteractionListener; import me.youhavetrouble.standin.stand.StandinInteractionListener;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
@SuppressWarnings("UnstableApiUsage")
public final class StandIn extends JavaPlugin { public final class StandIn extends JavaPlugin {
public static final NamespacedKey KEY = new NamespacedKey("stand-in", "stand-in"); public static final NamespacedKey KEY = new NamespacedKey("stand-in", "stand-in");
@Override @Override
public void onEnable() { public void onEnable() {
getServer().getPluginManager().addPermissions(
List.of(
new Permission("standin.edit.armor_stand", PermissionDefault.OP),
new Permission("standin.edit.mannequin", PermissionDefault.OP)
)
);
getServer().getPluginManager().registerEvents(new StandinInteractionListener(), this); getServer().getPluginManager().registerEvents(new StandinInteractionListener(), this);
} }
@@ -21,7 +21,7 @@ public class StandinInteractionListener implements Listener {
if (entity == null) return false; if (entity == null) return false;
if (!player.isOnline()) return false; if (!player.isOnline()) return false;
if (entity instanceof ArmorStand armorStand) { if (entity instanceof ArmorStand armorStand && player.hasPermission("standin.edit.armor_stand")) {
StandinDialog.openArmorStandDialog(player, armorStand); StandinDialog.openArmorStandDialog(player, armorStand);
return true; return true;
} }