2020-11-02 20:50:51 +00:00
|
|
|
package me.totalfreedom.plex.command.impl;
|
|
|
|
|
2020-11-05 21:17:14 +00:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2020-11-02 20:50:51 +00:00
|
|
|
import me.totalfreedom.plex.command.PlexCommand;
|
2020-11-03 00:19:26 +00:00
|
|
|
import me.totalfreedom.plex.command.annotation.CommandParameters;
|
|
|
|
import me.totalfreedom.plex.command.annotation.CommandPermissions;
|
|
|
|
import me.totalfreedom.plex.command.exception.CommandArgumentException;
|
|
|
|
import me.totalfreedom.plex.command.source.CommandSource;
|
2020-11-02 20:50:51 +00:00
|
|
|
import me.totalfreedom.plex.rank.enums.Rank;
|
|
|
|
import me.totalfreedom.plex.util.PlexUtils;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static me.totalfreedom.plex.util.PlexUtils.tl;
|
|
|
|
|
|
|
|
@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
|
2020-11-03 00:19:26 +00:00
|
|
|
public void execute(CommandSource sender, String[] args)
|
2020-11-02 20:50:51 +00:00
|
|
|
{
|
2020-11-03 00:19:26 +00:00
|
|
|
if (args.length != 1)
|
|
|
|
throw new CommandArgumentException();
|
|
|
|
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
|
2020-11-03 00:19:26 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|