add tempban punishment system and redo the way tempbans parse duration

This commit is contained in:
Taah
2022-04-19 13:16:07 -07:00
parent 953f1813d3
commit 98c487c639
7 changed files with 43 additions and 64 deletions

View File

@ -12,16 +12,19 @@ import dev.plex.punishment.Punishment;
import dev.plex.punishment.PunishmentType;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import java.util.List;
import java.util.UUID;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tempban", source = RequiredCommandSource.ANY)
@ -64,18 +67,17 @@ public class TempbanCMD extends PlexCommand
return messageComponent("playerBanned");
}
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
punishment.setType(PunishmentType.BAN);
punishment.setType(PunishmentType.TEMPBAN);
if (args.length > 2)
{
reason = StringUtils.join(args, " ", 2, args.length);
punishment.setReason(reason);
}
else
} else
{
punishment.setReason("No reason provided.");
}
punishment.setPunishedUsername(plexPlayer.getName());
punishment.setEndDate(PlexUtils.parseDateOffset(args[1]));
punishment.setEndDate(PlexUtils.createDate(args[1]));
punishment.setCustomTime(false);
punishment.setActive(!isAdmin(plexPlayer));
if (player != null)