From 817cb03dcaee50466375c1aa43d89c386ab4d5d0 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sat, 26 Feb 2022 00:24:11 -0600 Subject: [PATCH] Add tempbans --- .../java/dev/plex/command/impl/BanCMD.java | 2 +- .../dev/plex/command/impl/TempbanCMD.java | 101 ++++++++++++++ .../dev/plex/handlers/CommandHandler.java | 1 + .../dev/plex/listener/impl/BanListener.java | 16 +-- .../dev/plex/listener/impl/ChatListener.java | 4 +- .../java/dev/plex/punishment/Punishment.java | 16 ++- src/main/java/dev/plex/util/PlexUtils.java | 126 ++++++++++++++---- src/main/java/dev/plex/util/TimeUnit.java | 24 ++++ src/main/resources/config.yml | 4 +- src/main/resources/messages.yml | 24 +--- 10 files changed, 259 insertions(+), 59 deletions(-) create mode 100644 src/main/java/dev/plex/command/impl/TempbanCMD.java create mode 100644 src/main/java/dev/plex/util/TimeUnit.java diff --git a/src/main/java/dev/plex/command/impl/BanCMD.java b/src/main/java/dev/plex/command/impl/BanCMD.java index b116fb0..86b4017 100644 --- a/src/main/java/dev/plex/command/impl/BanCMD.java +++ b/src/main/java/dev/plex/command/impl/BanCMD.java @@ -88,7 +88,7 @@ public class BanCMD extends PlexCommand PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName())); if (player != null) { - player.kick(componentFromString("&cYou've been banned.")); + player.kick(Punishment.generateBanMessage(punishment)); } PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + punishedPlayer.getUuid()); return null; diff --git a/src/main/java/dev/plex/command/impl/TempbanCMD.java b/src/main/java/dev/plex/command/impl/TempbanCMD.java new file mode 100644 index 0000000..f704211 --- /dev/null +++ b/src/main/java/dev/plex/command/impl/TempbanCMD.java @@ -0,0 +1,101 @@ +package dev.plex.command.impl; + +import com.google.common.collect.ImmutableList; +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.PlayerNotBannedException; +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.List; +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 = "tempban", usage = "/