Reduce message spam through asynchronity
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
f8c13b627b
Commit
bc96ab6d96
@ -87,6 +87,7 @@ public class ErrorLogger extends Handler {
|
||||
contains.add("Error authenticating ");
|
||||
contains.add("read timed out");
|
||||
contains.add("Connection reset by peer");
|
||||
contains.add("No client connected for pending server");
|
||||
ignoreContains = Collections.unmodifiableList(contains);
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ package de.steamwar.bungeecore.comms;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.comms.handlers.*;
|
||||
import de.steamwar.bungeecore.comms.packets.FightEndsPacket;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@ -46,7 +47,7 @@ public class SpigotReceiver extends BasicListener {
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
Byte handler = in.readByte();
|
||||
handlerMap.get(handler).handle(in, ((Server) event.getSender()).getInfo());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> handlerMap.get(handler).handle(in, ((Server) event.getSender()).getInfo()));
|
||||
}
|
||||
|
||||
public static void registerHandler(Byte id, SpigotHandler handler) {
|
||||
|
@ -19,6 +19,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.Punishment;
|
||||
@ -40,54 +41,58 @@ public class BanListener extends BasicListener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(LoginEvent event) {
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason(user.punishmentMessage(Punishment.PunishmentType.Ban, ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
|
||||
return;
|
||||
}
|
||||
event.registerIntent(BungeeCore.get());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason(user.punishmentMessage(Punishment.PunishmentType.Ban, ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
|
||||
return;
|
||||
}
|
||||
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
if(!ips.isEmpty()){
|
||||
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||
if(!ips.isEmpty()){
|
||||
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
boolean perma = false;
|
||||
for(BannedUserIPs banned : ips) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
||||
if(ban.isPerma()) {
|
||||
perma = true;
|
||||
break;
|
||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||
boolean perma = false;
|
||||
for(BannedUserIPs banned : ips) {
|
||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
||||
if(ban.isPerma()) {
|
||||
perma = true;
|
||||
break;
|
||||
}
|
||||
if(ban.getEndTime().after(highestBan))
|
||||
highestBan = ban.getEndTime();
|
||||
}
|
||||
}
|
||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
|
||||
+ (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")))
|
||||
+ " 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.getUserName(),
|
||||
banned.getTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", target)))));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if(ban.getEndTime().after(highestBan))
|
||||
highestBan = ban.getEndTime();
|
||||
}
|
||||
}
|
||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
|
||||
+ (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")))
|
||||
+ " 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.getUserName(),
|
||||
banned.getTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", target)))));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
event.completeIntent(BungeeCore.get());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class ChatListener extends BasicListener {
|
||||
return;
|
||||
|
||||
e.setCancelled(true);
|
||||
publicChat(user, sender, e.getMessage());
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> publicChat(user, sender, e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ public class ChatListener extends BasicListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message){
|
||||
private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message) {
|
||||
String name = UserElo.getEmblem(user) + sender.getDisplayName();
|
||||
String chatcolor = user.getUserGroup().getChatColorCode();
|
||||
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.listeners;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.Session;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@ -40,7 +42,8 @@ public class SessionManager extends BasicListener {
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerDisconnectEvent e){
|
||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||
if(timestamp != null)
|
||||
Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp);
|
||||
if(timestamp != null) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren