geforkt von SteamWar/BungeeCore
Fixing Double Execution of Code
Dieser Commit ist enthalten in:
Ursprung
dcff5ed22f
Commit
68ce7330ef
@ -52,6 +52,15 @@ public class BanListener extends BasicListener {
|
|||||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
if(!ips.isEmpty()){
|
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()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|
||||||
@ -59,20 +68,15 @@ public class BanListener extends BasicListener {
|
|||||||
StringBuilder potentialBan = new StringBuilder();
|
StringBuilder potentialBan = new StringBuilder();
|
||||||
potentialBan.append(Message.parsePrefixed("BAN_AVOIDING_ALERT", target, user.getUserName()));
|
potentialBan.append(Message.parsePrefixed("BAN_AVOIDING_ALERT", target, user.getUserName()));
|
||||||
|
|
||||||
Timestamp highestBan = Timestamp.from(Instant.now());
|
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getId(),
|
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getId(),
|
||||||
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT), bannedUser.getUserName()));
|
banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT), bannedUser.getUserName()));
|
||||||
if(highestBan.before(banned.getTimestamp()))
|
|
||||||
highestBan = banned.getTimestamp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent msg = new TextComponent(potentialBan.toString());
|
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.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() + " "
|
msg.setClickEvent(clickEvent);
|
||||||
+ highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm"))
|
|
||||||
+ " Bannumgehung"));
|
|
||||||
target.sendMessage(msg);
|
target.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren