Plex/src/main/java/dev/plex/command/impl/OpCMD.java

40 lines
1.3 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.command.impl;
2020-11-02 20:50:51 +00:00
2020-11-05 21:17:14 +00:00
import com.google.common.collect.ImmutableList;
2022-01-04 03:04:39 +00:00
import dev.plex.command.PlexCommand;
2021-01-03 07:21:15 +00:00
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandArgumentException;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
2020-11-02 20:50:51 +00:00
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
2020-11-02 20:50:51 +00:00
2022-01-04 03:04:39 +00:00
import java.util.List;
@CommandParameters(name = "op", description = "Op a player on the server", usage = "/<command> <player>")
2020-11-02 20:50:51 +00:00
@CommandPermissions(level = Rank.OP)
public class OpCMD extends PlexCommand
{
@Override
2022-01-27 05:28:30 +00:00
public Component execute(CommandSender sender, String[] args)
2020-11-02 20:50:51 +00:00
{
if (args.length != 1)
2020-11-06 01:29:38 +00:00
{
throw new CommandArgumentException();
2020-11-06 01:29:38 +00:00
}
Player player = getNonNullPlayer(args[0]);
2020-11-03 02:58:56 +00:00
player.setOp(true);
2020-11-02 20:50:51 +00:00
PlexUtils.broadcast(tl("oppedPlayer", sender.getName(), player.getName()));
return null;
2020-11-02 20:50:51 +00:00
}
@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
2020-11-05 21:17:14 +00:00
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
2020-11-02 20:50:51 +00:00
}
}