From cf07e86a09534ed7cc2a3fad3adea237488101c9 Mon Sep 17 00:00:00 2001 From: ME1312 Date: Sun, 18 Dec 2022 14:30:32 -0500 Subject: [PATCH] Mirror the listeners field --- SubServers.Bungee/common/pom.xml | 2 +- .../src/net/ME1312/SubServers/Bungee/BungeeCommon.java | 9 +++++++-- .../src/net/ME1312/SubServers/Bungee/SubProxy.java | 6 ++++-- SubServers.Client/Common/pom.xml | 2 +- SubServers.Host/pom.xml | 4 ++-- .../src/net/ME1312/SubServers/Sync/ExProxy.java | 2 ++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/SubServers.Bungee/common/pom.xml b/SubServers.Bungee/common/pom.xml index 1e819260..0026d870 100644 --- a/SubServers.Bungee/common/pom.xml +++ b/SubServers.Bungee/common/pom.xml @@ -28,7 +28,7 @@ net.ME1312.Galaxi GalaxiBase - 22w24a + 22w50c compile diff --git a/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeCommon.java b/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeCommon.java index b68cd25b..2f1b1774 100644 --- a/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeCommon.java +++ b/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeCommon.java @@ -1,9 +1,12 @@ package net.ME1312.SubServers.Bungee; +import net.ME1312.Galaxi.Library.Util; + +import io.netty.channel.Channel; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.config.ServerInfo; -import java.io.IOException; +import java.util.Collection; import java.util.Map; import java.util.function.Supplier; @@ -13,8 +16,10 @@ import java.util.function.Supplier; public abstract class BungeeCommon extends BungeeCord { private static BungeeCommon instance; final Supplier api; + protected final Collection listeners; - protected BungeeCommon(Supplier api) throws IOException { + protected BungeeCommon(Supplier api) throws Exception { + listeners= Util.reflect(BungeeCord.class.getDeclaredField("listeners"), this); this.api = api; instance = this; } diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubProxy.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubProxy.java index 8a6789d7..b02a7205 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubProxy.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubProxy.java @@ -34,6 +34,7 @@ import net.ME1312.SubServers.Bungee.Network.SubProtocol; import com.dosse.upnp.UPnP; import com.google.common.collect.Range; import com.google.gson.Gson; +import io.netty.channel.Channel; import net.md_5.bungee.BungeeServerInfo; import net.md_5.bungee.UserConnection; import net.md_5.bungee.api.ChatColor; @@ -92,6 +93,7 @@ public final class SubProxy extends BungeeCommon implements Listener { public SubProtocol subprotocol; public SubDataServer subdata = null; public SubServer sudo = null; + public final Collection listeners = super.listeners; public static final Version version = Version.fromString("2.19a"); public final Proxy mProxy; @@ -825,7 +827,7 @@ public final class SubProxy extends BungeeCommon implements Listener { } private boolean shutdown = false; - protected void shutdown() { + void shutdown() { if (ready) { legServers.clear(); legServers.putAll(getServersCopy()); @@ -833,7 +835,7 @@ public final class SubProxy extends BungeeCommon implements Listener { Logger.get("SubServers").info("Stopping hosted servers"); String[] hosts = this.hosts.keySet().toArray(new String[0]); - if (shutdown || !super.isRunning) running = false; + if (shutdown) running = false; for (String host : hosts) { api.forceRemoveHost(host); } diff --git a/SubServers.Client/Common/pom.xml b/SubServers.Client/Common/pom.xml index 9b69b12e..6f9a493d 100644 --- a/SubServers.Client/Common/pom.xml +++ b/SubServers.Client/Common/pom.xml @@ -18,7 +18,7 @@ net.ME1312.Galaxi GalaxiBase - 22w24a + 22w50c compile diff --git a/SubServers.Host/pom.xml b/SubServers.Host/pom.xml index de496c0b..53f5ccce 100644 --- a/SubServers.Host/pom.xml +++ b/SubServers.Host/pom.xml @@ -30,13 +30,13 @@ net.ME1312.Galaxi GalaxiEngine - 22w24a + 22w50c compile net.ME1312.Galaxi GalaxiUI - 22w24a + 22w50c runtime diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/ExProxy.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/ExProxy.java index 2140d939..77cd3b7d 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/ExProxy.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/ExProxy.java @@ -32,6 +32,7 @@ import net.ME1312.SubServers.Sync.Server.SubServerImpl; import com.dosse.upnp.UPnP; import com.google.gson.Gson; +import io.netty.channel.Channel; import net.md_5.bungee.BungeeServerInfo; import net.md_5.bungee.UserConnection; import net.md_5.bungee.api.ProxyServer; @@ -74,6 +75,7 @@ public final class ExProxy extends BungeeCommon implements Listener { public final Plugin plugin; public final SubAPI api = new SubAPI(this); public SubProtocol subprotocol; + public final Collection listeners = super.listeners; public static final Version version = Version.fromString("2.19a"); public final boolean isPatched;