Archiviert
1
0

Fixing Double Execution of Code

Dieser Commit ist enthalten in:
Chaoscaot 2020-12-10 19:18:50 +01:00
Ursprung dcff5ed22f
Commit 68ce7330ef

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);
}
}