diff --git a/server/src/main/java/dev/plex/command/impl/PunishmentsCMD.java b/server/src/main/java/dev/plex/command/impl/PunishmentsCMD.java index 451bb80..f2af4f4 100644 --- a/server/src/main/java/dev/plex/command/impl/PunishmentsCMD.java +++ b/server/src/main/java/dev/plex/command/impl/PunishmentsCMD.java @@ -1,14 +1,20 @@ package dev.plex.command.impl; import com.google.common.collect.ImmutableList; +import dev.plex.cache.DataUtils; import dev.plex.command.PlexCommand; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; +import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.command.source.RequiredCommandSource; +import dev.plex.menu.impl.PunishedPlayerMenu; import dev.plex.menu.impl.PunishmentMenu; +import dev.plex.player.PlexPlayer; import dev.plex.util.PlexUtils; import net.kyori.adventure.text.Component; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -23,7 +29,23 @@ public class PunishmentsCMD extends PlexCommand @Override protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args) { - new PunishmentMenu().open(playerSender); + if (args.length == 0) + { + new PunishmentMenu().open(playerSender); + } + else + { + if (!DataUtils.hasPlayedBefore(args[0])) + { + throw new PlayerNotFoundException(); + } + + final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[0]); + final PlexPlayer player = offlinePlayer.isOnline() ? getOnlinePlexPlayer(args[0]) : getOfflinePlexPlayer(offlinePlayer.getUniqueId()); + + new PunishedPlayerMenu(player).open(playerSender); + } + return null; }