Brigadier

This commit is contained in:
2026-05-19 19:01:22 -04:00
parent 3da6b2972e
commit 66476fe110
52 changed files with 1117 additions and 1172 deletions
@@ -1,6 +1,6 @@
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import dev.plex.command.ServerCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
@@ -12,8 +12,8 @@ import dev.plex.util.TimeUtils;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.List;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -25,6 +25,17 @@ import org.jetbrains.annotations.Nullable;
@CommandPermissions(permission = "plex.tempmute")
public class TempmuteCMD extends ServerCommand
{
@Override
protected void buildCommand(LiteralArgumentBuilder<CommandSourceStack> command)
{
command.executes(context -> executeCommand(context));
command.then(playerArgument("player")
.then(word("time")
.executes(context -> executeCommand(context, string(context, "player"), string(context, "time")))
.then(greedyString("reason")
.executes(context -> executeCommand(context, argsWithGreedy(string(context, "player"), string(context, "time"), string(context, "reason")))))));
}
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
@@ -85,9 +96,4 @@ public class TempmuteCMD extends ServerCommand
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
}
}