geforkt von SteamWar/BungeeCore
Merge pull request 'Fix of Perma ban on Avoiding Alert' (#173) from perma-fix into master
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
eac3600d48
@ -21,6 +21,7 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -51,12 +52,21 @@ public class BanListener extends BasicListener {
|
|||||||
if(!ips.isEmpty()){
|
if(!ips.isEmpty()){
|
||||||
|
|
||||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||||
|
boolean perma = false;
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
if(highestBan.before(banned.getTimestamp()))
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
highestBan = banned.getTimestamp();
|
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() + " "
|
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");
|
+ " Bannumgehung");
|
||||||
|
|
||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
|
@ -149,6 +149,10 @@ public class SteamwarUser {
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Punishment getPunishment(Punishment.PunishmentType type) {
|
||||||
|
return punishments.getOrDefault(type, null);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isBanned() {
|
public boolean isBanned() {
|
||||||
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
|
if(!punishments.containsKey(Punishment.PunishmentType.Ban))
|
||||||
return false;
|
return false;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren