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;
|
2022-01-04 03:04:39 +00:00
|
|
|
import dev.plex.cache.PlayerCache;
|
|
|
|
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;
|
2022-01-04 03:04:39 +00:00
|
|
|
import dev.plex.player.PunishedPlayer;
|
2021-01-03 07:21:15 +00:00
|
|
|
import dev.plex.punishment.Punishment;
|
|
|
|
import dev.plex.punishment.PunishmentType;
|
2022-01-04 03:04:39 +00:00
|
|
|
import dev.plex.rank.enums.Rank;
|
|
|
|
import dev.plex.util.PlexUtils;
|
2020-11-10 02:47:03 +00:00
|
|
|
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;
|
2022-01-27 21:23:01 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
2022-02-04 08:18:07 +00:00
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
2022-01-27 21:23:01 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2022-02-04 04:49:05 +00:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2020-11-10 02:47:03 +00:00
|
|
|
|
2022-01-27 09:00:50 +00:00
|
|
|
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>")
|
2022-01-30 01:31:10 +00:00
|
|
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
2020-11-03 02:58:56 +00:00
|
|
|
public class FreezeCMD extends PlexCommand
|
|
|
|
{
|
|
|
|
@Override
|
2022-02-04 04:49:05 +00:00
|
|
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
2020-11-03 02:58:56 +00:00
|
|
|
{
|
|
|
|
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());
|
2022-01-27 09:00:50 +00:00
|
|
|
Punishment punishment = new Punishment(UUID.fromString(punishedPlayer.getUuid()), getUUID(sender));
|
2020-11-10 02:47:03 +00:00
|
|
|
punishment.setCustomTime(false);
|
2022-02-04 08:18:07 +00:00
|
|
|
Date date = new Date();
|
2022-02-05 20:43:49 +00:00
|
|
|
punishment.setEndDate(DateUtils.addMinutes(date, 5));
|
2020-11-10 02:47:03 +00:00
|
|
|
punishment.setType(PunishmentType.FREEZE);
|
|
|
|
punishment.setPunishedUsername(player.getName());
|
|
|
|
punishment.setReason("");
|
|
|
|
|
|
|
|
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
|
|
|
PlexUtils.broadcast(tl("frozePlayer", sender.getName(), player.getName()));
|
2022-01-27 09:00:50 +00:00
|
|
|
return null;
|
2020-11-03 02:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-01-27 09:00:50 +00:00
|
|
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
2020-11-03 02:58:56 +00:00
|
|
|
{
|
2022-01-27 09:00:50 +00:00
|
|
|
return args.length == 1 && isAdmin(sender) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
2020-11-03 02:58:56 +00:00
|
|
|
}
|
|
|
|
}
|