SteamWar/BungeeCore
Archiviert
13
2

Ban time on ban Avoiding #158

Manuell gemergt
Lixfel hat 5 Commits von ban-listener-time nach master 2020-12-10 19:40:34 +01:00 zusammengeführt
Nur Änderungen aus Commit 68ce7330ef werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -52,6 +52,15 @@ public class BanListener extends BasicListener {
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
if(!ips.isEmpty()){
Timestamp highestBan = Timestamp.from(Instant.now());
for(BannedUserIPs banned : ips) {
if(highestBan.before(banned.getTimestamp()))
highestBan = banned.getTimestamp();
}
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
+ highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm"))
+ " Bannumgehung");
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat"))
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
@ -59,20 +68,15 @@ public class BanListener extends BasicListener {
StringBuilder potentialBan = new StringBuilder();
potentialBan.append(Message.parsePrefixed("BAN_AVOIDING_ALERT", target, user.getUserName()));
Timestamp highestBan = Timestamp.from(Instant.now());
for(BannedUserIPs banned : ips) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getId(),
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT), bannedUser.getUserName()));
if(highestBan.before(banned.getTimestamp()))
highestBan = banned.getTimestamp();
}
TextComponent msg = new TextComponent(potentialBan.toString());
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.parse("BAN_AVOIDING_BAN_HOVER", target)).create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
+ highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm"))
+ " Bannumgehung"));
msg.setClickEvent(clickEvent);
target.sendMessage(msg);
}
}