Fixes /punishments [player] not actually working

This commit is contained in:
Video 2023-11-07 04:39:54 -07:00
parent 37ac71b6ee
commit 360775bac3

View File

@ -1,14 +1,20 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import dev.plex.cache.DataUtils;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.command.source.RequiredCommandSource; import dev.plex.command.source.RequiredCommandSource;
import dev.plex.menu.impl.PunishedPlayerMenu;
import dev.plex.menu.impl.PunishmentMenu; import dev.plex.menu.impl.PunishmentMenu;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -22,8 +28,24 @@ public class PunishmentsCMD extends PlexCommand
{ {
@Override @Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args) protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{ {
new PunishmentMenu().open(playerSender); 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; return null;
} }