diff --git a/plugin/src/main/java/com/alttd/essentia/EssentiaPlugin.java b/plugin/src/main/java/com/alttd/essentia/EssentiaPlugin.java index 8193334..d0e29cd 100644 --- a/plugin/src/main/java/com/alttd/essentia/EssentiaPlugin.java +++ b/plugin/src/main/java/com/alttd/essentia/EssentiaPlugin.java @@ -58,7 +58,7 @@ public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI { } void loadCommands() { - Reflections reflections = new Reflections("com.alttd.essentia.commands"); + Reflections reflections = new Reflections("com.alttd.essentia.commands.list"); Set> subTypes = reflections.get(Scanners.SubTypes.of(EssentiaCommand.class).asClass()); LifecycleEventManager manager = this.getLifecycleManager(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/EssentiaCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/EssentiaCommand.java index f6c2394..a9c93fa 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/EssentiaCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/EssentiaCommand.java @@ -9,6 +9,8 @@ import java.util.List; // TODO -- add optional -s -silent parameters to commands? public interface EssentiaCommand { + String commandName(); + @NotNull LiteralCommandNode command(); default String description() { @@ -19,4 +21,20 @@ public interface EssentiaCommand { return Collections.emptyList(); } + default String baseCommandPermission() { + return "essentia.command.player." + commandName(); + } + + default String baseOtherCommandPermission() { + return "essentia.command.player." + commandName() + "other"; + } + + default String adminCommandPermission() { + return "essentia.command.admin." + commandName(); + } + + default String adminOtherCommandPermission() { + return "essentia.command.admin." + commandName() + "other"; + } + } diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/BurnCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/BurnCommand.java index 1c1812c..e38e161 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/BurnCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/BurnCommand.java @@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull; public class BurnCommand implements EssentiaCommand { - static String commandName = "burn"; + @Override + public String commandName() { + return "burn"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -33,7 +36,7 @@ public class BurnCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/ClearInventoryCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/ClearInventoryCommand.java index 360bf46..141530a 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/ClearInventoryCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/ClearInventoryCommand.java @@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull; public class ClearInventoryCommand implements EssentiaCommand { - static String commandName = "clearinventory"; + @Override + public String commandName() { + return "clearinventory"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -34,7 +37,7 @@ public class ClearInventoryCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/CuffCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/CuffCommand.java index ba42c0f..2fdb88f 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/CuffCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/CuffCommand.java @@ -19,18 +19,21 @@ import org.jetbrains.annotations.NotNull; public class CuffCommand implements EssentiaCommand { - static String commandName = "cuff"; + @Override + public String commandName() { + return "cuff"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/EnchantCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/EnchantCommand.java index a54a490..eedeb76 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/EnchantCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/EnchantCommand.java @@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull; public class EnchantCommand implements EssentiaCommand { - static String commandName = "enchant"; + @Override + public String commandName() { + return "enchant"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .then( Commands.argument("enchantment", new EnchantmentArgument()) @@ -51,7 +54,7 @@ public class EnchantCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/EssentiaAdminCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/EssentiaAdminCommand.java index 08bdbb5..15a055e 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/EssentiaAdminCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/EssentiaAdminCommand.java @@ -10,11 +10,16 @@ import org.jetbrains.annotations.NotNull; public class EssentiaAdminCommand implements EssentiaCommand { + @Override + public String commandName() { + return "essentiareload"; + } + @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal("essentia") - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin.reload")) + Commands.literal(commandName()) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())) .executes((commandContext -> 1)) .then( Commands.literal("reload") diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/FeedCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/FeedCommand.java index b83fc3c..1b2cd3c 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/FeedCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/FeedCommand.java @@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull; public class FeedCommand implements EssentiaCommand { - static String commandName = "feed"; + @Override + public String commandName() { + return "feed"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -34,7 +37,7 @@ public class FeedCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/FlyCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/FlyCommand.java index c739998..4aa54b1 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/FlyCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/FlyCommand.java @@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull; public class FlyCommand implements EssentiaCommand { - static String commandName = "fly"; + @Override + public String commandName() { + return "fly"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -38,7 +41,7 @@ public class FlyCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/FlySpeedCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/FlySpeedCommand.java index cb15131..bd53ee7 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/FlySpeedCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/FlySpeedCommand.java @@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull; public class FlySpeedCommand implements EssentiaCommand { - static String commandName = "flyspeed"; + @Override + public String commandName() { + return "flyspeed"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ).then( Commands.argument("speed", FloatArgumentType.floatArg(-1, 1)) .executes((source) -> { @@ -39,7 +42,7 @@ public class FlySpeedCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/GameModeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/GameModeCommand.java index bc02ba3..19e2ec5 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/GameModeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/GameModeCommand.java @@ -17,14 +17,17 @@ import org.jetbrains.annotations.NotNull; public class GameModeCommand implements EssentiaCommand { - static String commandName = "gamemode"; + @Override + public String commandName() { + return "gamemode"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .then( Commands.argument("gamemode", ArgumentTypes.gameMode()) @@ -38,7 +41,7 @@ public class GameModeCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/GodCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/GodCommand.java index 318d7e9..6c2a87a 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/GodCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/GodCommand.java @@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull; public class GodCommand implements EssentiaCommand { - static String commandName = "god"; + @Override + public String commandName() { + return "god"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -38,7 +41,7 @@ public class GodCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/HealCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/HealCommand.java index 6bd4bd5..f26be24 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/HealCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/HealCommand.java @@ -14,17 +14,19 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -public class HealCommand - implements EssentiaCommand { +public class HealCommand implements EssentiaCommand { - static String commandName = "heal"; + @Override + public String commandName() { + return "heal"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -35,7 +37,7 @@ public class HealCommand }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/InfoCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/InfoCommand.java index c7845b7..6cf2713 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/InfoCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/InfoCommand.java @@ -15,14 +15,17 @@ import org.jetbrains.annotations.NotNull; public class InfoCommand implements EssentiaCommand { - static String commandName = "info"; + @Override + public String commandName() { + return "info"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -32,7 +35,7 @@ public class InfoCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerTimeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerTimeCommand.java index a6b97f3..e68387f 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerTimeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerTimeCommand.java @@ -13,14 +13,17 @@ import java.util.List; // TODO -- output messages public class PlayerTimeCommand implements EssentiaCommand { - static String commandName = "playertime"; + @Override + public String commandName() { + return "playertime"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerWeatherCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerWeatherCommand.java index 67e5c42..3333e9c 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerWeatherCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/PlayerWeatherCommand.java @@ -18,14 +18,17 @@ import java.util.List; // TODO -- output messages public class PlayerWeatherCommand implements EssentiaCommand { - static String commandName = "playerweather"; + @Override + public String commandName() { + return "playerweather"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( @@ -49,7 +52,7 @@ public class PlayerWeatherCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes(commandContext -> { CommandSourceStack sourceStack = commandContext.getSource(); Player target = commandContext.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/SetSpawnCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/SetSpawnCommand.java index 3220c9a..4be8e14 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/SetSpawnCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/SetSpawnCommand.java @@ -13,14 +13,17 @@ import org.jetbrains.annotations.NotNull; public class SetSpawnCommand implements EssentiaCommand { - static String commandName = "setspawn"; + @Override + public String commandName() { + return "setspawn"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/SmiteCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/SmiteCommand.java index 65c340a..8a709c1 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/SmiteCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/SmiteCommand.java @@ -18,14 +18,17 @@ import java.util.List; public class SmiteCommand implements EssentiaCommand { - static String commandName = "smite"; + @Override + public String commandName() { + return "smite"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -35,7 +38,7 @@ public class SmiteCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportCommand.java index ab3203b..acf5781 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportCommand.java @@ -14,19 +14,22 @@ import java.util.List; public class TeleportCommand implements EssentiaCommand { - static String commandName = "teleport"; + @Override + public String commandName() { + return "teleport"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportHereCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportHereCommand.java index 2ef2358..3a14220 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportHereCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportHereCommand.java @@ -14,19 +14,22 @@ import java.util.List; public class TeleportHereCommand implements EssentiaCommand { - static String commandName = "teleporthere"; + @Override + public String commandName() { + return "teleporthere"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportPositionCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportPositionCommand.java index 1fb35db..3619e37 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportPositionCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/TeleportPositionCommand.java @@ -16,14 +16,17 @@ import java.util.List; public class TeleportPositionCommand implements EssentiaCommand { - static String commandName = "teleportposition"; + @Override + public String commandName() { + return "teleportposition"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( @@ -39,7 +42,7 @@ public class TeleportPositionCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { if (!(source.getSource().getSender() instanceof Player player)) return 1; diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/TimeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/TimeCommand.java index b483385..61d51aa 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/TimeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/TimeCommand.java @@ -12,14 +12,17 @@ import org.jetbrains.annotations.NotNull; // TODO -- output messages public class TimeCommand implements EssentiaCommand { - static String commandName = "time"; + @Override + public String commandName() { + return "time"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/UnCuffCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/UnCuffCommand.java index caa4553..68e4327 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/UnCuffCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/UnCuffCommand.java @@ -19,18 +19,21 @@ import org.jetbrains.annotations.NotNull; public class UnCuffCommand implements EssentiaCommand { - static String commandName = "uncuff"; + @Override + public String commandName() { + return "uncuff"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/WalkSpeedCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/WalkSpeedCommand.java index f1bc5b2..18cbc33 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/WalkSpeedCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/WalkSpeedCommand.java @@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull; public class WalkSpeedCommand implements EssentiaCommand { - static String commandName = "walkspeed"; + @Override + public String commandName() { + return "walkspeed"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ).then( Commands.argument("speed", FloatArgumentType.floatArg(-1, 1)) .executes((source) -> { @@ -39,7 +42,7 @@ public class WalkSpeedCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/WeatherCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/WeatherCommand.java index a69cd17..c52fea0 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/WeatherCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/WeatherCommand.java @@ -20,14 +20,17 @@ import java.util.Random; // TODO -- output messages public class WeatherCommand implements EssentiaCommand { - static String commandName = "weather"; + @Override + public String commandName() { + return "weather"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( diff --git a/plugin/src/main/java/com/alttd/essentia/commands/admin/WorkBenchCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/admin/WorkBenchCommand.java index 749a8d8..5592c46 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/admin/WorkBenchCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/admin/WorkBenchCommand.java @@ -17,14 +17,17 @@ import java.util.List; public class WorkBenchCommand implements EssentiaCommand { - static String commandName = "workbench"; + @Override + public String commandName() { + return "workbench"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -34,7 +37,7 @@ public class WorkBenchCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/BackCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/BackCommand.java index 0f5b8cd..ac9e5c2 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/BackCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/BackCommand.java @@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull; public class BackCommand implements EssentiaCommand { - static String commandName = "back"; + @Override + public String commandName() { + return "back"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/DeathBackCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/DeathBackCommand.java index 50a965e..e65fdb6 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/DeathBackCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/DeathBackCommand.java @@ -20,14 +20,17 @@ import java.util.List; public class DeathBackCommand implements EssentiaCommand { - static String commandName = "deathback"; + @Override + public String commandName() { + return "deathback"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/DelHomeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/DelHomeCommand.java index 286a2b1..b68a620 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/DelHomeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/DelHomeCommand.java @@ -23,14 +23,17 @@ import java.util.Collection; public class DelHomeCommand implements EssentiaCommand { - static String commandName = "delhome"; + @Override + public String commandName() { + return "delhome"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -70,7 +73,7 @@ public class DelHomeCommand implements EssentiaCommand { ) .then( Commands.argument("player", new OfflinePlayerArgument()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .then( Commands.argument("home", StringArgumentType.word()) .suggests((context, suggestionsBuilder) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/DisposeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/DisposeCommand.java index 2f1d256..9b883a2 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/DisposeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/DisposeCommand.java @@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull; public class DisposeCommand implements EssentiaCommand { - static String commandName = "dispose"; + @Override + public String commandName() { + return "dispose"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -35,7 +38,7 @@ public class DisposeCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/HomeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/HomeCommand.java index 0430450..bcf76c5 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/HomeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/HomeCommand.java @@ -26,14 +26,17 @@ import java.util.Collection; // TODO - home other public class HomeCommand implements EssentiaCommand { - static String commandName = "home"; + @Override + public String commandName() { + return "home"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/HomeListCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/HomeListCommand.java index 6bc4972..73b2fab 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/HomeListCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/HomeListCommand.java @@ -19,14 +19,17 @@ import java.util.List; public class HomeListCommand implements EssentiaCommand { - static String commandName = "homelist"; + @Override + public String commandName() { + return "homelist"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -36,7 +39,7 @@ public class HomeListCommand implements EssentiaCommand { }) .then( Commands.argument("player", new OfflinePlayerCompletingArgument()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { OfflinePlayer target = source.getArgument("player", OfflinePlayer.class); execute(source.getSource().getSender(), target); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/SetHomeCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/SetHomeCommand.java index b2dff7c..ea94f50 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/SetHomeCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/SetHomeCommand.java @@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull; public class SetHomeCommand implements EssentiaCommand { - static String commandName = "sethome"; + @Override + public String commandName() { + return "sethome"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { @@ -49,7 +52,7 @@ public class SetHomeCommand implements EssentiaCommand { ) .then( Commands.argument("player", new OfflinePlayerArgument()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .then( Commands.argument("name", StringArgumentType.word()) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/SpawnCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/SpawnCommand.java index e47feed..ea17c0b 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/SpawnCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/SpawnCommand.java @@ -21,14 +21,17 @@ import org.jetbrains.annotations.NotNull; public class SpawnCommand implements EssentiaCommand { - static String commandName = "spawn"; + @Override + public String commandName() { + return "spawn"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -38,7 +41,7 @@ public class SpawnCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportAcceptCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportAcceptCommand.java index adc16f7..0aa5674 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportAcceptCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportAcceptCommand.java @@ -16,14 +16,17 @@ import java.util.List; public class TeleportAcceptCommand implements EssentiaCommand { - static String commandName = "teleportaccept"; + @Override + public String commandName() { + return "teleportaccept"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportDenyCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportDenyCommand.java index 9986353..2349313 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportDenyCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportDenyCommand.java @@ -16,14 +16,17 @@ import java.util.List; public class TeleportDenyCommand implements EssentiaCommand { - static String commandName = "teleportdeny"; + @Override + public String commandName() { + return "teleportdeny"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .executes((source) -> { diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestCommand.java index 9eccdb9..e73a4fb 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestCommand.java @@ -20,19 +20,22 @@ import java.util.List; public class TeleportRequestCommand implements EssentiaCommand { - static String commandName = "teleportrequesthere"; + @Override + public String commandName() { + return "teleportrequesthere"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { if (!(source.getSource().getSender() instanceof Player player)) return 1; diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestHereCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestHereCommand.java index bc310a7..f1bdf45 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestHereCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportRequestHereCommand.java @@ -20,19 +20,22 @@ import java.util.List; public class TeleportRequestHereCommand implements EssentiaCommand { - static String commandName = "teleportrequesthere"; + @Override + public String commandName() { + return "teleportrequesthere"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) && commandSourceStack.getSender() instanceof Player ) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { if (!(source.getSource().getSender() instanceof Player player)) return 1; diff --git a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportToggleCommand.java b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportToggleCommand.java index b125e76..44ac045 100644 --- a/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportToggleCommand.java +++ b/plugin/src/main/java/com/alttd/essentia/commands/player/TeleportToggleCommand.java @@ -21,14 +21,17 @@ import java.util.List; public class TeleportToggleCommand implements EssentiaCommand { - static String commandName = "teleporttoggle"; + @Override + public String commandName() { + return "teleporttoggle"; + } @Override public @NotNull LiteralCommandNode command() { final LiteralArgumentBuilder builder = - Commands.literal(commandName) + Commands.literal(commandName()) .requires( - commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) + commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) ) .executes((source) -> { if (source.getSource().getSender() instanceof Player player) @@ -38,7 +41,7 @@ public class TeleportToggleCommand implements EssentiaCommand { }) .then( Commands.argument("player", ArgumentTypes.player()) - .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) + .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission())) .executes((source) -> { CommandSourceStack sourceStack = source.getSource(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();