Move command permissions to EssentiaCommand interface.

This commit is contained in:
Len 2024-10-04 17:38:40 +02:00
parent 162ffd3599
commit dbb3f45898
39 changed files with 270 additions and 140 deletions

View File

@ -58,7 +58,7 @@ public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI {
} }
void loadCommands() { void loadCommands() {
Reflections reflections = new Reflections("com.alttd.essentia.commands"); Reflections reflections = new Reflections("com.alttd.essentia.commands.list");
Set<Class<?>> subTypes = reflections.get(Scanners.SubTypes.of(EssentiaCommand.class).asClass()); Set<Class<?>> subTypes = reflections.get(Scanners.SubTypes.of(EssentiaCommand.class).asClass());
LifecycleEventManager<Plugin> manager = this.getLifecycleManager(); LifecycleEventManager<Plugin> manager = this.getLifecycleManager();

View File

@ -9,6 +9,8 @@ import java.util.List;
// TODO -- add optional -s -silent parameters to commands? // TODO -- add optional -s -silent parameters to commands?
public interface EssentiaCommand { public interface EssentiaCommand {
String commandName();
@NotNull LiteralCommandNode<CommandSourceStack> command(); @NotNull LiteralCommandNode<CommandSourceStack> command();
default String description() { default String description() {
@ -19,4 +21,20 @@ public interface EssentiaCommand {
return Collections.emptyList(); 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";
}
} }

View File

@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull;
public class BurnCommand implements EssentiaCommand { public class BurnCommand implements EssentiaCommand {
static String commandName = "burn"; @Override
public String commandName() {
return "burn";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -33,7 +36,7 @@ public class BurnCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull;
public class ClearInventoryCommand implements EssentiaCommand { public class ClearInventoryCommand implements EssentiaCommand {
static String commandName = "clearinventory"; @Override
public String commandName() {
return "clearinventory";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -34,7 +37,7 @@ public class ClearInventoryCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -19,18 +19,21 @@ import org.jetbrains.annotations.NotNull;
public class CuffCommand implements EssentiaCommand { public class CuffCommand implements EssentiaCommand {
static String commandName = "cuff"; @Override
public String commandName() {
return "cuff";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull;
public class EnchantCommand implements EssentiaCommand { public class EnchantCommand implements EssentiaCommand {
static String commandName = "enchant"; @Override
public String commandName() {
return "enchant";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.then( .then(
Commands.argument("enchantment", new EnchantmentArgument()) Commands.argument("enchantment", new EnchantmentArgument())
@ -51,7 +54,7 @@ public class EnchantCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -10,11 +10,16 @@ import org.jetbrains.annotations.NotNull;
public class EssentiaAdminCommand implements EssentiaCommand { public class EssentiaAdminCommand implements EssentiaCommand {
@Override
public String commandName() {
return "essentiareload";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal("essentia") Commands.literal(commandName())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin.reload")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()))
.executes((commandContext -> 1)) .executes((commandContext -> 1))
.then( .then(
Commands.literal("reload") Commands.literal("reload")

View File

@ -16,14 +16,17 @@ import org.jetbrains.annotations.NotNull;
public class FeedCommand implements EssentiaCommand { public class FeedCommand implements EssentiaCommand {
static String commandName = "feed"; @Override
public String commandName() {
return "feed";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -34,7 +37,7 @@ public class FeedCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull;
public class FlyCommand implements EssentiaCommand { public class FlyCommand implements EssentiaCommand {
static String commandName = "fly"; @Override
public String commandName() {
return "fly";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -38,7 +41,7 @@ public class FlyCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull;
public class FlySpeedCommand implements EssentiaCommand { public class FlySpeedCommand implements EssentiaCommand {
static String commandName = "flyspeed"; @Override
public String commandName() {
return "flyspeed";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
).then( ).then(
Commands.argument("speed", FloatArgumentType.floatArg(-1, 1)) Commands.argument("speed", FloatArgumentType.floatArg(-1, 1))
.executes((source) -> { .executes((source) -> {
@ -39,7 +42,7 @@ public class FlySpeedCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -17,14 +17,17 @@ import org.jetbrains.annotations.NotNull;
public class GameModeCommand implements EssentiaCommand { public class GameModeCommand implements EssentiaCommand {
static String commandName = "gamemode"; @Override
public String commandName() {
return "gamemode";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.then( .then(
Commands.argument("gamemode", ArgumentTypes.gameMode()) Commands.argument("gamemode", ArgumentTypes.gameMode())
@ -38,7 +41,7 @@ public class GameModeCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull;
public class GodCommand implements EssentiaCommand { public class GodCommand implements EssentiaCommand {
static String commandName = "god"; @Override
public String commandName() {
return "god";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -38,7 +41,7 @@ public class GodCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -14,17 +14,19 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class HealCommand public class HealCommand implements EssentiaCommand {
implements EssentiaCommand {
static String commandName = "heal"; @Override
public String commandName() {
return "heal";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -35,7 +37,7 @@ public class HealCommand
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -15,14 +15,17 @@ import org.jetbrains.annotations.NotNull;
public class InfoCommand implements EssentiaCommand { public class InfoCommand implements EssentiaCommand {
static String commandName = "info"; @Override
public String commandName() {
return "info";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -32,7 +35,7 @@ public class InfoCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -13,14 +13,17 @@ import java.util.List;
// TODO -- output messages // TODO -- output messages
public class PlayerTimeCommand implements EssentiaCommand { public class PlayerTimeCommand implements EssentiaCommand {
static String commandName = "playertime"; @Override
public String commandName() {
return "playertime";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(

View File

@ -18,14 +18,17 @@ import java.util.List;
// TODO -- output messages // TODO -- output messages
public class PlayerWeatherCommand implements EssentiaCommand { public class PlayerWeatherCommand implements EssentiaCommand {
static String commandName = "playerweather"; @Override
public String commandName() {
return "playerweather";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
@ -49,7 +52,7 @@ public class PlayerWeatherCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes(commandContext -> { .executes(commandContext -> {
CommandSourceStack sourceStack = commandContext.getSource(); CommandSourceStack sourceStack = commandContext.getSource();
Player target = commandContext.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = commandContext.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -13,14 +13,17 @@ import org.jetbrains.annotations.NotNull;
public class SetSpawnCommand implements EssentiaCommand { public class SetSpawnCommand implements EssentiaCommand {
static String commandName = "setspawn"; @Override
public String commandName() {
return "setspawn";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -18,14 +18,17 @@ import java.util.List;
public class SmiteCommand implements EssentiaCommand { public class SmiteCommand implements EssentiaCommand {
static String commandName = "smite"; @Override
public String commandName() {
return "smite";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -35,7 +38,7 @@ public class SmiteCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -14,19 +14,22 @@ import java.util.List;
public class TeleportCommand implements EssentiaCommand { public class TeleportCommand implements EssentiaCommand {
static String commandName = "teleport"; @Override
public String commandName() {
return "teleport";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -14,19 +14,22 @@ import java.util.List;
public class TeleportHereCommand implements EssentiaCommand { public class TeleportHereCommand implements EssentiaCommand {
static String commandName = "teleporthere"; @Override
public String commandName() {
return "teleporthere";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -16,14 +16,17 @@ import java.util.List;
public class TeleportPositionCommand implements EssentiaCommand { public class TeleportPositionCommand implements EssentiaCommand {
static String commandName = "teleportposition"; @Override
public String commandName() {
return "teleportposition";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
@ -39,7 +42,7 @@ public class TeleportPositionCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
if (!(source.getSource().getSender() instanceof Player player)) if (!(source.getSource().getSender() instanceof Player player))
return 1; return 1;

View File

@ -12,14 +12,17 @@ import org.jetbrains.annotations.NotNull;
// TODO -- output messages // TODO -- output messages
public class TimeCommand implements EssentiaCommand { public class TimeCommand implements EssentiaCommand {
static String commandName = "time"; @Override
public String commandName() {
return "time";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(

View File

@ -19,18 +19,21 @@ import org.jetbrains.annotations.NotNull;
public class UnCuffCommand implements EssentiaCommand { public class UnCuffCommand implements EssentiaCommand {
static String commandName = "uncuff"; @Override
public String commandName() {
return "uncuff";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull;
public class WalkSpeedCommand implements EssentiaCommand { public class WalkSpeedCommand implements EssentiaCommand {
static String commandName = "walkspeed"; @Override
public String commandName() {
return "walkspeed";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
).then( ).then(
Commands.argument("speed", FloatArgumentType.floatArg(-1, 1)) Commands.argument("speed", FloatArgumentType.floatArg(-1, 1))
.executes((source) -> { .executes((source) -> {
@ -39,7 +42,7 @@ public class WalkSpeedCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -20,14 +20,17 @@ import java.util.Random;
// TODO -- output messages // TODO -- output messages
public class WeatherCommand implements EssentiaCommand { public class WeatherCommand implements EssentiaCommand {
static String commandName = "weather"; @Override
public String commandName() {
return "weather";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(

View File

@ -17,14 +17,17 @@ import java.util.List;
public class WorkBenchCommand implements EssentiaCommand { public class WorkBenchCommand implements EssentiaCommand {
static String commandName = "workbench"; @Override
public String commandName() {
return "workbench";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -34,7 +37,7 @@ public class WorkBenchCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull;
public class BackCommand implements EssentiaCommand { public class BackCommand implements EssentiaCommand {
static String commandName = "back"; @Override
public String commandName() {
return "back";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -20,14 +20,17 @@ import java.util.List;
public class DeathBackCommand implements EssentiaCommand { public class DeathBackCommand implements EssentiaCommand {
static String commandName = "deathback"; @Override
public String commandName() {
return "deathback";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -23,14 +23,17 @@ import java.util.Collection;
public class DelHomeCommand implements EssentiaCommand { public class DelHomeCommand implements EssentiaCommand {
static String commandName = "delhome"; @Override
public String commandName() {
return "delhome";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -70,7 +73,7 @@ public class DelHomeCommand implements EssentiaCommand {
) )
.then( .then(
Commands.argument("player", new OfflinePlayerArgument()) Commands.argument("player", new OfflinePlayerArgument())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.then( .then(
Commands.argument("home", StringArgumentType.word()) Commands.argument("home", StringArgumentType.word())
.suggests((context, suggestionsBuilder) -> { .suggests((context, suggestionsBuilder) -> {

View File

@ -18,14 +18,17 @@ import org.jetbrains.annotations.NotNull;
public class DisposeCommand implements EssentiaCommand { public class DisposeCommand implements EssentiaCommand {
static String commandName = "dispose"; @Override
public String commandName() {
return "dispose";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -35,7 +38,7 @@ public class DisposeCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -26,14 +26,17 @@ import java.util.Collection;
// TODO - home other // TODO - home other
public class HomeCommand implements EssentiaCommand { public class HomeCommand implements EssentiaCommand {
static String commandName = "home"; @Override
public String commandName() {
return "home";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -19,14 +19,17 @@ import java.util.List;
public class HomeListCommand implements EssentiaCommand { public class HomeListCommand implements EssentiaCommand {
static String commandName = "homelist"; @Override
public String commandName() {
return "homelist";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -36,7 +39,7 @@ public class HomeListCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", new OfflinePlayerCompletingArgument()) Commands.argument("player", new OfflinePlayerCompletingArgument())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
OfflinePlayer target = source.getArgument("player", OfflinePlayer.class); OfflinePlayer target = source.getArgument("player", OfflinePlayer.class);
execute(source.getSource().getSender(), target); execute(source.getSource().getSender(), target);

View File

@ -20,14 +20,17 @@ import org.jetbrains.annotations.NotNull;
public class SetHomeCommand implements EssentiaCommand { public class SetHomeCommand implements EssentiaCommand {
static String commandName = "sethome"; @Override
public String commandName() {
return "sethome";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {
@ -49,7 +52,7 @@ public class SetHomeCommand implements EssentiaCommand {
) )
.then( .then(
Commands.argument("player", new OfflinePlayerArgument()) Commands.argument("player", new OfflinePlayerArgument())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.then( .then(
Commands.argument("name", StringArgumentType.word()) Commands.argument("name", StringArgumentType.word())
.executes((source) -> { .executes((source) -> {

View File

@ -21,14 +21,17 @@ import org.jetbrains.annotations.NotNull;
public class SpawnCommand implements EssentiaCommand { public class SpawnCommand implements EssentiaCommand {
static String commandName = "spawn"; @Override
public String commandName() {
return "spawn";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -38,7 +41,7 @@ public class SpawnCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();

View File

@ -16,14 +16,17 @@ import java.util.List;
public class TeleportAcceptCommand implements EssentiaCommand { public class TeleportAcceptCommand implements EssentiaCommand {
static String commandName = "teleportaccept"; @Override
public String commandName() {
return "teleportaccept";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -16,14 +16,17 @@ import java.util.List;
public class TeleportDenyCommand implements EssentiaCommand { public class TeleportDenyCommand implements EssentiaCommand {
static String commandName = "teleportdeny"; @Override
public String commandName() {
return "teleportdeny";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.executes((source) -> { .executes((source) -> {

View File

@ -20,19 +20,22 @@ import java.util.List;
public class TeleportRequestCommand implements EssentiaCommand { public class TeleportRequestCommand implements EssentiaCommand {
static String commandName = "teleportrequesthere"; @Override
public String commandName() {
return "teleportrequesthere";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
if (!(source.getSource().getSender() instanceof Player player)) if (!(source.getSource().getSender() instanceof Player player))
return 1; return 1;

View File

@ -20,19 +20,22 @@ import java.util.List;
public class TeleportRequestHereCommand implements EssentiaCommand { public class TeleportRequestHereCommand implements EssentiaCommand {
static String commandName = "teleportrequesthere"; @Override
public String commandName() {
return "teleportrequesthere";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) && commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission()) &&
commandSourceStack.getSender() instanceof Player commandSourceStack.getSender() instanceof Player
) )
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
if (!(source.getSource().getSender() instanceof Player player)) if (!(source.getSource().getSender() instanceof Player player))
return 1; return 1;

View File

@ -21,14 +21,17 @@ import java.util.List;
public class TeleportToggleCommand implements EssentiaCommand { public class TeleportToggleCommand implements EssentiaCommand {
static String commandName = "teleporttoggle"; @Override
public String commandName() {
return "teleporttoggle";
}
@Override @Override
public @NotNull LiteralCommandNode<CommandSourceStack> command() { public @NotNull LiteralCommandNode<CommandSourceStack> command() {
final LiteralArgumentBuilder<CommandSourceStack> builder = final LiteralArgumentBuilder<CommandSourceStack> builder =
Commands.literal(commandName) Commands.literal(commandName())
.requires( .requires(
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) commandSourceStack -> commandSourceStack.getSender().hasPermission(baseCommandPermission())
) )
.executes((source) -> { .executes((source) -> {
if (source.getSource().getSender() instanceof Player player) if (source.getSource().getSender() instanceof Player player)
@ -38,7 +41,7 @@ public class TeleportToggleCommand implements EssentiaCommand {
}) })
.then( .then(
Commands.argument("player", ArgumentTypes.player()) Commands.argument("player", ArgumentTypes.player())
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other")) .requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(baseOtherCommandPermission()))
.executes((source) -> { .executes((source) -> {
CommandSourceStack sourceStack = source.getSource(); CommandSourceStack sourceStack = source.getSource();
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst(); Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();