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

46 lines
1.8 KiB
Java
Raw Normal View History

2022-02-07 03:45:40 +00:00
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.CommandFailException;
import dev.plex.player.PlexPlayer;
2022-02-07 03:45:40 +00:00
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import java.util.List;
2022-02-07 03:45:40 +00:00
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unfreeze")
@CommandParameters(name = "unfreeze", description = "Unfreeze a player", usage = "/<command> <player>")
public class UnfreezeCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length != 1)
{
return usage();
2022-02-07 03:45:40 +00:00
}
Player player = getNonNullPlayer(args[0]);
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
2022-02-07 03:45:40 +00:00
if (!punishedPlayer.isFrozen())
{
2022-02-25 07:09:55 +00:00
throw new CommandFailException(PlexUtils.messageString("playerNotFrozen"));
2022-02-07 03:45:40 +00:00
}
punishedPlayer.setFrozen(false);
PlexUtils.broadcast(messageComponent("unfrozePlayer", sender.getName(), player.getName()));
return null;
2022-02-07 03:45:40 +00:00
}
@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return args.length == 1 && checkTab(sender, Rank.ADMIN, "plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
2022-02-07 03:45:40 +00:00
}
}