2022-02-25 08:59:48 +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;
|
2022-04-04 08:36:50 +00:00
|
|
|
import dev.plex.player.PlexPlayer;
|
2023-08-25 11:07:56 +00:00
|
|
|
|
2022-02-25 08:59:48 +00:00
|
|
|
import dev.plex.util.PlexUtils;
|
|
|
|
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;
|
|
|
|
|
2023-03-08 20:26:10 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2023-08-25 11:07:56 +00:00
|
|
|
@CommandPermissions(permission = "plex.unmute")
|
2022-02-25 08:59:48 +00:00
|
|
|
@CommandParameters(name = "unmute", description = "Unmute a player", usage = "/<command> <player>")
|
|
|
|
public class UnmuteCMD extends PlexCommand
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
|
|
|
return usage();
|
|
|
|
}
|
|
|
|
Player player = getNonNullPlayer(args[0]);
|
2022-04-04 08:36:50 +00:00
|
|
|
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
2022-02-25 08:59:48 +00:00
|
|
|
if (!punishedPlayer.isMuted())
|
|
|
|
{
|
|
|
|
throw new CommandFailException(PlexUtils.messageString("playerNotMuted"));
|
|
|
|
}
|
|
|
|
punishedPlayer.setMuted(false);
|
|
|
|
PlexUtils.broadcast(messageComponent("unmutedPlayer", sender.getName(), player.getName()));
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
|
|
{
|
2023-08-25 11:07:56 +00:00
|
|
|
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
2022-02-25 08:59:48 +00:00
|
|
|
}
|
|
|
|
}
|