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

41 lines
1.2 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.command.source.CommandSource;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
2020-11-02 20:50:51 +00:00
import org.bukkit.entity.Player;
2022-01-04 03:04:39 +00:00
import java.util.List;
2020-11-02 20:50:51 +00:00
@CommandParameters(description = "Op a player on the server", usage = "/<command> <player>")
@CommandPermissions(level = Rank.OP)
public class OpCMD extends PlexCommand
{
public OpCMD()
{
super("op");
}
@Override
public void execute(CommandSource 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()));
}
@Override
public List<String> onTabComplete(CommandSource sender, String[] args)
{
2020-11-05 21:17:14 +00:00
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
2020-11-02 20:50:51 +00:00
}
}