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:
Commit
e917e7f465
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
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.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BanListener extends BasicListener {
|
public class BanListener extends BasicListener {
|
||||||
@ -47,27 +51,32 @@ 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()){
|
||||||
StringBuilder potentialBan = new StringBuilder();
|
|
||||||
potentialBan.append(BungeeCore.CHAT_PREFIX);
|
|
||||||
potentialBan.append("§cMögliche Bannumgehung durch §r");
|
|
||||||
potentialBan.append(user.getUserName());
|
|
||||||
potentialBan.append("§c:");
|
|
||||||
|
|
||||||
|
Timestamp highestBan = Timestamp.from(Instant.now());
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
if(highestBan.before(banned.getTimestamp()))
|
||||||
potentialBan.append(" §e");
|
highestBan = banned.getTimestamp();
|
||||||
potentialBan.append(banned.getTimestamp().toLocalDateTime().format(BungeeCore.DATE_FORMAT));
|
|
||||||
potentialBan.append(" §c");
|
|
||||||
potentialBan.append(bannedUser.getUserName());
|
|
||||||
}
|
}
|
||||||
|
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()){
|
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
|
||||||
|| target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN)){
|
|| 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);
|
target.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,6 +214,12 @@ public class SteamwarUser {
|
|||||||
if(player != null){
|
if(player != null){
|
||||||
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
updateBanIP(player.getAddress().getAddress().getHostAddress());
|
||||||
player.disconnect(banMessage());
|
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
|
}else
|
||||||
updateBanIP("");
|
updateBanIP("");
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,9 @@ USAGE_IGNORE=§8/§7ignore §8[§eSpieler§8]
|
|||||||
ALERT=§f{0}
|
ALERT=§f{0}
|
||||||
|
|
||||||
BAN_MESSAGE_YOU=§7Du hast §e{0} §7gebannt§8. §7Grund§8: §c{1}
|
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}
|
MUTE_MESSAGE_YOU=§7Du hast §e{0} §7gemutet§8. §7Grund§8: §c{1}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren