SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Ban time on ban Avoiding' (#158) from ban-listener-time into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2020-12-10 19:40:33 +01:00
Commit e917e7f465
3 geänderte Dateien mit 32 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.BannedUserIPs;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ProxyServer;
@ -31,6 +32,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.event.EventHandler;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.List;
public class BanListener extends BasicListener {
@ -47,27 +51,32 @@ public class BanListener extends BasicListener {
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
if(!ips.isEmpty()){
StringBuilder potentialBan = new StringBuilder();
potentialBan.append(BungeeCore.CHAT_PREFIX);
potentialBan.append("§cMögliche Bannumgehung durch §r");
potentialBan.append(user.getUserName());
potentialBan.append("§c:");
for(BannedUserIPs banned : ips){
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
potentialBan.append(" §e");
potentialBan.append(banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT));
potentialBan.append(" §c");
potentialBan.append(bannedUser.getUserName());
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");
TextComponent msg = new TextComponent(potentialBan.toString());
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cBanne Spieler wegen Bannumgehung").create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " perma Bannumgehung"));
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat"))
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|| target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN)){
StringBuilder potentialBan = new StringBuilder();
potentialBan.append(Message.parsePrefixed("BAN_AVOIDING_ALERT", target, user.getUserName()));
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()));
}
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(clickEvent);
target.sendMessage(msg);
}
}

Datei anzeigen

@ -214,6 +214,12 @@ public class SteamwarUser {
if(player != null){
updateBanIP(player.getAddress().getAddress().getHostAddress());
player.disconnect(banMessage());
for (BannedUserIPs banned:
BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) {
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
if(bannedUser.isBanned() && banned.getTimestamp().before(time))
bannedUser.ban(time, bannedUser.banReason);
}
}else
updateBanIP("");
}

Datei anzeigen

@ -93,6 +93,9 @@ USAGE_IGNORE=§8/§7ignore §8[§eSpieler§8]
ALERT=§f{0}
BAN_MESSAGE_YOU=§7Du hast §e{0} §7gebannt§8. §7Grund§8: §c{1}
BAN_AVOIDING_ALERT=§cMögliche Bannumgehung durch §r{0}§c: §c
BAN_AVOIDING_LIST={0} §e{1} §c
BAN_AVOIDING_BAN_HOVER=§cBanne Spieler wegen Bannumgehung
MUTE_MESSAGE_YOU=§7Du hast §e{0} §7gemutet§8. §7Grund§8: §c{1}