From 575ef6fb087a67bebab273b39ec1b1a747613b63 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 2 Feb 2021 23:42:00 +0100 Subject: [PATCH] Fix of Perma ban on Avoiding Alert --- .../bungeecore/listeners/BanListener.java | 16 +++++++++++++--- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/BanListener.java b/src/de/steamwar/bungeecore/listeners/BanListener.java index 80f666e..2daabde 100644 --- a/src/de/steamwar/bungeecore/listeners/BanListener.java +++ b/src/de/steamwar/bungeecore/listeners/BanListener.java @@ -21,6 +21,7 @@ package de.steamwar.bungeecore.listeners; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.BannedUserIPs; +import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.ClickEvent; @@ -51,12 +52,21 @@ public class BanListener extends BasicListener { if(!ips.isEmpty()){ Timestamp highestBan = ips.get(0).getTimestamp(); + boolean perma = false; for(BannedUserIPs banned : ips) { - if(highestBan.before(banned.getTimestamp())) - highestBan = banned.getTimestamp(); + SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID()); + if(bannedUser.isBanned()) { + Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban); + if(ban.isPerma()) { + perma = true; + break; + } + if(ban.getEndTime().after(highestBan)) + highestBan = ban.getEndTime(); + } } ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " " - + highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")) + + (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm"))) + " Bannumgehung"); for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 4c5b562..1a1aefd 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -149,6 +149,10 @@ public class SteamwarUser { return team; } + public Punishment getPunishment(Punishment.PunishmentType type) { + return punishments.getOrDefault(type, null); + } + public boolean isBanned() { if(!punishments.containsKey(Punishment.PunishmentType.Ban)) return false; -- 2.39.2