Archiviert
1
0

Reduce message spam through asynchronity

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-04-02 17:51:14 +02:00
Ursprung f8c13b627b
Commit bc96ab6d96
5 geänderte Dateien mit 60 neuen und 50 gelöschten Zeilen

Datei anzeigen

@ -87,6 +87,7 @@ public class ErrorLogger extends Handler {
contains.add("Error authenticating "); contains.add("Error authenticating ");
contains.add("read timed out"); contains.add("read timed out");
contains.add("Connection reset by peer"); contains.add("Connection reset by peer");
contains.add("No client connected for pending server");
ignoreContains = Collections.unmodifiableList(contains); ignoreContains = Collections.unmodifiableList(contains);
} }
} }

Datei anzeigen

@ -21,9 +21,10 @@ package de.steamwar.bungeecore.comms;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.comms.handlers.*; import de.steamwar.bungeecore.comms.handlers.*;
import de.steamwar.bungeecore.comms.packets.FightEndsPacket;
import de.steamwar.bungeecore.listeners.BasicListener; 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.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
@ -46,7 +47,7 @@ public class SpigotReceiver extends BasicListener {
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData()); ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
Byte handler = in.readByte(); 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) { public static void registerHandler(Byte id, SpigotHandler handler) {

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.listeners; package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.BannedUserIPs; import de.steamwar.bungeecore.sql.BannedUserIPs;
import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.Punishment;
@ -40,6 +41,8 @@ public class BanListener extends BasicListener {
@EventHandler @EventHandler
public void onLogin(LoginEvent event) { public void onLogin(LoginEvent event) {
event.registerIntent(BungeeCore.get());
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection()); SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
if (user.isPunished(Punishment.PunishmentType.Ban)) { if (user.isPunished(Punishment.PunishmentType.Ban)) {
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress()); user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
@ -89,5 +92,7 @@ public class BanListener extends BasicListener {
} }
} }
} }
event.completeIntent(BungeeCore.get());
});
} }
} }

Datei anzeigen

@ -167,7 +167,7 @@ public class ChatListener extends BasicListener {
return; return;
e.setCancelled(true); 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 name = UserElo.getEmblem(user) + sender.getDisplayName();
String chatcolor = user.getUserGroup().getChatColorCode(); String chatcolor = user.getUserGroup().getChatColorCode();

Datei anzeigen

@ -19,8 +19,10 @@
package de.steamwar.bungeecore.listeners; package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.Session; import de.steamwar.bungeecore.sql.Session;
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.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
@ -40,7 +42,8 @@ public class SessionManager extends BasicListener {
@EventHandler @EventHandler
public void onDisconnect(PlayerDisconnectEvent e){ public void onDisconnect(PlayerDisconnectEvent e){
Timestamp timestamp = sessions.remove(e.getPlayer()); Timestamp timestamp = sessions.remove(e.getPlayer());
if(timestamp != null) if(timestamp != null) {
Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp));
}
} }
} }