mirror of
https://github.com/plexusorg/Plex.git
synced 2025-06-28 22:46:40 +00:00
chili sauce
This commit is contained in:
71
src/main/java/dev/plex/command/impl/KickCMD.java
Normal file
71
src/main/java/dev/plex/command/impl/KickCMD.java
Normal file
@ -0,0 +1,71 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
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.player.PlexPlayer;
|
||||
import dev.plex.player.PunishedPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||
public class KickCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
|
||||
UUID targetUUID = PlexUtils.getFromName(args[0]);
|
||||
String reason = "No reason provided";
|
||||
|
||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||
Player player = Bukkit.getPlayer(targetUUID);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(targetUUID) == null ? new PunishedPlayer(targetUUID) : PlayerCache.getPunishedPlayer(targetUUID);
|
||||
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
|
||||
punishment.setType(PunishmentType.KICK);
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
punishment.setReason(reason);
|
||||
}
|
||||
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
punishment.setEndDate(LocalDateTime.now());
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(false);
|
||||
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("kickedPlayer", sender.getName(), plexPlayer.getName()));
|
||||
player.kick(componentFromString(reason));
|
||||
return null;
|
||||
}
|
||||
}
|
@ -20,31 +20,28 @@ import org.jetbrains.annotations.Nullable;
|
||||
@CommandParameters(name = "plex", usage = "/<command> [reload | redis]", aliases = "plexhelp", description = "Show information about Plex or reload it")
|
||||
public class PlexCMD extends PlexCommand
|
||||
{
|
||||
// Don't modify this command
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
send(sender, ChatColor.LIGHT_PURPLE + "Plex - A new freedom plugin.");
|
||||
return componentFromString(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + plugin.getDescription().getVersion());
|
||||
send(sender, ChatColor.LIGHT_PURPLE + "Plugin version: " + plugin.getDescription().getVersion());
|
||||
return componentFromString(ChatColor.LIGHT_PURPLE + "Authors: " + ChatColor.GOLD + "Telesphoreo, Taahh");
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
checkRank(sender, Rank.SENIOR_ADMIN, "plex.reload");
|
||||
|
||||
Plex.get().config.load();
|
||||
plugin.config.load();
|
||||
send(sender, "Reloaded config file");
|
||||
|
||||
Plex.get().messages.load();
|
||||
plugin.messages.load();
|
||||
send(sender, "Reloaded messages file");
|
||||
|
||||
Plex.get().indefBans.load();
|
||||
Plex.get().getPunishmentManager().mergeIndefiniteBans();
|
||||
plugin.indefBans.load();
|
||||
plugin.getPunishmentManager().mergeIndefiniteBans();
|
||||
send(sender, "Reloaded indefinite bans");
|
||||
|
||||
Plex.get().getRankManager().importDefaultRanks();
|
||||
plugin.getRankManager().importDefaultRanks();
|
||||
send(sender, "Imported ranks");
|
||||
|
||||
send(sender, "Plex successfully reloaded.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("redis"))
|
||||
|
@ -35,6 +35,7 @@ public class CommandHandler extends PlexBase
|
||||
commands.add(new CreativeCMD());
|
||||
commands.add(new FlatlandsCMD());
|
||||
commands.add(new FreezeCMD());
|
||||
commands.add(new KickCMD());
|
||||
commands.add(new ListCMD());
|
||||
commands.add(new LocalSpawnCMD());
|
||||
commands.add(new LockupCMD());
|
||||
|
@ -2,5 +2,5 @@ package dev.plex.punishment;
|
||||
|
||||
public enum PunishmentType
|
||||
{
|
||||
MUTE, FREEZE, BAN;
|
||||
MUTE, FREEZE, BAN, KICK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user