Compare commits
9 Commits
ff2824f287
...
4dba5f3c41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dba5f3c41 | ||
|
|
dbb3f45898 | ||
|
|
162ffd3599 | ||
|
|
430e6fb898 | ||
|
|
aede22811a | ||
|
|
a8221a68af | ||
|
|
29559b83c4 | ||
|
|
be8b7e20df | ||
|
|
6a8e21852c |
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
import com.alttd.essentia.commands.argumement.GameModeArgument;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
|
@ -18,17 +17,20 @@ 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", new GameModeArgument())
|
Commands.argument("gamemode", ArgumentTypes.gameMode())
|
||||||
.executes((source) -> {
|
.executes((source) -> {
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
if (!(source.getSource().getSender() instanceof Player player))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -39,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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// TODO -- output messages
|
||||||
|
public class PlayerTimeCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "playertime";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(
|
||||||
|
commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
|
||||||
|
commandSourceStack.getSender() instanceof Player
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("freeze")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, player.getPlayerTime());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("unfreeze")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
reset(player);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("day")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 1000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("noon")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 6000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("night")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 13000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("midnight")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 18000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(Player player) {
|
||||||
|
player.resetPlayerTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTime(Player player, long time) {
|
||||||
|
player.setPlayerTime(time, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> aliases() {
|
||||||
|
return List.of("ptime");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.alttd.essentia.commands.argumement.WeatherArgument;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||||
|
import org.bukkit.WeatherType;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// TODO -- output messages
|
||||||
|
public class PlayerWeatherCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "playerweather";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(
|
||||||
|
commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
|
||||||
|
commandSourceStack.getSender() instanceof Player
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("reset")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
resetWeather(player);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.argument("weather", new WeatherArgument())
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (!(commandContext.getSource().getSender() instanceof Player player))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
WeatherType weatherType = commandContext.getArgument("weather", WeatherType.class);
|
||||||
|
execute(commandContext.getSource().getSender(), player, weatherType);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
Commands.argument("player", ArgumentTypes.player())
|
||||||
|
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
|
||||||
|
.executes(commandContext -> {
|
||||||
|
CommandSourceStack sourceStack = commandContext.getSource();
|
||||||
|
Player target = commandContext.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();
|
||||||
|
WeatherType weatherType = commandContext.getArgument("weather", WeatherType.class);
|
||||||
|
execute(commandContext.getSource().getSender(), target, weatherType);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sender, Player target, WeatherType weatherType) {
|
||||||
|
target.setPlayerWeather(weatherType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetWeather(Player player) {
|
||||||
|
player.resetPlayerWeather();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> aliases() {
|
||||||
|
return List.of("pweather");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.alttd.essentia.commands.argumement.EquipmentArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class RepairCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "repair";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()))
|
||||||
|
// .executes((source) -> {
|
||||||
|
// if (source.getSource().getSender() instanceof Player player)
|
||||||
|
// execute(player, player);
|
||||||
|
//
|
||||||
|
// return 1;
|
||||||
|
// })
|
||||||
|
.then(Commands.argument("equipmentslot", new EquipmentArgumentType())
|
||||||
|
.executes((source) -> {
|
||||||
|
if (!(source.getSource().getSender() instanceof Player player))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
EquipmentSlot equipmentSlot = source.getArgument("equipmentslot", EquipmentSlot.class);
|
||||||
|
execute(source.getSource().getSender(), player, equipmentSlot);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
Commands.argument("player", ArgumentTypes.player())
|
||||||
|
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission(adminOtherCommandPermission()))
|
||||||
|
.executes((source) -> {
|
||||||
|
CommandSourceStack sourceStack = source.getSource();
|
||||||
|
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).getFirst();
|
||||||
|
EquipmentSlot equipmentSlot = source.getArgument("equipmentslot", EquipmentSlot.class);
|
||||||
|
execute(source.getSource().getSender(), target, equipmentSlot);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - placeholders and messages from config
|
||||||
|
public void execute(CommandSender sender, Player target, EquipmentSlot equipmentSlot) {
|
||||||
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
|
Placeholder.component("requester", sender.name()),
|
||||||
|
Placeholder.component("target", target.displayName())
|
||||||
|
);
|
||||||
|
|
||||||
|
ItemStack itemStack = target.getInventory().getItem(equipmentSlot);
|
||||||
|
if (!(itemStack.getItemMeta() instanceof Damageable damageable))
|
||||||
|
return; // send message can not repair this item
|
||||||
|
|
||||||
|
damageable.setDamage(0);
|
||||||
|
sender.sendRichMessage(target == sender ? "You have repaired your <item>." : "<sender> has repaired your <item>.", placeholders);
|
||||||
|
if (target != sender)
|
||||||
|
target.sendRichMessage("You repaired <target>'s <item>.", placeholders);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class SetSpawnCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "setspawn";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(
|
||||||
|
commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
|
||||||
|
commandSourceStack.getSender() instanceof Player
|
||||||
|
)
|
||||||
|
.executes((source) -> {
|
||||||
|
if (source.getSource().getSender() instanceof Player player)
|
||||||
|
execute(player, player);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sender, Player target) {
|
||||||
|
// Todo - output messages
|
||||||
|
World world = target.getWorld();
|
||||||
|
world.setSpawnLocation(target.getLocation());
|
||||||
|
// TODO -- method in config to update & save
|
||||||
|
Config.config.set("spawn-world", world.getName());
|
||||||
|
Config.SPAWN_WORLD = world.getName();
|
||||||
|
Config.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
// TODO -- output messages
|
||||||
|
public class TimeCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "time";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(
|
||||||
|
commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
|
||||||
|
commandSourceStack.getSender() instanceof Player
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("freeze")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
freeze(player, true);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("unfreeze")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
freeze(player, false);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("day")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 1000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("noon")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 6000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("night")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 13000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("midnight")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setTime(player, 18000);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeze(Player player, boolean value) {
|
||||||
|
player.getWorld().setGameRule(GameRule.DO_DAYLIGHT_CYCLE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTime(Player player, int time) {
|
||||||
|
player.getWorld().setTime(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.commands.EssentiaCommand;
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||||
|
import io.papermc.paper.command.brigadier.Commands;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
// TODO -- output messages
|
||||||
|
public class WeatherCommand implements EssentiaCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String commandName() {
|
||||||
|
return "weather";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||||
|
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||||
|
Commands.literal(commandName())
|
||||||
|
.requires(
|
||||||
|
commandSourceStack -> commandSourceStack.getSender().hasPermission(adminCommandPermission()) &&
|
||||||
|
commandSourceStack.getSender() instanceof Player
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("clear")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
clearWeather(player, -1);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
Commands.argument("duration", ArgumentTypes.time())
|
||||||
|
.executes(commandContext -> {
|
||||||
|
int duration = commandContext.getArgument("duration", Integer.class);
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
clearWeather(player, duration);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("rain")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setRain(player, -1, false);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
Commands.argument("duration", ArgumentTypes.time())
|
||||||
|
.executes(commandContext -> {
|
||||||
|
int duration = commandContext.getArgument("duration", Integer.class);
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setRain(player, duration, false);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("thunder")
|
||||||
|
.executes(commandContext -> {
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setRain(player, -1, true);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
Commands.argument("duration", ArgumentTypes.time())
|
||||||
|
.executes(commandContext -> {
|
||||||
|
int duration = commandContext.getArgument("duration", Integer.class);
|
||||||
|
if (commandContext.getSource().getSender() instanceof Player player)
|
||||||
|
setRain(player, duration, true);
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearWeather(Player player, int duration) {
|
||||||
|
player.getWorld().setClearWeatherDuration(duration == -1 ? new Random().nextInt() : duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRain(Player player, int duration, boolean thunder) {
|
||||||
|
player.getWorld().setStorm(thunder);
|
||||||
|
player.getWorld().setWeatherDuration(duration == -1 ? new Random().nextInt() : duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class EnchantmentArgument implements CustomArgumentType.Converted<Enchant
|
||||||
try {
|
try {
|
||||||
return Enchantment.getByKey(NamespacedKey.minecraft(nativeType));
|
return Enchantment.getByKey(NamespacedKey.minecraft(nativeType));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid gamemode %s!".formatted(nativeType), NamedTextColor.RED));
|
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid enchantment %s!".formatted(nativeType), NamedTextColor.RED));
|
||||||
|
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.alttd.essentia.commands.argumement;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Message;
|
||||||
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
|
import io.papermc.paper.command.brigadier.MessageComponentSerializer;
|
||||||
|
import io.papermc.paper.command.brigadier.argument.CustomArgumentType;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class EquipmentArgumentType implements CustomArgumentType.Converted<EquipmentSlot, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull EquipmentSlot convert(String nativeType) throws CommandSyntaxException {
|
||||||
|
try {
|
||||||
|
return EquipmentSlot.valueOf(nativeType.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid EquipmentSlot %s!".formatted(nativeType), NamedTextColor.RED));
|
||||||
|
|
||||||
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ArgumentType<String> getNativeType() {
|
||||||
|
return StringArgumentType.word();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||||
|
for (EquipmentSlot equipmentSlot : EquipmentSlot.values()) {
|
||||||
|
builder.suggest(equipmentSlot.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompletableFuture.completedFuture(
|
||||||
|
builder.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -12,19 +12,19 @@ import io.papermc.paper.command.brigadier.MessageComponentSerializer;
|
||||||
import io.papermc.paper.command.brigadier.argument.CustomArgumentType;
|
import io.papermc.paper.command.brigadier.argument.CustomArgumentType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.WeatherType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class GameModeArgument implements CustomArgumentType.Converted<GameMode, String> {
|
public class WeatherArgument implements CustomArgumentType.Converted<WeatherType, String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull GameMode convert(String nativeType) throws CommandSyntaxException {
|
public @NotNull WeatherType convert(String nativeType) throws CommandSyntaxException {
|
||||||
try {
|
try {
|
||||||
return GameMode.valueOf(nativeType.toUpperCase());
|
return WeatherType.valueOf(nativeType.toUpperCase());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid gamemode %s!".formatted(nativeType), NamedTextColor.RED));
|
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid WeatherType %s!".formatted(nativeType), NamedTextColor.RED));
|
||||||
|
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
||||||
}
|
}
|
||||||
|
|
@ -37,8 +37,8 @@ public class GameModeArgument implements CustomArgumentType.Converted<GameMode,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
|
||||||
for (GameMode gameMode : GameMode.values()) {
|
for (WeatherType weatherType : WeatherType.values()) {
|
||||||
builder.suggest(gameMode.name().toLowerCase());
|
builder.suggest(weatherType.name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(
|
return CompletableFuture.completedFuture(
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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) -> {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.alttd.essentia.configuration;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
@ -66,7 +65,7 @@ public class Config {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void saveConfig() {
|
public static void saveConfig() {
|
||||||
try {
|
try {
|
||||||
config.save(CONFIG_FILE);
|
config.save(CONFIG_FILE);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user