Mirror the listeners field

This commit is contained in:
ME1312 2022-12-18 14:30:32 -05:00
parent d8463e25c5
commit cf07e86a09
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
6 changed files with 17 additions and 8 deletions

View File

@ -28,7 +28,7 @@
<dependency> <dependency>
<groupId>net.ME1312.Galaxi</groupId> <groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiBase</artifactId> <artifactId>GalaxiBase</artifactId>
<version>22w24a</version> <version>22w50c</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -1,9 +1,12 @@
package net.ME1312.SubServers.Bungee; 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.BungeeCord;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import java.io.IOException; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -13,8 +16,10 @@ import java.util.function.Supplier;
public abstract class BungeeCommon extends BungeeCord { public abstract class BungeeCommon extends BungeeCord {
private static BungeeCommon instance; private static BungeeCommon instance;
final Supplier<BungeeAPI> api; final Supplier<BungeeAPI> api;
protected final Collection<Channel> listeners;
protected BungeeCommon(Supplier<BungeeAPI> api) throws IOException { protected BungeeCommon(Supplier<BungeeAPI> api) throws Exception {
listeners= Util.reflect(BungeeCord.class.getDeclaredField("listeners"), this);
this.api = api; this.api = api;
instance = this; instance = this;
} }

View File

@ -34,6 +34,7 @@ import net.ME1312.SubServers.Bungee.Network.SubProtocol;
import com.dosse.upnp.UPnP; import com.dosse.upnp.UPnP;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.netty.channel.Channel;
import net.md_5.bungee.BungeeServerInfo; import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -92,6 +93,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
public SubProtocol subprotocol; public SubProtocol subprotocol;
public SubDataServer subdata = null; public SubDataServer subdata = null;
public SubServer sudo = null; public SubServer sudo = null;
public final Collection<Channel> listeners = super.listeners;
public static final Version version = Version.fromString("2.19a"); public static final Version version = Version.fromString("2.19a");
public final Proxy mProxy; public final Proxy mProxy;
@ -825,7 +827,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
} }
private boolean shutdown = false; private boolean shutdown = false;
protected void shutdown() { void shutdown() {
if (ready) { if (ready) {
legServers.clear(); legServers.clear();
legServers.putAll(getServersCopy()); legServers.putAll(getServersCopy());
@ -833,7 +835,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
Logger.get("SubServers").info("Stopping hosted servers"); Logger.get("SubServers").info("Stopping hosted servers");
String[] hosts = this.hosts.keySet().toArray(new String[0]); String[] hosts = this.hosts.keySet().toArray(new String[0]);
if (shutdown || !super.isRunning) running = false; if (shutdown) running = false;
for (String host : hosts) { for (String host : hosts) {
api.forceRemoveHost(host); api.forceRemoveHost(host);
} }

View File

@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>net.ME1312.Galaxi</groupId> <groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiBase</artifactId> <artifactId>GalaxiBase</artifactId>
<version>22w24a</version> <version>22w50c</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -30,13 +30,13 @@
<dependency> <dependency>
<groupId>net.ME1312.Galaxi</groupId> <groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId> <artifactId>GalaxiEngine</artifactId>
<version>22w24a</version> <version>22w50c</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.ME1312.Galaxi</groupId> <groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUI</artifactId> <artifactId>GalaxiUI</artifactId>
<version>22w24a</version> <version>22w50c</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -32,6 +32,7 @@ import net.ME1312.SubServers.Sync.Server.SubServerImpl;
import com.dosse.upnp.UPnP; import com.dosse.upnp.UPnP;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.netty.channel.Channel;
import net.md_5.bungee.BungeeServerInfo; import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ProxyServer; 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 Plugin plugin;
public final SubAPI api = new SubAPI(this); public final SubAPI api = new SubAPI(this);
public SubProtocol subprotocol; public SubProtocol subprotocol;
public final Collection<Channel> listeners = super.listeners;
public static final Version version = Version.fromString("2.19a"); public static final Version version = Version.fromString("2.19a");
public final boolean isPatched; public final boolean isPatched;