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;
|
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;
|
2022-02-05 23:14:23 +00:00
|
|
|
import java.time.LocalDateTime;
|
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;
|
|
|
|
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-02-07 05:53:57 +00:00
|
|
|
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>", aliases = "fr")
|
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
|
|
|
{
|
2022-02-14 05:55:50 +00:00
|
|
|
return usage();
|
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-05 23:14:23 +00:00
|
|
|
LocalDateTime date = LocalDateTime.now();
|
|
|
|
punishment.setEndDate(date.plusMinutes(5));
|
2020-11-10 02:47:03 +00:00
|
|
|
punishment.setType(PunishmentType.FREEZE);
|
|
|
|
punishment.setPunishedUsername(player.getName());
|
|
|
|
punishment.setReason("");
|
|
|
|
|
|
|
|
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
2022-02-25 07:09:55 +00:00
|
|
|
PlexUtils.broadcast(messageComponent("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-02-18 02:00:47 +00:00
|
|
|
return args.length == 1 && checkTab(sender, Rank.ADMIN, "plex.freeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
2020-11-03 02:58:56 +00:00
|
|
|
}
|
|
|
|
}
|