From a028db546246aa09c5264c3af568d970134e104c Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 Sep 2022 11:51:36 +0200 Subject: [PATCH 1/3] Show no Chat Reports (Next to chat and Server List for NoChatReportsMod) --- src/de/steamwar/bungeecore/BungeeCore.java | 3 ++ .../bungeecore/listeners/mods/Forge.java | 5 ---- .../listeners/ping/PingListener.java | 13 +++++++++ .../SteamWarServerPing.java} | 29 +++++-------------- 4 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 src/de/steamwar/bungeecore/listeners/ping/PingListener.java rename src/de/steamwar/bungeecore/listeners/{mods/FMLPing.java => ping/SteamWarServerPing.java} (68%) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index e319ed6..df18fb2 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.listeners.*; import de.steamwar.bungeecore.listeners.mods.*; +import de.steamwar.bungeecore.listeners.ping.PingListener; import de.steamwar.bungeecore.network.BungeeNetworkHandler; import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.sql.*; @@ -77,6 +78,7 @@ public class BungeeCore extends Plugin { public void onEnable(){ getProxy().registerChannel("sw:bridge"); getProxy().registerChannel("fabricmodsender:mods"); + getProxy().registerChannel("nochatreports:sync"); setInstance(this); MAIN_SERVER = ProxyServer.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565); @@ -110,6 +112,7 @@ public class BungeeCore extends Plugin { new BrandListener(); new Fabric(); new SubserverProtocolFixer(); + new PingListener(); local = new Node.LocalNode(); //new Node.RemoteNode("lx"); diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 6d274e6..94a0fa2 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -55,11 +55,6 @@ public class Forge extends BasicListener { initialHandlerCh.setAccessible(true); } - @EventHandler - public void onServerPing(ProxyPingEvent event) { - event.setResponse(new FMLPing(event.getResponse(), event.getConnection().getVersion())); - } - public static void onServerConnected(LoginEvent event) { if(event.getConnection().getVersion() < 341) { //1.13+ event.completeIntent(BungeeCore.get()); diff --git a/src/de/steamwar/bungeecore/listeners/ping/PingListener.java b/src/de/steamwar/bungeecore/listeners/ping/PingListener.java new file mode 100644 index 0000000..95bb277 --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/ping/PingListener.java @@ -0,0 +1,13 @@ +package de.steamwar.bungeecore.listeners.ping; + +import de.steamwar.bungeecore.listeners.BasicListener; +import net.md_5.bungee.api.event.ProxyPingEvent; +import net.md_5.bungee.event.EventHandler; + +public class PingListener extends BasicListener { + + @EventHandler + public void onPing(ProxyPingEvent event) { + event.setResponse(new SteamWarServerPing(event.getResponse(), event.getConnection().getVersion())); + } +} diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java similarity index 68% rename from src/de/steamwar/bungeecore/listeners/mods/FMLPing.java rename to src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java index a8b5994..9d91975 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java +++ b/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java @@ -1,32 +1,17 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ -package de.steamwar.bungeecore.listeners.mods; +package de.steamwar.bungeecore.listeners.ping; import net.md_5.bungee.api.ServerPing; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; -public class FMLPing extends ServerPing { +public class SteamWarServerPing extends ServerPing { + private final boolean preventsChatReports = true; private final ForgeData forgeData; - public FMLPing(ServerPing existing, int version) { + public SteamWarServerPing(ServerPing existing, int version) { super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject()); forgeData = new ForgeData(version); } From 1168f8cc862e71c1cd3ed65172f5037db18f7590 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 Sep 2022 11:52:57 +0200 Subject: [PATCH 2/3] Add Copyright --- .../listeners/ping/SteamWarServerPing.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java b/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java index 9d91975..76240ac 100644 --- a/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java +++ b/src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2022 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package de.steamwar.bungeecore.listeners.ping; import net.md_5.bungee.api.ServerPing; From 4c0afb4bbdd9cc2355a0aa78a597917e50c03221 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 18 Sep 2022 11:53:29 +0200 Subject: [PATCH 3/3] More Copyright --- .../listeners/ping/PingListener.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/de/steamwar/bungeecore/listeners/ping/PingListener.java b/src/de/steamwar/bungeecore/listeners/ping/PingListener.java index 95bb277..a7bbf6e 100644 --- a/src/de/steamwar/bungeecore/listeners/ping/PingListener.java +++ b/src/de/steamwar/bungeecore/listeners/ping/PingListener.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2022 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + package de.steamwar.bungeecore.listeners.ping; import de.steamwar.bungeecore.listeners.BasicListener;