chili sauce

This commit is contained in:
Telesphoreo 2022-02-28 19:44:10 -06:00
parent 565cef61db
commit 71de135cfc
5 changed files with 86 additions and 18 deletions

View 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;
}
}

View File

@ -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") @CommandParameters(name = "plex", usage = "/<command> [reload | redis]", aliases = "plexhelp", description = "Show information about Plex or reload it")
public class PlexCMD extends PlexCommand public class PlexCMD extends PlexCommand
{ {
// Don't modify this command
@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) if (args.length == 0)
{ {
send(sender, ChatColor.LIGHT_PURPLE + "Plex - A new freedom plugin."); 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")) if (args[0].equalsIgnoreCase("reload"))
{ {
checkRank(sender, Rank.SENIOR_ADMIN, "plex.reload"); checkRank(sender, Rank.SENIOR_ADMIN, "plex.reload");
plugin.config.load();
Plex.get().config.load();
send(sender, "Reloaded config file"); send(sender, "Reloaded config file");
plugin.messages.load();
Plex.get().messages.load();
send(sender, "Reloaded messages file"); send(sender, "Reloaded messages file");
plugin.indefBans.load();
Plex.get().indefBans.load(); plugin.getPunishmentManager().mergeIndefiniteBans();
Plex.get().getPunishmentManager().mergeIndefiniteBans();
send(sender, "Reloaded indefinite bans"); send(sender, "Reloaded indefinite bans");
plugin.getRankManager().importDefaultRanks();
Plex.get().getRankManager().importDefaultRanks();
send(sender, "Imported ranks"); send(sender, "Imported ranks");
send(sender, "Plex successfully reloaded."); send(sender, "Plex successfully reloaded.");
} }
else if (args[0].equalsIgnoreCase("redis")) else if (args[0].equalsIgnoreCase("redis"))

View File

@ -35,6 +35,7 @@ public class CommandHandler extends PlexBase
commands.add(new CreativeCMD()); commands.add(new CreativeCMD());
commands.add(new FlatlandsCMD()); commands.add(new FlatlandsCMD());
commands.add(new FreezeCMD()); commands.add(new FreezeCMD());
commands.add(new KickCMD());
commands.add(new ListCMD()); commands.add(new ListCMD());
commands.add(new LocalSpawnCMD()); commands.add(new LocalSpawnCMD());
commands.add(new LockupCMD()); commands.add(new LockupCMD());

View File

@ -2,5 +2,5 @@ package dev.plex.punishment;
public enum PunishmentType public enum PunishmentType
{ {
MUTE, FREEZE, BAN; MUTE, FREEZE, BAN, KICK;
} }

View File

@ -35,14 +35,14 @@ oppedPlayer: "<aqua><v> - Opped <v>"
deoppedPlayer: "<red><v> - Deopped <v>" deoppedPlayer: "<red><v> - Deopped <v>"
# 1. The person who is freezing # 1. The person who is freezing
# 2. The person who has been frozen # 2. The person who has been frozen
frozePlayer: "<aqua><v> - Froze <v>" frozePlayer: "<red><v> - Froze <v>"
# 1. The person who is unfreezing # 1. The person who is unfreezing
# 2. The person who has been unfrozen # 2. The person who has been unfrozen
unfrozePlayer: "<aqua><v> - Unfroze <v>" unfrozePlayer: "<aqua><v> - Unfroze <v>"
# 1. The person who is muting # 1. The command sender
# 2. The person who has been muted # 2. The person who has been muted
mutedPlayer: "<aqua><v> - Muted <v>" mutedPlayer: "<red><v> - Muted <v>"
# 1. The person who is unmuting # 1. The command sender
# 2. The person who has been unmuted # 2. The person who has been unmuted
unmutedPlayer: "<aqua><v> - Unmuted <v>" unmutedPlayer: "<aqua><v> - Unmuted <v>"
# 1. The person who is locking up # 1. The person who is locking up
@ -51,7 +51,6 @@ lockedUpPlayer: "<aqua><v> - Locking up <v>"
# 1. The person who is unlocking # 1. The person who is unlocking
# 2. The person who has been unlocked # 2. The person who has been unlocked
unlockedUpPlayer: "<aqua><v> - Unlocking <v>" unlockedUpPlayer: "<aqua><v> - Unlocking <v>"
noPermission: "<red>You cannot use this command!" noPermission: "<red>You cannot use this command!"
# 1. The rank required to use the command # 1. The rank required to use the command
noPermissionRank: "<red>You must be at least <v> to use this command!" noPermissionRank: "<red>You must be at least <v> to use this command!"
@ -114,8 +113,8 @@ playerBanned: "<red>That player is already banned!"
playerFrozen: "<red>That player is already frozen!" playerFrozen: "<red>That player is already frozen!"
playerMuted: "<red>That player is already muted!" playerMuted: "<red>That player is already muted!"
playerLockedUp: "<red>That player is already locked up!" playerLockedUp: "<red>That player is already locked up!"
muted: "<red>You are currently muted - STFU!" muted: "<red>You are currently muted - STFU!"
kickedPlayer: "<red><v> - Kicking <v>"
teleportedToWorldSpawn: "<aqua>Teleporting to the local spawn" teleportedToWorldSpawn: "<aqua>Teleporting to the local spawn"
toggleCommandSpy: "CommandSpy has been" toggleCommandSpy: "CommandSpy has been"
enabled: "enabled." enabled: "enabled."