mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-06 09:36:40 +00:00
Migrate (what I could find) legacy component system uses to kyori component system
Create List command Remove fionn command Remove test command Add Mojang Utils Auto add Plex Players back to cache on start if any are online
This commit is contained in:
@ -14,29 +14,29 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.ANY)
|
||||
|
||||
public class BanCMD extends PlexCommand
|
||||
{
|
||||
public BanCMD() {
|
||||
super("ban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute(CommandSender sender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
sender.send(usage(getUsage()));
|
||||
return;
|
||||
return usage(getUsage());
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
@ -51,35 +51,38 @@ public class BanCMD extends PlexCommand
|
||||
|
||||
if (isAdmin(plexPlayer))
|
||||
{
|
||||
if (!sender.isConsoleSender())
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
PlexPlayer plexPlayer1 = sender.getPlexPlayer();
|
||||
PlexPlayer plexPlayer1 = getPlexPlayer((Player) sender);
|
||||
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
|
||||
{
|
||||
sender.send(tl("higherRankThanYou"));
|
||||
return;
|
||||
return tl("higherRankThanYou");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(targetUUID) == null ? new PunishedPlayer(targetUUID) : PlayerCache.getPunishedPlayer(targetUUID);
|
||||
Punishment punishment = new Punishment(targetUUID, !sender.isConsoleSender() ? sender.getPlayer().getUniqueId() : null);
|
||||
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
punishment.setReason("");
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
//TODO: Debug End date
|
||||
punishment.setEndDate(new Date(Instant.now().plusSeconds(10/*PlexUtils.secondsToHours(24)*/).getEpochSecond()));
|
||||
punishment.setCustomTime(false);
|
||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||
Bukkit.broadcastMessage(sender.getName() + " - Banning " + plexPlayer.getName());
|
||||
Bukkit.broadcast(componentFromString(sender.getName() + " - Banning " + plexPlayer.getName()));
|
||||
if (Bukkit.getPlayer(targetUUID) != null)
|
||||
{
|
||||
Bukkit.getPlayer(targetUUID).kickPlayer("§cYou've been banned.");
|
||||
Bukkit.getPlayer(targetUUID).kick(componentFromString("&cYou've been banned."));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && isAdmin(sender) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user