Compare commits
No commits in common. "4faaa48a069e7ee5d309b9b1c15e4ec776c18682" and "e2a32c1ebdb7815c41ab9ba6dea5dbd9c5438c24" have entirely different histories.
4faaa48a06
...
e2a32c1ebd
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21.1-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.20.4-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,4 @@ public interface User {
|
||||||
Request request();
|
Request request();
|
||||||
|
|
||||||
void request(Request request);
|
void request(Request request);
|
||||||
|
|
||||||
boolean isCuffed();
|
|
||||||
|
|
||||||
void setCuffed(boolean cuffed);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,25 @@ import java.io.ByteArrayOutputStream
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("io.github.goooler.shadow") version "8.1.8"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
}
|
}
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "com.alttd.essentia"
|
group = "com.alttd.essentia"
|
||||||
version = "Build-" + (System.getenv("BUILD_NUMBER") ?: gitCommit())
|
version = "Build-" + (System.getenv("BUILD_NUMBER") ?: gitCommit())
|
||||||
description = "Altitude essentials ;)"
|
description = "Altitude essentials ;)"
|
||||||
|
|
||||||
apply<JavaLibraryPlugin>()
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(21))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply<JavaLibraryPlugin>()
|
apply<JavaLibraryPlugin>()
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
configure<PublishingExtension> {
|
configure<PublishingExtension> {
|
||||||
repositories {
|
repositories {
|
||||||
|
|
@ -66,10 +64,14 @@ tasks {
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
// enabled = false
|
// enabled = false
|
||||||
archiveFileName.set("${rootProject.name}.jar")
|
// archiveFileName.set("${rootProject.name}.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("com.alttd:Galaxy-API:1.20.4-R0.1-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
fun gitCommit(): String {
|
fun gitCommit(): String {
|
||||||
val os = ByteArrayOutputStream()
|
val os = ByteArrayOutputStream()
|
||||||
project.exec {
|
project.exec {
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ plugins {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
compileOnly("com.alttd:Galaxy-API:1.21.1-R0.1-SNAPSHOT")
|
compileOnly("com.alttd:Galaxy-API:1.20.4-R0.1-SNAPSHOT")
|
||||||
api("org.reflections:reflections:0.10.2")
|
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
compileOnly("org.projectlombok:lombok:1.18.24")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
annotationProcessor("org.projectlombok:lombok:1.18.24")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,17 @@
|
||||||
package com.alttd.essentia;
|
package com.alttd.essentia;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.admin.*;
|
||||||
|
import com.alttd.essentia.commands.player.*;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
|
import com.alttd.essentia.listeners.PlayerListener;
|
||||||
import com.alttd.essentia.storage.StorageManager;
|
import com.alttd.essentia.storage.StorageManager;
|
||||||
import com.alttd.essentia.storage.StorageProvider;
|
import com.alttd.essentia.storage.StorageProvider;
|
||||||
import com.alttd.essentia.storage.StorageType;
|
import com.alttd.essentia.storage.StorageType;
|
||||||
import com.alttd.essentia.user.EssentiaUserManager;
|
import com.alttd.essentia.user.EssentiaUserManager;
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
import com.alttd.essentia.api.user.UserManager;
|
||||||
import io.papermc.paper.command.brigadier.Commands;
|
|
||||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
|
||||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.reflections.Reflections;
|
|
||||||
import org.reflections.scanners.Scanners;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI {
|
public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI {
|
||||||
|
|
||||||
|
|
@ -58,36 +51,30 @@ public class EssentiaPlugin extends JavaPlugin implements EssentiaAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCommands() {
|
void loadCommands() {
|
||||||
Reflections reflections = new Reflections("com.alttd.essentia.commands");
|
getCommand("essentia").setExecutor(new EssentiaCommand(this));
|
||||||
Set<Class<?>> subTypes = reflections.get(Scanners.SubTypes.of(EssentiaCommand.class).asClass());
|
getCommand("teleportaccept").setExecutor(new TeleportAcceptCommand(this));
|
||||||
|
getCommand("teleportdeny").setExecutor(new TeleportDenyCommand(this));
|
||||||
LifecycleEventManager<Plugin> manager = this.getLifecycleManager();
|
getCommand("teleportrequest").setExecutor(new TeleportRequestCommand(this));
|
||||||
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
getCommand("teleportrequesthere").setExecutor(new TeleportRequestHereCommand(this));
|
||||||
final Commands commands = event.registrar();
|
getCommand("teleporttoggle").setExecutor(new TeleportToggleCommand(this));
|
||||||
subTypes.forEach(clazz -> {
|
getCommand("clearinventory").setExecutor(new ClearInventoryCommand(this));
|
||||||
try {
|
getCommand("home").setExecutor(new HomeCommand(this));
|
||||||
EssentiaCommand essentiaCommand = (EssentiaCommand) clazz.getDeclaredConstructor().newInstance();
|
getCommand("homes").setExecutor(new HomeListCommand(this));
|
||||||
commands.register(essentiaCommand.command(), essentiaCommand.description(), essentiaCommand.aliases());
|
getCommand("sethome").setExecutor(new SetHomeCommand(this));
|
||||||
} catch (Exception e) {
|
getCommand("deletehome").setExecutor(new DelHomeCommand(this));
|
||||||
EssentiaPlugin.instance().getLogger().severe("Failed to register command " + clazz.getSimpleName());
|
getCommand("back").setExecutor(new BackCommand(this));
|
||||||
}
|
getCommand("deathback").setExecutor(new DeathBackCommand(this));
|
||||||
});
|
getCommand("fly").setExecutor(new FlyCommand(this));
|
||||||
});
|
getCommand("gamemode").setExecutor(new GamemodeCommand(this));
|
||||||
|
getCommand("heal").setExecutor(new HealCommand(this));
|
||||||
|
getCommand("feed").setExecutor(new FeedCommand(this));
|
||||||
|
getCommand("enchant").setExecutor(new EnchantCommand(this));
|
||||||
|
getCommand("spawn").setExecutor(new SpawnCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadEventListeners() {
|
void loadEventListeners() {
|
||||||
final PluginManager pluginManager = getServer().getPluginManager();
|
final PluginManager pluginManager = getServer().getPluginManager();
|
||||||
Reflections reflections = new Reflections("com.alttd.essentia.listeners");
|
pluginManager.registerEvents(new PlayerListener(this), this);
|
||||||
Set<Class<?>> subTypes = reflections.get(Scanners.SubTypes.of(Listener.class).asClass());
|
|
||||||
|
|
||||||
subTypes.forEach(clazz -> {
|
|
||||||
try {
|
|
||||||
Listener listener = (Listener) clazz.getDeclaredConstructor().newInstance();
|
|
||||||
pluginManager.registerEvents(listener, this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
EssentiaPlugin.instance().getLogger().severe("Failed to register event listener " + clazz.getSimpleName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadManagers() {
|
void loadManagers() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.alttd.essentia.commands;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
|
||||||
|
public abstract class AdminSubCommand extends SubCommand {
|
||||||
|
|
||||||
|
protected AdminSubCommand(EssentiaPlugin plugin, String name, String... aliases) {
|
||||||
|
super(plugin, name, aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package com.alttd.essentia.commands;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
// TODO -- add optional -s -silent parameters to commands?
|
|
||||||
public interface EssentiaCommand {
|
|
||||||
|
|
||||||
@NotNull LiteralCommandNode<CommandSourceStack> command();
|
|
||||||
|
|
||||||
default String description() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<String> aliases() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.alttd.essentia.commands;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
|
import com.alttd.essentia.api.user.User;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class PlayerSubCommand extends SubCommand {
|
||||||
|
|
||||||
|
protected PlayerSubCommand(EssentiaPlugin plugin, String name, String... aliases) {
|
||||||
|
super(plugin, name, aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String... args) {
|
||||||
|
if (!(sender instanceof Player player)) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_ONLY_COMMAND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return execute(player, plugin.userManager().getUser(player), args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean execute(Player player, User user, String... args);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.alttd.essentia.commands;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public abstract class SubCommand implements TabExecutor {
|
||||||
|
|
||||||
|
protected EssentiaPlugin plugin;
|
||||||
|
protected final String name;
|
||||||
|
private final String[] aliases;
|
||||||
|
private final Map<String, SubCommand> subCommands = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
protected SubCommand(EssentiaPlugin plugin, String name, String... aliases) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.name = name;
|
||||||
|
this.aliases = aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean execute(CommandSender sender, String... args);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
SubCommand subCommand = getSubCommand(args[0]);
|
||||||
|
if (subCommand != null) {
|
||||||
|
return subCommand.onCommand(sender, cmd, args[0], Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return execute(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
return subCommands.keySet().stream()
|
||||||
|
.sorted(String::compareToIgnoreCase)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
SubCommand subCommand = getSubCommand(args[0]);
|
||||||
|
if (subCommand != null) {
|
||||||
|
return subCommand.onTabComplete(sender, command, args[0], Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
return subCommands.keySet().stream()
|
||||||
|
.filter(s -> s.toLowerCase().startsWith(args[0]))
|
||||||
|
.sorted(String::compareToIgnoreCase)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerSubCommand(SubCommand subCommand) {
|
||||||
|
subCommands.put(subCommand.name.toLowerCase(), subCommand);
|
||||||
|
for (String alias : subCommand.aliases) {
|
||||||
|
subCommands.putIfAbsent(alias.toLowerCase(), subCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubCommand getSubCommand(String name) {
|
||||||
|
return subCommands.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,66 +1,39 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
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 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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class BurnCommand implements EssentiaCommand {
|
public class BurnCommand extends AdminSubCommand {
|
||||||
|
|
||||||
static String commandName = "burn";
|
public BurnCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "burn");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String description() {
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
return "Set yourself or another player on fire!";
|
Player target = args.length > 0 ? org.bukkit.Bukkit.getPlayer(args[0]) : sender instanceof Player player ? player : null;
|
||||||
}
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("essentia.command." + name + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) { // TODO - optional time?
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("requester", sender.name()),
|
Placeholder.component("requester", sender.name()),
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
);
|
);
|
||||||
|
|
||||||
target.setFireTicks((int) (3000L / 50));
|
target.setFireTicks((int) (3000L / 50));
|
||||||
sender.sendRichMessage(target == sender ? Config.BURN_SELF : Config.BURN_OTHER, placeholders);
|
sender.sendRichMessage(target == sender ? Config.BURN_SELF : Config.BURN_OTHER, placeholders);
|
||||||
if (target != sender)
|
if (target != sender)
|
||||||
target.sendRichMessage(Config.BURN_BY_OTHER, placeholders);
|
target.sendRichMessage(Config.BURN_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,49 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
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 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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ClearInventoryCommand implements EssentiaCommand {
|
public class ClearInventoryCommand extends AdminSubCommand {
|
||||||
|
|
||||||
static String commandName = "clearinventory";
|
public ClearInventoryCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "clearinventory");
|
||||||
|
// TODO - register clear other subcommand
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
if (args.length > 0) { // TODO - make this into a subcommand
|
||||||
Commands.literal(commandName)
|
if (!sender.hasPermission("essentia.command.clearinventory.other")) {
|
||||||
.requires(
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
return true;
|
||||||
commandSourceStack.getSender() instanceof Player
|
}
|
||||||
)
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
.executes((source) -> {
|
if (player == null) {
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
execute(player, player);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
})
|
Placeholder.component("requester", sender.name()),
|
||||||
.then(
|
Placeholder.component("target", player.displayName())
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
);
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
sender.sendRichMessage(Config.PLAYER_INVENTORY_CLEARED, placeholders);
|
||||||
.executes((source) -> {
|
player.sendRichMessage(Config.INVENTORY_CLEARED_BY_OTHER, placeholders);
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
player.getInventory().clear();
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
return true;
|
||||||
|
}
|
||||||
execute(source.getSource().getSender(), target);
|
if (!(sender instanceof Player player)) {
|
||||||
return 1;
|
sender.sendRichMessage(Config.PLAYER_ONLY_COMMAND);
|
||||||
})
|
return true;
|
||||||
);
|
}
|
||||||
return builder.build();
|
player.getInventory().clear();
|
||||||
|
player.sendRichMessage(Config.INVENTORY_CLEARED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
target.getInventory().clear();
|
|
||||||
sender.sendRichMessage(target == sender ? Config.INVENTORY_CLEARED : Config.PLAYER_INVENTORY_CLEARED, placeholders);
|
|
||||||
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.INVENTORY_CLEARED_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
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 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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class CuffCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "cuff";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
UserManager userManager = EssentiaPlugin.instance().userManager();
|
|
||||||
if (!userManager.hasUser(target.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = userManager.getUser(target);
|
|
||||||
if (user.isCuffed()) {
|
|
||||||
sender.sendRichMessage("<target> is already cuffed."); // TODO - CONFIG messages
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
user.setCuffed(true);
|
|
||||||
// TODO - CONFIG messages
|
|
||||||
sender.sendRichMessage(target == sender ? Config.BURN_SELF : Config.BURN_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.BURN_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +1,38 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.argumement.EnchantmentArgument;
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import org.bukkit.NamespacedKey;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import org.bukkit.command.Command;
|
||||||
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.Material;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class EnchantCommand implements EssentiaCommand {
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
static String commandName = "enchant";
|
public class EnchantCommand extends AdminSubCommand {
|
||||||
|
|
||||||
|
public EnchantCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "enchant");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
// TODO
|
||||||
Commands.literal(commandName)
|
return true;
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("enchantment", new EnchantmentArgument())
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Enchantment enchantment = source.getArgument("enchantment", Enchantment.class);
|
|
||||||
execute(source.getSource().getSender(), player, enchantment);
|
|
||||||
return 1;
|
|
||||||
}).then(
|
|
||||||
Commands.argument("level", IntegerArgumentType.integer(1, 100))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Enchantment enchantment = source.getArgument("enchantment", Enchantment.class);
|
|
||||||
int level = source.getArgument("level", Integer.class);
|
|
||||||
execute(source.getSource().getSender(), player, enchantment, level);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
Enchantment enchantment = source.getArgument("enchantment", Enchantment.class);
|
|
||||||
int level = source.getArgument("level", Integer.class);
|
|
||||||
execute(source.getSource().getSender(), target, enchantment, level);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execute(CommandSender sender, Player target, Enchantment enchantment) {
|
@Override
|
||||||
execute(sender, target, enchantment, 1, false);
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String @NotNull [] args) {
|
||||||
}
|
if (args.length == 1) {
|
||||||
|
return Arrays.stream(Enchantment.values())
|
||||||
private void execute(CommandSender sender, Player target, Enchantment enchantment, int level) {
|
.map(Enchantment::getKey)
|
||||||
execute(sender, target, enchantment, level, false);
|
.map(NamespacedKey::getKey)
|
||||||
}
|
.filter(name -> name.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
public void execute(CommandSender sender, Player target, Enchantment enchantment, int level, boolean unsafe) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName()),
|
|
||||||
Placeholder.unparsed("enchantment", enchantment.getKey().value())
|
|
||||||
);
|
|
||||||
|
|
||||||
// target.setGameMode(gameMode);
|
|
||||||
ItemStack itemStack = target.getInventory().getItemInMainHand();
|
|
||||||
if (itemStack.getType() == Material.AIR) {
|
|
||||||
sender.sendRichMessage("Hold the item you want to enchant", placeholders);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (unsafe) {
|
return null;
|
||||||
itemStack.addUnsafeEnchantment(enchantment, level);
|
|
||||||
} else {
|
|
||||||
if ((level > enchantment.getMaxLevel())) {
|
|
||||||
level = enchantment.getMaxLevel();
|
|
||||||
}
|
|
||||||
if (!enchantment.canEnchantItem(itemStack)) {
|
|
||||||
sender.sendRichMessage("You can not enchant this item with <enchantment>", placeholders);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack.addEnchantment(enchantment, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendRichMessage(target == sender ? "You enchanted your item with <enchantment>." : "<sender> enchanted your item with <enchantment>.", placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage("You enchanted <target>'s item with <enchantment>.", placeholders);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class EssentiaAdminCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal("essentia")
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin.reload"))
|
|
||||||
.executes((commandContext -> 1))
|
|
||||||
.then(
|
|
||||||
Commands.literal("reload")
|
|
||||||
.executes((cmd) -> {
|
|
||||||
EssentiaPlugin.instance().reloadConfig();
|
|
||||||
return com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
;
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.SubCommand;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class EssentiaCommand extends SubCommand {
|
||||||
|
|
||||||
|
public EssentiaCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "essentia");
|
||||||
|
|
||||||
|
registerSubCommand(new ReloadCommand(plugin));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,52 +1,31 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
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 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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class FeedCommand implements EssentiaCommand {
|
public class FeedCommand extends AdminSubCommand {
|
||||||
|
|
||||||
static String commandName = "feed";
|
public FeedCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "feed");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
Player target = args.length > 0 ? org.bukkit.Bukkit.getPlayer(args[0]) : sender instanceof Player player ? player : null;
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("essentia.command.feed" + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("requester", sender.name()),
|
Placeholder.component("requester", sender.name()),
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
|
|
@ -57,7 +36,6 @@ public class FeedCommand implements EssentiaCommand {
|
||||||
sender.sendRichMessage(target == sender ? Config.FEED_SELF : Config.FEED_OTHER, placeholders);
|
sender.sendRichMessage(target == sender ? Config.FEED_SELF : Config.FEED_OTHER, placeholders);
|
||||||
if (target != sender)
|
if (target != sender)
|
||||||
target.sendRichMessage(Config.FEED_BY_OTHER, placeholders);
|
target.sendRichMessage(Config.FEED_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,74 +1,56 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
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 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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class FlyCommand implements EssentiaCommand {
|
public class FlyCommand extends AdminSubCommand {
|
||||||
|
|
||||||
static String commandName = "fly";
|
public FlyCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "fly");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
if (args.length > 0) {
|
||||||
Commands.literal(commandName)
|
if (!sender.hasPermission("essentia.command.fly.other")) {
|
||||||
.requires(
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
return true;
|
||||||
commandSourceStack.getSender() instanceof Player
|
}
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
})
|
if (target == null) {
|
||||||
.then(
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
return true;
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
}
|
||||||
.executes((source) -> {
|
target.setAllowFlight(!target.getAllowFlight());
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
|
|
||||||
execute(source.getSource().getSender(), target);
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
return 1;
|
Placeholder.component("player", sender.name()),
|
||||||
})
|
Placeholder.component("target", target.name()),
|
||||||
);
|
Placeholder.unparsed("status", BooleanUtils.toStringOnOff(target.getAllowFlight()))
|
||||||
return builder.build();
|
);
|
||||||
}
|
sender.sendRichMessage(Config.TOGGLED_FLIGHT_BY_OTHER, placeholders);
|
||||||
|
target.sendRichMessage(Config.TOGGLED_FLIGHT_PLAYER, placeholders);
|
||||||
public void execute(CommandSender sender, Player target) {
|
return true;
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
}
|
||||||
Placeholder.component("player", sender.name()),
|
if (!(sender instanceof Player player)) {
|
||||||
Placeholder.component("target", target.name()),
|
sender.sendRichMessage(Config.PLAYER_ONLY_COMMAND);
|
||||||
Placeholder.unparsed("status", BooleanUtils.toStringOnOff(!target.getAllowFlight()))
|
return true;
|
||||||
);
|
|
||||||
|
|
||||||
UserManager userManager = EssentiaPlugin.instance().userManager();
|
|
||||||
if (!userManager.hasUser(target.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = userManager.getUser(target);
|
player.setAllowFlight(!player.getAllowFlight());
|
||||||
user.getUserSettings().flying(!user.getUserSettings().flying());
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
target.setFlying(!user.getUserSettings().flying());
|
Placeholder.component("player", player.name()),
|
||||||
sender.sendRichMessage(target == sender ? Config.TOGGLED_FLIGHT : Config.TOGGLED_FLIGHT_PLAYER, placeholders);
|
Placeholder.parsed("status", BooleanUtils.toStringOnOff(player.getAllowFlight()))
|
||||||
if (target != sender)
|
);
|
||||||
target.sendRichMessage(Config.TOGGLED_FLIGHT_BY_OTHER, placeholders);
|
sender.sendRichMessage(Config.TOGGLED_FLIGHT, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
|
||||||
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.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class FlySpeedCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "flyspeed";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
).then(
|
|
||||||
Commands.argument("speed", FloatArgumentType.floatArg(-1, 1))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Enchantment enchantment = source.getArgument("enchantment", Enchantment.class);
|
|
||||||
float speed = source.getArgument("speed", Float.class);
|
|
||||||
execute(source.getSource().getSender(), player, speed);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
float speed = source.getArgument("speed", Float.class);
|
|
||||||
execute(source.getSource().getSender(), target, speed);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target, float speed) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
target.setFlySpeed(speed);
|
|
||||||
// TODO - Config messages
|
|
||||||
sender.sendRichMessage(target == sender ? Config.FEED_SELF : Config.FEED_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.FEED_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.commands.argumement.GameModeArgument;
|
|
||||||
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 io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.SelectorArgumentResolver;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class GameModeCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "gamemode";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("gamemode", new GameModeArgument())
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
GameMode gameMode = source.getArgument("gamemode", GameMode.class);
|
|
||||||
execute(source.getSource().getSender(), player, gameMode);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
GameMode gameMode = source.getArgument("gamemode", GameMode.class);
|
|
||||||
execute(source.getSource().getSender(), target, gameMode);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target, GameMode gameMode) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName()),
|
|
||||||
Placeholder.unparsed("gamemode", gameMode.toString().toLowerCase())
|
|
||||||
);
|
|
||||||
|
|
||||||
target.setGameMode(gameMode);
|
|
||||||
sender.sendRichMessage(target == sender ? Config.GAMEMODE_SET : Config.GAMEMODE_SET_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.GAMEMODE_SET_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class GamemodeCommand extends AdminSubCommand {
|
||||||
|
|
||||||
|
public GamemodeCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "gamemode");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
// TODO -- refactor all "other" subcommands to follow this style, cleaner and easier?
|
||||||
|
Player target = args.length > 1 ? Bukkit.getPlayer(args[1]) : sender instanceof Player player ? player : null;
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.hasPermission("essentia.command.gamemode" + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMode gameMode = GameMode.SURVIVAL;
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "creative", "c" -> gameMode = GameMode.CREATIVE;
|
||||||
|
case "spectator", "sp" -> gameMode = GameMode.SPECTATOR;
|
||||||
|
}
|
||||||
|
target.setGameMode(gameMode);
|
||||||
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
|
Placeholder.component("requester", sender.name()),
|
||||||
|
Placeholder.component("target", target.displayName()),
|
||||||
|
Placeholder.unparsed("gamemode", gameMode.toString())
|
||||||
|
);
|
||||||
|
sender.sendRichMessage(target == sender ? Config.GAMEMODE_SET : Config.GAMEMODE_SET_OTHER, placeholders);
|
||||||
|
if (target != sender)
|
||||||
|
target.sendRichMessage(Config.GAMEMODE_SET_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String name = args[0].trim().toLowerCase();
|
||||||
|
return Arrays.stream(GameMode.values()).map(GameMode::toString)
|
||||||
|
.filter(string -> string.toLowerCase().startsWith(name)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
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 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.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class GodCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "god";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
UserManager userManager = EssentiaPlugin.instance().userManager();
|
|
||||||
User user = userManager.getUser(target);
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("player", sender.name()),
|
|
||||||
Placeholder.component("target", target.name()),
|
|
||||||
Placeholder.unparsed("status", BooleanUtils.toStringOnOff(!user.getUserSettings().godMode()))
|
|
||||||
);
|
|
||||||
|
|
||||||
user.getUserSettings().godMode(!user.getUserSettings().godMode());
|
|
||||||
target.setInvulnerable(!user.getUserSettings().godMode());
|
|
||||||
sender.sendRichMessage(target == sender ? Config.TOGGLED_GOD : Config.TOGGLED_GOD_PLAYER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.TOGGLED_GOD_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +1,39 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
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 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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class HealCommand
|
public class HealCommand extends AdminSubCommand {
|
||||||
implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "heal";
|
public HealCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "heal");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
Player target = args.length > 0 ? org.bukkit.Bukkit.getPlayer(args[0]) : sender instanceof Player player ? player : null;
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("essentia.command.heal" + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("requester", sender.name()),
|
Placeholder.component("requester", sender.name()),
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
);
|
);
|
||||||
|
|
||||||
target.setHealth(20);
|
target.setHealth(20);
|
||||||
sender.sendRichMessage(target == sender ? Config.HEAL_SELF : Config.HEAL_OTHER, placeholders);
|
sender.sendRichMessage(target == sender ? Config.HEAL_SELF : Config.HEAL_OTHER, placeholders);
|
||||||
if (target != sender)
|
if (target != sender)
|
||||||
target.sendRichMessage(Config.HEAL_BY_OTHER, placeholders);
|
target.sendRichMessage(Config.HEAL_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,40 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.alttd.essentia.configuration.Config;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class InfoCommand implements EssentiaCommand {
|
public class InfoCommand extends AdminSubCommand {
|
||||||
|
|
||||||
static String commandName = "info";
|
public InfoCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "info");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) { // TODO - implement player info
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
Player target = args.length > 0 ? org.bukkit.Bukkit.getPlayer(args[0]) : sender instanceof Player player ? player : null;
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("essentia.command." + name + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("requester", sender.name()),
|
Placeholder.component("requester", sender.name()),
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
);
|
);
|
||||||
|
// Todo Show player info
|
||||||
|
// target.setHealth(20);
|
||||||
|
// sender.sendRichMessage(target == sender ? Config.HEAL_SELF : Config.HEAL_OTHER, placeholders);
|
||||||
|
// if (target != sender)
|
||||||
|
// target.sendRichMessage(Config.HEAL_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class ReloadCommand extends AdminSubCommand {
|
||||||
|
|
||||||
|
public ReloadCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "reload");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
plugin.loadConfiguration();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
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 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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SmiteCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "smite";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
if (sender instanceof Player player)
|
|
||||||
target.damage(100.0D, player);
|
|
||||||
|
|
||||||
target.setHealth(0.0D);
|
|
||||||
target.getWorld().strikeLightningEffect(target.getLocation());
|
|
||||||
sender.sendRichMessage(target == sender ? Config.SMITE_SELF : Config.SMITE_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.SMITE_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("kill");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
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 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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TeleportCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "teleport";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute((Player) source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target) {
|
|
||||||
sender.teleport(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tp");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
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 io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TeleportHereCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "teleporthere";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute((Player) source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target) {
|
|
||||||
target.teleport(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tp", "tphere");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
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 io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
|
||||||
import io.papermc.paper.math.BlockPosition;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TeleportPositionCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "teleportposition";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("pos", ArgumentTypes.blockPosition())
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
BlockPosition position = source.getArgument("pos", BlockPositionResolver.class).resolve(sourceStack);
|
|
||||||
execute(player, player, position);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
BlockPosition position = source.getArgument("pos", BlockPositionResolver.class).resolve(sourceStack);
|
|
||||||
execute(player, target, position);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target, BlockPosition position) {
|
|
||||||
target.teleport(position.toLocation(target.getWorld()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tppos");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
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 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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class UnCuffCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "uncuff";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
UserManager userManager = EssentiaPlugin.instance().userManager();
|
|
||||||
if (!userManager.hasUser(target.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = userManager.getUser(target);
|
|
||||||
if (!user.isCuffed()) {
|
|
||||||
sender.sendRichMessage("<target> is not cuffed."); // TODO - CONFIG messages
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
user.setCuffed(false);
|
|
||||||
// TODO - CONFIG messages
|
|
||||||
sender.sendRichMessage(target == sender ? Config.BURN_SELF : Config.BURN_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.BURN_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
package com.alttd.essentia.commands.admin;
|
|
||||||
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
|
||||||
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.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class WalkSpeedCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "walkspeed";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
).then(
|
|
||||||
Commands.argument("speed", FloatArgumentType.floatArg(-1, 1))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
Enchantment enchantment = source.getArgument("enchantment", Enchantment.class);
|
|
||||||
float speed = source.getArgument("speed", Float.class);
|
|
||||||
execute(source.getSource().getSender(), player, speed);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
float speed = source.getArgument("speed", Float.class);
|
|
||||||
execute(source.getSource().getSender(), target, speed);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target, float speed) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
target.setFlySpeed(speed);
|
|
||||||
// TODO - Config messages
|
|
||||||
sender.sendRichMessage(target == sender ? Config.FEED_SELF : Config.FEED_OTHER, placeholders);
|
|
||||||
if (target != sender)
|
|
||||||
target.sendRichMessage(Config.FEED_BY_OTHER, placeholders);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
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 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.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WorkBenchCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "workbench";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.admin." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
target.openWorkbench(null, true);
|
|
||||||
// TODO - output config messages
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("craft", "craftingtable");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.alttd.essentia.commands.admin;
|
||||||
|
|
||||||
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.AdminSubCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class smiteCommand extends AdminSubCommand {
|
||||||
|
|
||||||
|
public smiteCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "smite");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute(CommandSender sender, String... args) {
|
||||||
|
Player target = args.length > 0 ? org.bukkit.Bukkit.getPlayer(args[0]) : sender instanceof Player player ? player : null;
|
||||||
|
if (target == null) {
|
||||||
|
sender.sendRichMessage(Config.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("essentia.command." + name + (target != sender ? ".other" : "")) ) {
|
||||||
|
sender.sendRichMessage(Config.COMMAND_NO_PERMISSION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
|
Placeholder.component("requester", sender.name()),
|
||||||
|
Placeholder.component("target", target.displayName())
|
||||||
|
);
|
||||||
|
// Todo smite the user xD
|
||||||
|
// target.setHealth(20);
|
||||||
|
// sender.sendRichMessage(target == sender ? Config.HEAL_SELF : Config.HEAL_OTHER, placeholders);
|
||||||
|
// if (target != sender)
|
||||||
|
// target.sendRichMessage(Config.HEAL_BY_OTHER, placeholders);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
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 io.papermc.paper.registry.RegistryAccess;
|
|
||||||
import io.papermc.paper.registry.RegistryKey;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.Registry;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class EnchantmentArgument implements CustomArgumentType.Converted<Enchantment, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Enchantment convert(String nativeType) throws CommandSyntaxException {
|
|
||||||
try {
|
|
||||||
return Enchantment.getByKey(NamespacedKey.minecraft(nativeType));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid gamemode %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 (Enchantment enchantment : RegistryAccess.registryAccess().getRegistry(RegistryKey.ENCHANTMENT)) {
|
|
||||||
builder.suggest(enchantment.getKey().value());
|
|
||||||
}
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(
|
|
||||||
builder.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
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.GameMode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class GameModeArgument implements CustomArgumentType.Converted<GameMode, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull GameMode convert(String nativeType) throws CommandSyntaxException {
|
|
||||||
try {
|
|
||||||
return GameMode.valueOf(nativeType.toUpperCase());
|
|
||||||
} catch (Exception e) {
|
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid gamemode %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 (GameMode gameMode : GameMode.values()) {
|
|
||||||
builder.suggest(gameMode.name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(
|
|
||||||
builder.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
package com.alttd.essentia.commands.argumement;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.model.Home;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
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.OfflinePlayer;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class HomeArgument implements CustomArgumentType.Converted<Home, String> {
|
|
||||||
|
|
||||||
User user;
|
|
||||||
public HomeArgument(OfflinePlayer offlinePlayer) {
|
|
||||||
user = EssentiaPlugin.instance().userManager().getUser(offlinePlayer.getUniqueId());
|
|
||||||
if (user == null)
|
|
||||||
user = EssentiaPlugin.instance().storageProvider().loadUser(offlinePlayer.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Home convert(String nativeType) throws CommandSyntaxException {
|
|
||||||
try {
|
|
||||||
return user.getHome(nativeType);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid Home %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 (String home : user.getHomes()) {
|
|
||||||
builder.suggest(home);
|
|
||||||
}
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(
|
|
||||||
builder.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
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.exceptions.CommandSyntaxException;
|
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
|
||||||
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.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class OfflinePlayerArgument implements CustomArgumentType.Converted<OfflinePlayer, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull OfflinePlayer convert(String nativeType) throws CommandSyntaxException {
|
|
||||||
try {
|
|
||||||
return Bukkit.getOfflinePlayer(nativeType);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid PlayerName %s!".formatted(nativeType), NamedTextColor.RED));
|
|
||||||
|
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(message), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull ArgumentType<String> getNativeType() {
|
|
||||||
return StringArgumentType.word();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
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.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class OfflinePlayerCompletingArgument implements CustomArgumentType.Converted<OfflinePlayer, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull OfflinePlayer convert(String nativeType) throws CommandSyntaxException {
|
|
||||||
try {
|
|
||||||
return Bukkit.getOfflinePlayer(nativeType);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Message message = MessageComponentSerializer.message().serialize(Component.text("Invalid PlayerName %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 (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
builder.suggest(player.getName(), MessageComponentSerializer.message().serialize(player.displayName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(
|
|
||||||
builder.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +1,39 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
import com.alttd.essentia.api.events.PlayerTeleportBackEvent;
|
import com.alttd.essentia.api.events.PlayerTeleportBackEvent;
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import com.alttd.essentia.tasks.TeleportSounds;
|
import com.alttd.essentia.tasks.TeleportSounds;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.alttd.essentia.api.user.User;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
|
||||||
import io.papermc.paper.command.brigadier.Commands;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class BackCommand implements EssentiaCommand {
|
public class BackCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
static String commandName = "back";
|
public BackCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "back");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
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) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Location back = user.getBackLocation(false);
|
Location back = user.getBackLocation(false);
|
||||||
|
|
||||||
if (back == null) {
|
if (back == null) {
|
||||||
target.sendRichMessage(Config.NO_BACK_LOCATION);
|
player.sendRichMessage(Config.NO_BACK_LOCATION);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
EssentiaEvent event = new PlayerTeleportBackEvent(target, back);
|
EssentiaEvent event = new PlayerTeleportBackEvent(player, back);
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
new TeleportSounds(back, player.getLocation())
|
||||||
|
.runTaskLater(plugin, 1);
|
||||||
|
|
||||||
new TeleportSounds(back, target.getLocation())
|
player.teleportAsync(back).thenAccept(result ->
|
||||||
.runTaskLater(EssentiaPlugin.instance(), 1);
|
player.sendRichMessage(Config.TELEPORTING_BACK));
|
||||||
|
return true;
|
||||||
target.teleportAsync(back).thenAccept(result ->
|
|
||||||
target.sendRichMessage(Config.TELEPORTING_BACK));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,39 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
import com.alttd.essentia.api.events.PlayerTeleportBackEvent;
|
import com.alttd.essentia.api.events.PlayerTeleportBackEvent;
|
||||||
import com.alttd.essentia.tasks.TeleportSounds;
|
import com.alttd.essentia.tasks.TeleportSounds;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
public class DeathBackCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
public class DeathBackCommand implements EssentiaCommand {
|
public DeathBackCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "back");
|
||||||
static String commandName = "deathback";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
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) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Location back = user.getBackLocation(true);
|
Location back = user.getBackLocation(true);
|
||||||
|
|
||||||
if (back == null) {
|
if (back == null) {
|
||||||
target.sendRichMessage(Config.NO_DEATH_LOCATION);
|
player.sendRichMessage(Config.NO_DEATH_LOCATION);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
EssentiaEvent event = new PlayerTeleportBackEvent(target, back);
|
EssentiaEvent event = new PlayerTeleportBackEvent(player, back);
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
new TeleportSounds(back, target.getLocation())
|
new TeleportSounds(back, player.getLocation())
|
||||||
.runTaskLater(EssentiaPlugin.instance(), 1);
|
.runTaskLater(plugin, 1);
|
||||||
|
|
||||||
target.teleportAsync(back).thenAccept(result ->
|
player.teleportAsync(back).thenAccept(result ->
|
||||||
target.sendRichMessage(Config.TELEPORTING_BACK_DEATH));
|
player.sendRichMessage(Config.TELEPORTING_BACK_DEATH));
|
||||||
}
|
return true;
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("dback");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,150 +1,41 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.commands.argumement.OfflinePlayerArgument;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
import com.alttd.essentia.api.events.PlayerRemoveHomeEvent;
|
import com.alttd.essentia.api.events.PlayerRemoveHomeEvent;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
|
||||||
import io.papermc.paper.command.brigadier.Commands;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public class DelHomeCommand extends PlayerSubCommand {
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class DelHomeCommand implements EssentiaCommand {
|
public DelHomeCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "deletehome");
|
||||||
static String commandName = "delhome";
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
// TODO -- subcommand to remove other player homes
|
||||||
Commands.literal(commandName)
|
// if (args.length > 1) {
|
||||||
.requires(
|
// if (!player.hasPermission("essentia.command.delhome.other")) {
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
// return true;
|
||||||
commandSourceStack.getSender() instanceof Player
|
// }
|
||||||
)
|
// }
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
String home = (args.length > 0) ? args[0] : "home";
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("home", StringArgumentType.word())
|
|
||||||
.suggests((context, suggestionsBuilder) -> {
|
|
||||||
if (!(context.getSource().getSender() instanceof Player player))
|
|
||||||
return Suggestions.empty();
|
|
||||||
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(player);
|
|
||||||
Collection<String> possibleValues = new ArrayList<>(user.getHomes());
|
|
||||||
|
|
||||||
if(possibleValues.isEmpty())
|
|
||||||
return Suggestions.empty();
|
|
||||||
|
|
||||||
String remaining = suggestionsBuilder.getRemaining().toLowerCase();
|
|
||||||
for (String str : possibleValues) {
|
|
||||||
if (str.toLowerCase().startsWith(remaining)) {
|
|
||||||
suggestionsBuilder.suggest(StringArgumentType.escapeIfRequired(str));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return suggestionsBuilder.buildFuture();
|
|
||||||
})
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
String home = source.getArgument("home", String.class);
|
|
||||||
execute(player, player, home);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", new OfflinePlayerArgument())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.then(
|
|
||||||
Commands.argument("home", StringArgumentType.word())
|
|
||||||
.suggests((context, suggestionsBuilder) -> {
|
|
||||||
if (!(context.getSource().getSender() instanceof Player player))
|
|
||||||
return Suggestions.empty();
|
|
||||||
|
|
||||||
OfflinePlayer target = context.getArgument("player", OfflinePlayer.class);
|
|
||||||
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target.getUniqueId());
|
|
||||||
if (user == null)
|
|
||||||
user = EssentiaPlugin.instance().storageProvider().loadUser(target.getUniqueId());
|
|
||||||
|
|
||||||
Collection<String> possibleValues = new ArrayList<>(user.getHomes());
|
|
||||||
|
|
||||||
if(possibleValues.isEmpty())
|
|
||||||
return Suggestions.empty();
|
|
||||||
|
|
||||||
String remaining = suggestionsBuilder.getRemaining().toLowerCase();
|
|
||||||
for (String str : possibleValues) {
|
|
||||||
if (str.toLowerCase().startsWith(remaining)) {
|
|
||||||
suggestionsBuilder.suggest(StringArgumentType.escapeIfRequired(str));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return suggestionsBuilder.buildFuture();
|
|
||||||
})
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
OfflinePlayer target = source.getArgument("player", OfflinePlayer.class);
|
|
||||||
String home = source.getArgument("home", String.class);
|
|
||||||
execute(player, target, home);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target) {
|
|
||||||
execute(sender, target, "home");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, OfflinePlayer target, String home) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target.getUniqueId());
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = EssentiaPlugin.instance().storageProvider().loadUser(target.getUniqueId());
|
|
||||||
|
|
||||||
delHome(sender, user, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target, String home) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
delHome(sender, user, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void delHome(Player sender, User user, String home) {
|
|
||||||
if (!user.hasHome(home)) {
|
if (!user.hasHome(home)) {
|
||||||
sender.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.unparsed("home", home));
|
player.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.unparsed("home", home));
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
EssentiaEvent event = new PlayerRemoveHomeEvent(player, home);
|
||||||
EssentiaEvent event = new PlayerRemoveHomeEvent(sender, home);
|
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setHome(home, null);
|
user.setHome(home, null);
|
||||||
sender.sendRichMessage(Config.HOME_DELETED, Placeholder.unparsed("home", home));
|
player.sendRichMessage(Config.HOME_DELETED, Placeholder.unparsed("home", home));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
package com.alttd.essentia.commands.player;
|
|
||||||
|
|
||||||
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 io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
|
||||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class DisposeCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "dispose";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("requester", sender.name()),
|
|
||||||
Placeholder.component("target", target.displayName())
|
|
||||||
);
|
|
||||||
|
|
||||||
Inventory inventory = Bukkit.createInventory(null, 36, MiniMessage.miniMessage().deserialize("Item Disposal")); // TODO - config
|
|
||||||
// TODO - PlayerItemDisposeEvent
|
|
||||||
target.openInventory(inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +1,82 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.api.model.Home;
|
||||||
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
import com.alttd.essentia.api.events.PlayerTeleportHomeEvent;
|
import com.alttd.essentia.api.events.PlayerTeleportHomeEvent;
|
||||||
import com.alttd.essentia.api.model.Home;
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.tasks.TeleportSounds;
|
import com.alttd.essentia.tasks.TeleportSounds;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
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;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// TODO - home other
|
public class HomeCommand extends PlayerSubCommand {
|
||||||
public class HomeCommand implements EssentiaCommand {
|
|
||||||
|
|
||||||
static String commandName = "home";
|
public HomeCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "home");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
String home;
|
||||||
Commands.literal(commandName)
|
if (args.length == 0) {
|
||||||
.requires(
|
int count = user.getHomeCount();
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
if (count <= 1) {
|
||||||
commandSourceStack.getSender() instanceof Player
|
home = user.getHomes().stream().findFirst().orElse(null);
|
||||||
)
|
} else {
|
||||||
.executes((source) -> {
|
player.sendRichMessage(Config.SPECIFY_HOME, Placeholder.unparsed("homelist", String.join(", ", user.getHomes())));
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
return true;
|
||||||
execute(player, player, "home");
|
}
|
||||||
|
if (home == null || home.isEmpty()) {
|
||||||
return 1;
|
player.sendRichMessage(Config.HOME_NOT_SET);
|
||||||
})
|
return true;
|
||||||
.then(
|
}
|
||||||
Commands.argument("name", StringArgumentType.word())
|
return true;
|
||||||
.executes((source) -> {
|
} else {
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
home = args[0];
|
||||||
return 1;
|
}
|
||||||
|
// TODO - subcommand to teleport to others homes
|
||||||
String name = source.getArgument("name", String.class);
|
// if (args.length > 1) {
|
||||||
execute(player, player, name);
|
// if (!player.hasPermission("essentia.command.home.other")) {
|
||||||
return 1;
|
// return true
|
||||||
})
|
// }
|
||||||
);
|
// }
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target, String home) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Home essentiaHome = user.getHome(home);
|
Home essentiaHome = user.getHome(home);
|
||||||
if (essentiaHome == null) {
|
if (essentiaHome == null) {
|
||||||
sender.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.parsed("home", home));
|
player.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.parsed("home", home));
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location homeLoc = essentiaHome.location();
|
Location homeLoc = essentiaHome.location();
|
||||||
if (homeLoc == null) {
|
if (homeLoc == null) {
|
||||||
sender.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.parsed("home", home));
|
player.sendRichMessage(Config.HOME_DOES_NOT_EXIST, Placeholder.parsed("home", home));
|
||||||
sender.sendRichMessage(Config.SPECIFY_HOME, Placeholder.unparsed("homelist", String.join(", ", user.getHomes())));
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
EssentiaEvent event = new PlayerTeleportHomeEvent(player, homeLoc, home);
|
||||||
EssentiaEvent event = new PlayerTeleportHomeEvent(target, homeLoc, home);
|
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
new TeleportSounds(homeLoc, target.getLocation())
|
new TeleportSounds(homeLoc, player.getLocation())
|
||||||
.runTaskLater(EssentiaPlugin.instance(), 1);
|
.runTaskLater(plugin, 1);
|
||||||
|
|
||||||
String homeName = home;
|
String homeName = home;
|
||||||
target.teleportAsync(homeLoc).thenAccept(result ->
|
player.teleportAsync(homeLoc).thenAccept(result ->
|
||||||
target.sendRichMessage(Config.HOME_TELEPORT, Placeholder.unparsed("home", homeName))
|
player.sendRichMessage(Config.HOME_TELEPORT, Placeholder.unparsed("home", homeName))
|
||||||
);
|
);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
return plugin.userManager().getUser((Player) sender).getMatchingHomeNames(args[0]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +1,29 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.commands.argumement.OfflinePlayerCompletingArgument;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.alttd.essentia.api.user.User;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
|
||||||
import io.papermc.paper.command.brigadier.Commands;
|
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
public class HomeListCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
public class HomeListCommand implements EssentiaCommand {
|
public HomeListCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "homes");
|
||||||
static String commandName = "homelist";
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
// TODO - subcommand to list other homes
|
||||||
Commands.literal(commandName)
|
// if (args.length > 0) {
|
||||||
.requires(
|
// if (!player.hasPermission("essentia.command.homes.other")) {
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName)
|
// return true;
|
||||||
)
|
// }
|
||||||
.executes((source) -> {
|
// }
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", new OfflinePlayerCompletingArgument())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
OfflinePlayer target = source.getArgument("player", OfflinePlayer.class);;
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(CommandSender sender, OfflinePlayer target) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target.getUniqueId());
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = EssentiaPlugin.instance().storageProvider().loadUser(target.getUniqueId());
|
|
||||||
|
|
||||||
// TODO - clickable homes that run /home <name>
|
// TODO - clickable homes that run /home <name>
|
||||||
sender.sendRichMessage(Config.HOME_LIST, Placeholder.unparsed("homelist", String.join(", ", user.getHomes())));
|
player.sendRichMessage(Config.HOME_LIST, Placeholder.unparsed("homelist", String.join(", ", user.getHomes())));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("homes");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,120 +1,50 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
import com.alttd.essentia.api.events.PlayerSetHomeEvent;
|
import com.alttd.essentia.api.events.PlayerSetHomeEvent;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.commands.argumement.OfflinePlayerArgument;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
|
||||||
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 net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SetHomeCommand implements EssentiaCommand {
|
public class SetHomeCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
static String commandName = "sethome";
|
|
||||||
|
public SetHomeCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "sethome");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
// TODO -- subcommand to allow setting other player homes
|
||||||
Commands.literal(commandName)
|
// if (args.length > 1) {
|
||||||
.requires(
|
// if (!player.hasPermission("essentia.command.sethome.other")) {
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
// return true;
|
||||||
commandSourceStack.getSender() instanceof Player
|
// }
|
||||||
)
|
// }
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
String home = (args.length > 0) ? args[0] : "home";
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("name", StringArgumentType.word())
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
String name = source.getArgument("name", String.class);
|
|
||||||
execute(player, player, name);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", new OfflinePlayerArgument())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.then(
|
|
||||||
Commands.argument("name", StringArgumentType.word())
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
OfflinePlayer target = source.getArgument("player", OfflinePlayer.class);
|
|
||||||
String name = source.getArgument("name", String.class);
|
|
||||||
execute(player, target, name);
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target) {
|
|
||||||
execute(sender, target, "home");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, OfflinePlayer target, String home) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target.getUniqueId());
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user = EssentiaPlugin.instance().storageProvider().loadUser(target.getUniqueId());
|
|
||||||
|
|
||||||
setHome(sender, user, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(Player sender, Player target, String home) {
|
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
setHome(sender, user, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setHome(Player sender, User user, String home) {
|
|
||||||
if (home.contains(".")) {
|
if (home.contains(".")) {
|
||||||
sender.sendRichMessage(Config.INVALID_HOME_NAME);
|
player.sendRichMessage(Config.INVALID_HOME_NAME);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasHome(home)) {
|
|
||||||
sender.sendRichMessage("<home> already exists.", Placeholder.unparsed("home", home)); // TODO -- CONFIG
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int limit = 5; // TODO -- player home limits hardcoded for now
|
int limit = 5; // TODO -- player home limits hardcoded for now
|
||||||
int count = user.getHomeCount();
|
int count = user.getHomeCount();
|
||||||
if (limit >= 0 && count >= limit) {
|
if (limit >= 0 && count >= limit) {
|
||||||
sender.sendRichMessage(Config.HOME_SET_MAX, Placeholder.unparsed("limit", String.valueOf(limit)));
|
player.sendRichMessage(Config.HOME_SET_MAX, Placeholder.unparsed("limit", String.valueOf(limit)));
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
Location homeLoc = player.getLocation();
|
||||||
Location homeLoc = sender.getLocation();
|
EssentiaEvent event = new PlayerSetHomeEvent(player, homeLoc, home);
|
||||||
EssentiaEvent event = new PlayerSetHomeEvent(sender, homeLoc, home);
|
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setHome(home, homeLoc);
|
user.setHome(home, homeLoc);
|
||||||
sender.sendRichMessage(Config.HOME_SET, Placeholder.unparsed("home", home));
|
player.sendRichMessage(Config.HOME_SET, Placeholder.unparsed("home", home));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,40 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.api.events.PlayerTeleportBackEvent;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.api.events.PlayerTeleportSpawnEvent;
|
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.events.EssentiaEvent;
|
import com.alttd.essentia.api.events.EssentiaEvent;
|
||||||
|
import com.alttd.essentia.api.events.PlayerTeleportSpawnEvent;
|
||||||
import com.alttd.essentia.tasks.TeleportSounds;
|
import com.alttd.essentia.tasks.TeleportSounds;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SpawnCommand implements EssentiaCommand {
|
public class SpawnCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
static String commandName = "spawn";
|
public SpawnCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "back");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute((Player) source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
World world = plugin.getServer().getWorld(Config.SPAWN_WORLD);
|
||||||
return;
|
|
||||||
|
|
||||||
World world = EssentiaPlugin.instance().getServer().getWorld(Config.SPAWN_WORLD);
|
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
sender.sendRichMessage("<red>Could not get the configured spawn world! contact an administrator");
|
player.sendRichMessage("<red>Could not get the configured spawn world! contact and administrator");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
Location spawnLocation = world.getSpawnLocation();
|
Location spawnLocation = world.getSpawnLocation();
|
||||||
EssentiaEvent event = new PlayerTeleportSpawnEvent(target, spawnLocation);
|
EssentiaEvent event = new PlayerTeleportSpawnEvent(player, spawnLocation);
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
new TeleportSounds(spawnLocation, target.getLocation())
|
new TeleportSounds(spawnLocation, player.getLocation())
|
||||||
.runTaskLater(EssentiaPlugin.instance(), 1);
|
.runTaskLater(plugin, 1);
|
||||||
|
|
||||||
target.teleportAsync(spawnLocation).thenAccept(result ->
|
player.teleportAsync(spawnLocation).thenAccept(result ->
|
||||||
target.sendRichMessage("Teleporting to spawn"));
|
player.sendRichMessage("Teleporting to spawn"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,27 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.request.Request;
|
import com.alttd.essentia.api.request.Request;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
public class TeleportAcceptCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
public class TeleportAcceptCommand implements EssentiaCommand {
|
public TeleportAcceptCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "teleportaccept");
|
||||||
static String commandName = "teleportaccept";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(Player player, Player target) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Request request = user.request();
|
Request request = user.request();
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
player.sendRichMessage(Config.NO_PENDING_REQUESTS);
|
player.sendRichMessage(Config.NO_PENDING_REQUESTS);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.accept();
|
request.accept();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tpyes", "tpaccpt");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,27 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.request.Request;
|
import com.alttd.essentia.api.request.Request;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
public class TeleportDenyCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
public class TeleportDenyCommand implements EssentiaCommand {
|
public TeleportDenyCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "teleportdeny");
|
||||||
static String commandName = "teleportdeny";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(Player player, Player target) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Request request = user.request();
|
Request request = user.request();
|
||||||
if (request == null) {
|
if (request == null) {
|
||||||
player.sendRichMessage(Config.NO_PENDING_REQUESTS);
|
player.sendRichMessage(Config.NO_PENDING_REQUESTS);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.deny();
|
request.deny();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tpdeny", "tpno");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,72 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.request.TeleportEssentiaRequest;
|
import com.alttd.essentia.request.TeleportEssentiaRequest;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
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;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TeleportRequestCommand implements EssentiaCommand {
|
public class TeleportRequestCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
static String commandName = "teleportrequesthere";
|
public TeleportRequestCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "teleportrequest");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(player, target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(Player player, Player target) {
|
@Override
|
||||||
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendRichMessage(Config.NO_PLAYER_SPECIFIED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.sendRichMessage(Config.PLAYER_NOT_ONLINE);
|
player.sendRichMessage(Config.PLAYER_NOT_ONLINE);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == player) {
|
if (target == player) {
|
||||||
player.sendRichMessage(Config.REQUEST_TO_SELF);
|
player.sendRichMessage(Config.REQUEST_TO_SELF);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
);
|
);
|
||||||
|
|
||||||
User targetUser = EssentiaPlugin.instance().userManager().getUser(target);
|
User targetUser = plugin.userManager().getUser(target);
|
||||||
if (targetUser.request() != null) {
|
if (targetUser.request() != null) {
|
||||||
player.sendRichMessage(Config.TARGET_HAS_PENDING_REQUEST, placeholders);
|
player.sendRichMessage(Config.TARGET_HAS_PENDING_REQUEST, placeholders);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetUser.getUserSettings().allowTeleports()) {
|
if (!targetUser.getUserSettings().allowTeleports()) {
|
||||||
player.sendRichMessage(Config.TELEPORT_TOGGLED_OFF, placeholders);
|
player.sendRichMessage(Config.TELEPORT_TOGGLED_OFF, placeholders);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetUser.request(new TeleportEssentiaRequest(EssentiaPlugin.instance(), player, target));
|
targetUser.request(new TeleportEssentiaRequest(plugin, player, target));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> aliases() {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
return List.of("tpa");
|
if (args.length == 1) {
|
||||||
|
String name = args[0].trim().toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(playerName -> playerName.toLowerCase().startsWith(name)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +1,72 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.request.TeleportHereEssentiaRequest;
|
import com.alttd.essentia.request.TeleportHereEssentiaRequest;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
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;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TeleportRequestHereCommand implements EssentiaCommand {
|
public class TeleportRequestHereCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
static String commandName = "teleportrequesthere";
|
public TeleportRequestHereCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "teleportrequesthere");
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName) &&
|
|
||||||
commandSourceStack.getSender() instanceof Player
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
if (!(source.getSource().getSender() instanceof Player player))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(player, target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(Player player, Player target) {
|
@Override
|
||||||
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
player.sendRichMessage(Config.NO_PLAYER_SPECIFIED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.sendRichMessage(Config.PLAYER_NOT_ONLINE);
|
player.sendRichMessage(Config.PLAYER_NOT_ONLINE);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == player) {
|
if (target == player) {
|
||||||
player.sendRichMessage(Config.REQUEST_TO_SELF);
|
player.sendRichMessage(Config.REQUEST_TO_SELF);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.component("target", target.displayName())
|
Placeholder.component("target", target.displayName())
|
||||||
);
|
);
|
||||||
|
|
||||||
User targetUser = EssentiaPlugin.instance().userManager().getUser(target);
|
User targetUser = plugin.userManager().getUser(target);
|
||||||
if (targetUser.request() != null) {
|
if (targetUser.request() != null) {
|
||||||
player.sendRichMessage(Config.TARGET_HAS_PENDING_REQUEST, placeholders);
|
player.sendRichMessage(Config.TARGET_HAS_PENDING_REQUEST, placeholders);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetUser.getUserSettings().allowTeleports()) {
|
if (!targetUser.getUserSettings().allowTeleports()) {
|
||||||
player.sendRichMessage(Config.TELEPORT_TOGGLED_OFF, placeholders);
|
player.sendRichMessage(Config.TELEPORT_TOGGLED_OFF, placeholders);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetUser.request(new TeleportHereEssentiaRequest(EssentiaPlugin.instance(), player, target));
|
targetUser.request(new TeleportHereEssentiaRequest(plugin, player, target));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> aliases() {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
return List.of("tpahere", "tphere");
|
if (args.length == 1) {
|
||||||
|
String name = args[0].trim().toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(playerName -> playerName.toLowerCase().startsWith(name)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,70 +1,27 @@
|
||||||
package com.alttd.essentia.commands.player;
|
package com.alttd.essentia.commands.player;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.commands.EssentiaCommand;
|
import com.alttd.essentia.commands.PlayerSubCommand;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
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.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
public class TeleportToggleCommand extends PlayerSubCommand {
|
||||||
|
|
||||||
public class TeleportToggleCommand implements EssentiaCommand {
|
public TeleportToggleCommand(EssentiaPlugin plugin) {
|
||||||
|
super(plugin, "teleporttoggle");
|
||||||
static String commandName = "teleporttoggle";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
|
||||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
|
||||||
Commands.literal(commandName)
|
|
||||||
.requires(
|
|
||||||
commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName)
|
|
||||||
)
|
|
||||||
.executes((source) -> {
|
|
||||||
if (source.getSource().getSender() instanceof Player player)
|
|
||||||
execute(player, player);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
Commands.argument("player", ArgumentTypes.player())
|
|
||||||
.requires(commandSourceStack -> commandSourceStack.getSender().hasPermission("essentia.command.player." + commandName + ".other"))
|
|
||||||
.executes((source) -> {
|
|
||||||
CommandSourceStack sourceStack = source.getSource();
|
|
||||||
Player target = source.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(sourceStack).get(0);
|
|
||||||
execute(source.getSource().getSender(), target);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(CommandSender sender, Player target) {
|
@Override
|
||||||
User user = EssentiaPlugin.instance().userManager().getUser(target);
|
protected boolean execute(Player player, User user, String... args) {
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
user.getUserSettings().allowTeleports(!user.getUserSettings().allowTeleports());
|
user.getUserSettings().allowTeleports(!user.getUserSettings().allowTeleports());
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
Placeholder.parsed("toggle", BooleanUtils.toStringOnOff(user.getUserSettings().allowTeleports()))
|
Placeholder.parsed("toggle", BooleanUtils.toStringOnOff(user.getUserSettings().allowTeleports()))
|
||||||
);
|
);
|
||||||
sender.sendRichMessage(Config.TELEPORT_TOGGLE_SET, placeholders);
|
player.sendRichMessage(Config.TELEPORT_TOGGLE_SET, placeholders);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> aliases() {
|
|
||||||
return List.of("tptoggle");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class Config {
|
||||||
config.load(CONFIG_FILE);
|
config.load(CONFIG_FILE);
|
||||||
} catch (IOException ignore) {
|
} catch (IOException ignore) {
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException ex) {
|
||||||
EssentiaPlugin.instance().getLogger().log(Level.SEVERE, "Could not load config.yml, please correct your syntax errors", ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Could not load config.yml, please correct your syntax errors", ex);
|
||||||
Throwables.throwIfUnchecked(ex);
|
Throwables.throwIfUnchecked(ex);
|
||||||
}
|
}
|
||||||
config.options().header(HEADER);
|
config.options().header(HEADER);
|
||||||
|
|
@ -44,7 +44,6 @@ public class Config {
|
||||||
version = getInt("config-version", 1);
|
version = getInt("config-version", 1);
|
||||||
set("config-version", 1);
|
set("config-version", 1);
|
||||||
|
|
||||||
EssentiaPlugin.instance().getLogger().info("Essentia Configuration loaded!");
|
|
||||||
readConfig(Config.class, null);
|
readConfig(Config.class, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +57,7 @@ public class Config {
|
||||||
} catch (InvocationTargetException ex) {
|
} catch (InvocationTargetException ex) {
|
||||||
Throwables.throwIfUnchecked(ex);
|
Throwables.throwIfUnchecked(ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
EssentiaPlugin.instance().getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +69,7 @@ public class Config {
|
||||||
try {
|
try {
|
||||||
config.save(CONFIG_FILE);
|
config.save(CONFIG_FILE);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
EssentiaPlugin.instance().getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +104,7 @@ public class Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void log(Level level, String s) {
|
protected static void log(Level level, String s) {
|
||||||
EssentiaPlugin.instance().getLogger().log(level, s);
|
Bukkit.getLogger().log(level, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int TELEPORT_REQUEST_TIMEOUT = 30;
|
public static int TELEPORT_REQUEST_TIMEOUT = 30;
|
||||||
|
|
@ -172,9 +171,6 @@ public class Config {
|
||||||
public static String TOGGLED_FLIGHT_BY_OTHER = "Toggled flight <status> on <target>.";
|
public static String TOGGLED_FLIGHT_BY_OTHER = "Toggled flight <status> on <target>.";
|
||||||
public static String TOGGLED_FLIGHT_PLAYER = "<player> toggled flight <status>.";
|
public static String TOGGLED_FLIGHT_PLAYER = "<player> toggled flight <status>.";
|
||||||
public static String TOGGLED_FLIGHT = "Toggled fly <status>.";
|
public static String TOGGLED_FLIGHT = "Toggled fly <status>.";
|
||||||
public static String TOGGLED_GOD_BY_OTHER = "Toggled God mode <status> on <target>.";
|
|
||||||
public static String TOGGLED_GOD_PLAYER = "<player> toggled God mode <status>.";
|
|
||||||
public static String TOGGLED_GOD = "Toggled God mode <status>.";
|
|
||||||
public static String NO_BACK_LOCATION = "No back location found!";
|
public static String NO_BACK_LOCATION = "No back location found!";
|
||||||
public static String TELEPORTING_BACK = "Teleporting back to previous location.";
|
public static String TELEPORTING_BACK = "Teleporting back to previous location.";
|
||||||
public static String NO_DEATH_LOCATION = "No death location found!";
|
public static String NO_DEATH_LOCATION = "No death location found!";
|
||||||
|
|
@ -195,10 +191,6 @@ public class Config {
|
||||||
public static String BURN_SELF = "You have set yourself on fire.";
|
public static String BURN_SELF = "You have set yourself on fire.";
|
||||||
public static String BURN_OTHER = "<target>'s has been set in fire.";
|
public static String BURN_OTHER = "<target>'s has been set in fire.";
|
||||||
public static String BURN_BY_OTHER = "<requester> has set you on fire.";
|
public static String BURN_BY_OTHER = "<requester> has set you on fire.";
|
||||||
|
|
||||||
public static String SMITE_SELF = "You have smited yourself.";
|
|
||||||
public static String SMITE_OTHER = "<target> has been smited.";
|
|
||||||
public static String SMITE_BY_OTHER = "<requester> has smited you.";
|
|
||||||
private static void messages() {
|
private static void messages() {
|
||||||
REQUEST_TIMED_OUT = getString("messages.request.time-out", REQUEST_TIMED_OUT);
|
REQUEST_TIMED_OUT = getString("messages.request.time-out", REQUEST_TIMED_OUT);
|
||||||
TELEPORT_ACCEPT_TARGET = getString("messages.request.teleport-accept-target", TELEPORT_ACCEPT_TARGET);
|
TELEPORT_ACCEPT_TARGET = getString("messages.request.teleport-accept-target", TELEPORT_ACCEPT_TARGET);
|
||||||
|
|
@ -250,7 +242,7 @@ public class Config {
|
||||||
FEED_BY_OTHER = getString("messages.command.feed.feed-by-other", FEED_BY_OTHER);
|
FEED_BY_OTHER = getString("messages.command.feed.feed-by-other", FEED_BY_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String STORAGE_TYPE = "YAML";
|
public static String STORAGE_TYPE = "mysql";
|
||||||
public static boolean AUTO_SAVE = true;
|
public static boolean AUTO_SAVE = true;
|
||||||
public static int AUTO_SAVE_DELAY = 60;
|
public static int AUTO_SAVE_DELAY = 60;
|
||||||
public static String MYSQL_IP = "localhost";
|
public static String MYSQL_IP = "localhost";
|
||||||
|
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
package com.alttd.essentia.listeners;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
import com.alttd.essentia.configuration.Config;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.player.*;
|
|
||||||
|
|
||||||
public class CuffListener implements Listener {
|
|
||||||
|
|
||||||
private final EssentiaPlugin plugin;
|
|
||||||
|
|
||||||
public CuffListener() {
|
|
||||||
this.plugin = EssentiaPlugin.instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isCuffed(Player player) {
|
|
||||||
UserManager userManager = plugin.userManager();
|
|
||||||
User user = userManager.getUser(player);
|
|
||||||
if (user == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return user.isCuffed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
|
||||||
if (!isCuffed(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
|
||||||
if (!isCuffed(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// if (!Config.TALKWHILECUFFED)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
cancelEvent(event, event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
|
||||||
if (!(event.getWhoClicked() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isCuffed(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
|
|
||||||
if (!isCuffed(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onProjectileLaunchEvent(ProjectileLaunchEvent event) {
|
|
||||||
if (!(event.getEntity().getShooter() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isCuffed(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onnEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|
||||||
if (!(event.getDamager() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isCuffed(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
|
||||||
if (!(event.getEntity() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isCuffed(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cancelEvent(event, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!isCuffed(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Location from = event.getFrom();
|
|
||||||
Location to = event.getTo();
|
|
||||||
|
|
||||||
if (from.getBlockY() < to.getBlockY() && player.isFlying()) {
|
|
||||||
cancelEvent(event, player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from.getWorld() != to.getWorld() || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ()) {
|
|
||||||
cancelEvent(event, player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancelEvent(Cancellable event, Player player) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
player.sendRichMessage("You can not do this while cuffed."); // TODO - config
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package com.alttd.essentia.listeners;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.model.UserSettings;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|
||||||
|
|
||||||
public class FlightListener implements Listener {
|
|
||||||
|
|
||||||
private final EssentiaPlugin plugin;
|
|
||||||
|
|
||||||
public FlightListener() {
|
|
||||||
this.plugin = EssentiaPlugin.instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
UserManager userManager = plugin.userManager();
|
|
||||||
User user = userManager.getUser(player);
|
|
||||||
if (user == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
UserSettings userSettings = user.getUserSettings();
|
|
||||||
if (userSettings.flying())
|
|
||||||
player.setFlying(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
package com.alttd.essentia.listeners;
|
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
|
||||||
import com.alttd.essentia.api.model.UserSettings;
|
|
||||||
import com.alttd.essentia.api.user.User;
|
|
||||||
import com.alttd.essentia.api.user.UserManager;
|
|
||||||
import com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|
||||||
|
|
||||||
public class GodModeListener implements Listener {
|
|
||||||
|
|
||||||
private final EssentiaPlugin plugin;
|
|
||||||
|
|
||||||
public GodModeListener() {
|
|
||||||
this.plugin = EssentiaPlugin.instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
|
||||||
if (!(event.getEntity() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isGodMode(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPhantomPreSpawn(PhantomPreSpawnEvent event) {
|
|
||||||
if (!(event.getSpawningEntity() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isGodMode(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.setShouldAbortSpawn(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onEntityTargetLivingEntity(EntityTargetLivingEntityEvent event) {
|
|
||||||
if (!(event.getEntity() instanceof Player player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isGodMode(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isGodMode(Player player) {
|
|
||||||
UserManager userManager = plugin.userManager();
|
|
||||||
User user = userManager.getUser(player);
|
|
||||||
if (user == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
UserSettings userSettings = user.getUserSettings();
|
|
||||||
return userSettings.godMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -22,8 +22,8 @@ public class PlayerListener implements Listener {
|
||||||
private final EssentiaPlugin plugin;
|
private final EssentiaPlugin plugin;
|
||||||
private final Set<PlayerTeleportEvent.TeleportCause> backAllowCauses = new HashSet<>();
|
private final Set<PlayerTeleportEvent.TeleportCause> backAllowCauses = new HashSet<>();
|
||||||
|
|
||||||
public PlayerListener() {
|
public PlayerListener(EssentiaPlugin plugin) {
|
||||||
this.plugin = EssentiaPlugin.instance();
|
this.plugin = plugin;
|
||||||
|
|
||||||
backAllowCauses.add(PlayerTeleportEvent.TeleportCause.PLUGIN);
|
backAllowCauses.add(PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
backAllowCauses.add(PlayerTeleportEvent.TeleportCause.COMMAND);
|
backAllowCauses.add(PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.alttd.essentia.model;
|
||||||
|
|
||||||
import com.alttd.essentia.api.model.UserSettings;
|
import com.alttd.essentia.api.model.UserSettings;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class EssentiaUserSettings implements UserSettings {
|
public class EssentiaUserSettings implements UserSettings {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.alttd.essentia.storage;
|
||||||
|
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.storage.mysql.SQLStorageProvider;
|
import com.alttd.essentia.storage.mysql.SQLStorageProvider;
|
||||||
import com.alttd.essentia.storage.sqlite.SQLiteStorageProvider;
|
|
||||||
import com.alttd.essentia.storage.yaml.YamlStorageProvider;
|
import com.alttd.essentia.storage.yaml.YamlStorageProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -17,10 +16,9 @@ public class StorageManager {
|
||||||
|
|
||||||
public StorageProvider storageProvider(StorageType type) {
|
public StorageProvider storageProvider(StorageType type) {
|
||||||
return switch (type) {
|
return switch (type) {
|
||||||
// case MYSQL -> new SQLStorageProvider(plugin); // FIXME
|
case MYSQL -> new SQLStorageProvider(plugin);
|
||||||
case YAML -> new YamlStorageProvider(plugin, plugin.getDataFolder().getPath() + File.separator + "PlayerData");
|
case YAML -> new YamlStorageProvider(plugin, plugin.getDataFolder().getPath() + File.separator + "PlayerData");
|
||||||
// case SQLITE -> new SQLiteStorageProvider(plugin); // FIXME
|
case SQLITE -> throw new UnsupportedOperationException(); // FIXME
|
||||||
default -> throw new UnsupportedOperationException();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,9 @@ public class YamlStorageProvider extends StorageProvider {
|
||||||
.backLocation(getStoredLocation(config,"teleports.back"))
|
.backLocation(getStoredLocation(config,"teleports.back"))
|
||||||
.deathLocation(getStoredLocation(config,"teleports.death"))
|
.deathLocation(getStoredLocation(config,"teleports.death"))
|
||||||
.homes(getHomeData(config))
|
.homes(getHomeData(config))
|
||||||
.cuffed(config.getBoolean("cuffed", false))
|
|
||||||
.userSettings(new EssentiaUserSettings
|
.userSettings(new EssentiaUserSettings
|
||||||
.Builder()
|
.Builder()
|
||||||
.flying(config.getBoolean("flying", false))
|
|
||||||
.allowTeleports(config.getBoolean("allow-teleports", true))
|
.allowTeleports(config.getBoolean("allow-teleports", true))
|
||||||
.godMode(config.getBoolean("god", false))
|
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ public class EssentiaUser implements User {
|
||||||
protected Map<String, Home> homes;
|
protected Map<String, Home> homes;
|
||||||
protected UserSettings userSettings;
|
protected UserSettings userSettings;
|
||||||
protected Request request;
|
protected Request request;
|
||||||
protected boolean cuffed;
|
|
||||||
|
|
||||||
private boolean saving;
|
private boolean saving;
|
||||||
private boolean needsSaving; // can we use a decorator for this to set it to true on every change?
|
private boolean needsSaving; // can we use a decorator for this to set it to true on every change?
|
||||||
|
|
@ -127,16 +126,6 @@ public class EssentiaUser implements User {
|
||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCuffed() {
|
|
||||||
return cuffed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCuffed(boolean cuffed) {
|
|
||||||
this.cuffed = cuffed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
protected UUID uuid;
|
protected UUID uuid;
|
||||||
|
|
@ -144,7 +133,6 @@ public class EssentiaUser implements User {
|
||||||
protected Location deathLocation = null;
|
protected Location deathLocation = null;
|
||||||
protected Map<String, Home> homes = new HashMap<>();
|
protected Map<String, Home> homes = new HashMap<>();
|
||||||
protected UserSettings userSettings = null;
|
protected UserSettings userSettings = null;
|
||||||
protected boolean cuffed = false;
|
|
||||||
|
|
||||||
public Builder uuid(UUID uuid) {
|
public Builder uuid(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
|
@ -171,11 +159,6 @@ public class EssentiaUser implements User {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder cuffed(boolean cuffed) {
|
|
||||||
this.cuffed = cuffed;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EssentiaUser build() {
|
public EssentiaUser build() {
|
||||||
return new EssentiaUser(this);
|
return new EssentiaUser(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,107 @@ main: com.alttd.essentia.EssentiaPlugin
|
||||||
description: Altitude essentials ;)
|
description: Altitude essentials ;)
|
||||||
authors:
|
authors:
|
||||||
- destro174
|
- destro174
|
||||||
api-version: "1.21"
|
api-version: "1.20"
|
||||||
|
|
||||||
|
commands:
|
||||||
|
essentia:
|
||||||
|
description: Reload configs.
|
||||||
|
permission: essentia.command.essentia-reload
|
||||||
|
usage: /<command> (reload)
|
||||||
|
teleportaccept:
|
||||||
|
description: Accept teleport request.
|
||||||
|
permission: essentia.command.teleportaccept
|
||||||
|
usage: /<command>
|
||||||
|
aliases:
|
||||||
|
- tpaccept
|
||||||
|
teleportdeny:
|
||||||
|
description: Decline teleport request.
|
||||||
|
permission: essentia.command.teleportdeny
|
||||||
|
usage: /<command>
|
||||||
|
aliases:
|
||||||
|
- tpdeny
|
||||||
|
teleportrequest:
|
||||||
|
description: Request to teleport to another player.
|
||||||
|
permission: essentia.command.teleportrequest
|
||||||
|
usage: /<command> player
|
||||||
|
aliases:
|
||||||
|
- tpa
|
||||||
|
- tprequest
|
||||||
|
- tparequest
|
||||||
|
teleportrequesthere:
|
||||||
|
description: Request another player to teleport to you.
|
||||||
|
permission: essentia.command.teleportrequesthere
|
||||||
|
usage: /<command> player
|
||||||
|
aliases:
|
||||||
|
- tpah
|
||||||
|
- tpahere
|
||||||
|
teleporttoggle:
|
||||||
|
description: Toggle teleport requests on/off.
|
||||||
|
permission: essentia.command.teleporttoggle
|
||||||
|
usage: /<command>
|
||||||
|
aliases:
|
||||||
|
- tptoggle
|
||||||
|
clearinventory:
|
||||||
|
description: Clears your inventory.
|
||||||
|
permission: essentia.command.clearinventory
|
||||||
|
usage: /<command> (player)
|
||||||
|
home:
|
||||||
|
description: Teleports the player home.
|
||||||
|
permission: essentia.command.home
|
||||||
|
usage: /<command> (home (player))
|
||||||
|
homes:
|
||||||
|
description: List the player's homes.
|
||||||
|
permission: essentia.command.homes
|
||||||
|
usage: /<command> (player)
|
||||||
|
aliases:
|
||||||
|
- listhomes
|
||||||
|
sethome:
|
||||||
|
description: Sets the player's home.
|
||||||
|
permission: essentia.command.sethome
|
||||||
|
usage: /<command> (home (player))
|
||||||
|
aliases:
|
||||||
|
- homeset
|
||||||
|
deletehome:
|
||||||
|
description: Deletes a home.
|
||||||
|
permission: essentia.command.deletehome
|
||||||
|
usage: /<command> [home (player)]
|
||||||
|
aliases:
|
||||||
|
- delhome
|
||||||
|
back:
|
||||||
|
description: Go back to previous location.
|
||||||
|
permission: essentia.command.back
|
||||||
|
usage: /<command>
|
||||||
|
deathback:
|
||||||
|
description: Go back to previous death location.
|
||||||
|
permission: essentia.command.deathback
|
||||||
|
usage: /<command>
|
||||||
|
aliases:
|
||||||
|
- dback
|
||||||
|
fly:
|
||||||
|
description: Toggles creative flymode for yourself or another player.
|
||||||
|
permission: essentia.command.fly
|
||||||
|
usage: /<command> (player)
|
||||||
|
gamemode:
|
||||||
|
description: Set gamemode for yourself or another player.
|
||||||
|
permission: essentia.command.gamemode
|
||||||
|
usage: /<command> (player)
|
||||||
|
aliases:
|
||||||
|
- gm
|
||||||
|
heal:
|
||||||
|
description: Heals yourself or another player.
|
||||||
|
permission: essentia.command.heal
|
||||||
|
usage: /<command> (player)
|
||||||
|
aliases:
|
||||||
|
- health
|
||||||
|
feed:
|
||||||
|
description: Refill hunger and saturation.
|
||||||
|
permission: essentia.command.feed
|
||||||
|
usage: /<command> (player)
|
||||||
|
enchant:
|
||||||
|
description: Enchants the item in hand
|
||||||
|
permission: essentia.command.enchant
|
||||||
|
usage: /<command> [enchantment/all] (level) (unsafe)
|
||||||
|
spawn:
|
||||||
|
description: Teleport yourself or another player to spawn.
|
||||||
|
permission: essentia.command.spawn
|
||||||
|
usage: /<command>
|
||||||
Loading…
Reference in New Issue
Block a user