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("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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -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,54 +41,58 @@ public class BanListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(LoginEvent event) {
|
public void onLogin(LoginEvent event) {
|
||||||
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
event.registerIntent(BungeeCore.get());
|
||||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||||
event.setCancelled(true);
|
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
event.setCancelReason(user.punishmentMessage(Punishment.PunishmentType.Ban, ProxyServer.getInstance().getPlayer(event.getConnection().getUniqueId())));
|
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
return;
|
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());
|
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
if(!ips.isEmpty()){
|
if(!ips.isEmpty()){
|
||||||
|
|
||||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||||
boolean perma = false;
|
boolean perma = false;
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
if (bannedUser.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
Punishment ban = bannedUser.getPunishment(Punishment.PunishmentType.Ban);
|
||||||
if(ban.isPerma()) {
|
if(ban.isPerma()) {
|
||||||
perma = true;
|
perma = true;
|
||||||
break;
|
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() + " "
|
event.completeIntent(BungeeCore.get());
|
||||||
+ (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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren