2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.services.impl;
|
2020-11-10 02:47:03 +00:00
|
|
|
|
2021-01-03 07:21:15 +00:00
|
|
|
import dev.plex.Plex;
|
2022-01-04 03:04:39 +00:00
|
|
|
import dev.plex.services.AbstractService;
|
2022-04-05 20:40:42 +00:00
|
|
|
import java.time.LocalDateTime;
|
2022-02-22 00:20:22 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
2022-01-27 21:23:01 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2020-11-10 02:47:03 +00:00
|
|
|
|
|
|
|
public class BanService extends AbstractService
|
|
|
|
{
|
2022-01-30 21:03:47 +00:00
|
|
|
public BanService()
|
|
|
|
{
|
2022-01-04 03:04:39 +00:00
|
|
|
super(true, true);
|
2020-11-10 02:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-01-30 21:03:47 +00:00
|
|
|
public void run()
|
|
|
|
{
|
2022-04-04 08:36:50 +00:00
|
|
|
Plex.get().getPunishmentManager().getActiveBans().whenComplete((punishments, throwable) ->
|
2020-11-10 02:47:03 +00:00
|
|
|
{
|
2022-04-04 08:36:50 +00:00
|
|
|
punishments.forEach(punishment ->
|
2020-11-10 02:47:03 +00:00
|
|
|
{
|
2022-04-04 08:36:50 +00:00
|
|
|
if (LocalDateTime.now().isAfter(punishment.getEndDate()))
|
|
|
|
{
|
|
|
|
Plex.get().getPunishmentManager().unban(punishment);
|
|
|
|
Bukkit.broadcast(Component.text("Plex - Unbanned " + Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-11-10 02:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-01-30 21:03:47 +00:00
|
|
|
public int repeatInSeconds()
|
|
|
|
{
|
2022-03-03 21:43:28 +00:00
|
|
|
// Every 5 minutes
|
|
|
|
return 300;
|
2020-11-10 02:47:03 +00:00
|
|
|
}
|
|
|
|
}
|