Rework punishment system by deleting the Ban and BanManager and moving everything into Punishment Manager. TODO cache punishments maybe? who knows! add an active field to punishments and fix the ban service to actually unban players

This commit is contained in:
Taah
2022-02-21 16:20:22 -08:00
parent d4578f2255
commit 6f506ac5cb
16 changed files with 295 additions and 381 deletions

View File

@ -77,6 +77,7 @@ public class BanCMD extends PlexCommand
LocalDateTime date = LocalDateTime.now();
punishment.setEndDate(date.plusDays(1));
punishment.setCustomTime(false);
punishment.setActive(true);
plugin.getPunishmentManager().doPunishment(punishedPlayer, punishment);
PlexUtils.broadcast(tl("banningPlayer", sender.getName(), plexPlayer.getName()));
if (player != null)

View File

@ -0,0 +1,50 @@
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
import dev.plex.Plex;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@CommandParameters(name = "debug", description = "Debug command", usage = "/<command> <redis-reset> [player]")
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
public class DebugCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{
return usage();
}
if (args[0].equalsIgnoreCase("redis-reset"))
{
Player player = getNonNullPlayer(args[1]);
if (Plex.get().getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
{
Plex.get().getRedisConnection().getJedis().del(player.getUniqueId().toString());
return componentFromString("Successfully reset " + player.getName() + "'s redis punishments!").color(NamedTextColor.YELLOW);
}
return componentFromString("Couldn't find player in redis punishments.");
}
return null;
}
@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
}
}

View File

@ -41,12 +41,12 @@ public class UnbanCMD extends PlexCommand
throw new PlayerNotFoundException();
}
if (!plugin.getBanManager().isBanned(targetUUID))
if (!plugin.getPunishmentManager().isBanned(targetUUID))
{
throw new PlayerNotBannedException();
}
plugin.getBanManager().unban(targetUUID);
plugin.getPunishmentManager().unban(targetUUID);
PlexUtils.broadcast(tl("unbanningPlayer", sender.getName(), plexPlayer.getName()));
}
return null;