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