2022-01-04 03:04:39 +00:00
|
|
|
package dev.plex.command.impl;
|
|
|
|
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.command.annotation.CommandParameters;
|
|
|
|
import dev.plex.command.annotation.CommandPermissions;
|
2022-03-19 03:33:23 +00:00
|
|
|
import dev.plex.command.annotation.System;
|
2022-03-18 01:18:35 +00:00
|
|
|
import dev.plex.command.exception.CommandFailException;
|
2022-01-04 03:04:39 +00:00
|
|
|
import dev.plex.command.source.RequiredCommandSource;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
2022-04-07 23:23:38 +00:00
|
|
|
import dev.plex.util.PlexUtils;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2022-01-27 09:00:50 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2022-02-04 04:49:05 +00:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
2022-01-04 03:04:39 +00:00
|
|
|
|
2022-03-18 01:18:35 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.ANY)
|
2022-01-27 09:00:50 +00:00
|
|
|
@CommandParameters(name = "rank", description = "Displays your rank")
|
2022-04-01 07:54:22 +00:00
|
|
|
@System(value = "ranks")
|
2022-01-29 22:35:48 +00:00
|
|
|
public class RankCMD extends PlexCommand
|
|
|
|
{
|
2022-01-04 03:04:39 +00:00
|
|
|
@Override
|
2022-02-04 04:49:05 +00:00
|
|
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
2022-01-29 22:35:48 +00:00
|
|
|
{
|
2022-02-24 06:04:26 +00:00
|
|
|
if (args.length == 0)
|
|
|
|
{
|
2022-03-18 01:18:35 +00:00
|
|
|
if (isConsole(sender))
|
|
|
|
{
|
|
|
|
throw new CommandFailException("<red>When using the console, you must specify a player's rank.");
|
|
|
|
}
|
2022-02-24 06:04:26 +00:00
|
|
|
if (!(playerSender == null))
|
|
|
|
{
|
|
|
|
Rank rank = getPlexPlayer(playerSender).getRankFromString();
|
2022-02-25 07:09:55 +00:00
|
|
|
return messageComponent("yourRank", rank.getReadable());
|
2022-02-24 06:04:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2022-02-05 20:43:49 +00:00
|
|
|
{
|
2022-02-24 06:04:26 +00:00
|
|
|
Player player = getNonNullPlayer(args[0]);
|
|
|
|
Rank rank = getPlexPlayer(player).getRankFromString();
|
2022-02-25 07:09:55 +00:00
|
|
|
return messageComponent("otherRank", player.getName(), rank.getReadable());
|
2022-02-05 20:43:49 +00:00
|
|
|
}
|
|
|
|
return null;
|
2022-01-04 03:04:39 +00:00
|
|
|
}
|
2022-04-07 23:23:38 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
|
|
{
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
return PlexUtils.getPlayerNameList();
|
|
|
|
}
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2022-01-04 03:04:39 +00:00
|
|
|
}
|