2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.command.impl;
|
2020-11-03 02:58:56 +00:00
|
|
|
|
2020-11-05 21:17:14 +00:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2020-11-10 02:47:03 +00:00
|
|
|
|
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.punishment.Punishment;
|
|
|
|
import dev.plex.punishment.PunishmentType;
|
2020-11-10 02:47:03 +00:00
|
|
|
import java.time.Instant;
|
|
|
|
import java.util.Date;
|
2020-11-06 01:29:38 +00:00
|
|
|
import java.util.List;
|
2020-11-10 02:47:03 +00:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2021-01-03 07:21:15 +00:00
|
|
|
import dev.plex.cache.PlayerCache;
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.player.PunishedPlayer;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
|
|
|
import dev.plex.util.PlexUtils;
|
2020-11-03 02:58:56 +00:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2020-11-10 02:47:03 +00:00
|
|
|
@CommandParameters(description = "Freeze a player on the server", usage = "/<command> <player>")
|
2020-11-03 02:58:56 +00:00
|
|
|
@CommandPermissions(level = Rank.ADMIN)
|
|
|
|
public class FreezeCMD extends PlexCommand
|
|
|
|
{
|
|
|
|
public FreezeCMD()
|
|
|
|
{
|
|
|
|
super("freeze");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(CommandSource sender, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length != 1)
|
2020-11-06 01:29:38 +00:00
|
|
|
{
|
2020-11-03 02:58:56 +00:00
|
|
|
throw new CommandArgumentException();
|
2020-11-06 01:29:38 +00:00
|
|
|
}
|
2020-11-03 02:58:56 +00:00
|
|
|
Player player = getNonNullPlayer(args[0]);
|
|
|
|
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
|
2020-11-10 02:47:03 +00:00
|
|
|
Punishment punishment = new Punishment(UUID.fromString(punishedPlayer.getUuid()), sender.isConsoleSender() ? null : sender.getPlayer().getUniqueId());
|
|
|
|
punishment.setCustomTime(false);
|
|
|
|
punishment.setEndDate(new Date(Instant.now().plusSeconds(10).toEpochMilli()));
|
|
|
|
punishment.setType(PunishmentType.FREEZE);
|
|
|
|
punishment.setPunishedUsername(player.getName());
|
|
|
|
punishment.setReason("");
|
|
|
|
|
|
|
|
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
|
|
|
PlexUtils.broadcast(tl("frozePlayer", sender.getName(), player.getName()));
|
2020-11-03 02:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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-03 02:58:56 +00:00
|
|
|
}
|
|
|
|
}
|