SteamWar/BungeeCore
Archiviert
13
2

Add Ban Time to Banumgehungs message and moved Messages to properties

Dieser Commit ist enthalten in:
Chaoscaot 2020-12-10 15:00:48 +01:00
Ursprung 518ba7bd35
Commit ed79088560
2 geänderte Dateien mit 24 neuen und 16 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,28 @@ 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());
}
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()));
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"));
target.sendMessage(msg);
}
}

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:
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}