Skip to content

Commit

Permalink
Mirror the listeners field
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Dec 18, 2022
1 parent d8463e2 commit cf07e86
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion SubServers.Bungee/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiBase</artifactId>
<version>22w24a</version>
<version>22w50c</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -13,8 +16,10 @@
public abstract class BungeeCommon extends BungeeCord {
private static BungeeCommon instance;
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;
instance = this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
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;
Expand Down Expand Up @@ -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<Channel> listeners = super.listeners;
public static final Version version = Version.fromString("2.19a");

public final Proxy mProxy;
Expand Down Expand Up @@ -825,15 +827,15 @@ public void stopListeners() {
}

private boolean shutdown = false;
protected void shutdown() {
void shutdown() {
if (ready) {
legServers.clear();
legServers.putAll(getServersCopy());
ready = false;

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);
}
Expand Down
2 changes: 1 addition & 1 deletion SubServers.Client/Common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiBase</artifactId>
<version>22w24a</version>
<version>22w50c</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions SubServers.Host/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>22w24a</version>
<version>22w50c</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUI</artifactId>
<version>22w24a</version>
<version>22w50c</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
2 changes: 2 additions & 0 deletions SubServers.Sync/src/net/ME1312/SubServers/Sync/ExProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

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;
Expand Down Expand Up @@ -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<Channel> listeners = super.listeners;
public static final Version version = Version.fromString("2.19a");

public final boolean isPatched;
Expand Down

0 comments on commit cf07e86

Please sign in to comment.