Fixes NSC list deploy

This commit is contained in:
Sotr
2018-05-30 16:28:30 +08:00
parent f6cbfe9399
commit f4fa41f759

View File

@@ -66,11 +66,6 @@ public class NonblockingServerConnection {
} }
} }
@Inject(method = "<init>", at = @At("RETURN"))
private void deployLists(CallbackInfo info) {
h = WrappedCollections.wrappedList(Lists.newCopyOnWriteArrayList());
}
@Shadow @Final private MinecraftServer f; @Shadow @Final private MinecraftServer f;
/** /**
@@ -81,6 +76,8 @@ public class NonblockingServerConnection {
registerChannels(Lists.newArrayList(LocalAddress.create(address, port))); registerChannels(Lists.newArrayList(LocalAddress.create(address, port)));
} }
private boolean needDeployList = true;
public void registerChannels(Collection<LocalAddress> data) throws IOException { public void registerChannels(Collection<LocalAddress> data) throws IOException {
Class<? extends ServerChannel> channelClass; Class<? extends ServerChannel> channelClass;
EventLoopGroup loopGroup; EventLoopGroup loopGroup;
@@ -95,6 +92,12 @@ public class NonblockingServerConnection {
logger.info("Using nio channel type"); logger.info("Using nio channel type");
} }
// Since we cannot overwrite the initializer, here is the best chance to handle it
if (needDeployList) {
h = WrappedCollections.wrappedList(Lists.newCopyOnWriteArrayList());
needDeployList = false;
}
ServerBootstrap bootstrap = new ServerBootstrap().channel(channelClass).childHandler(ChannelAdapter.create(h)).group(loopGroup); ServerBootstrap bootstrap = new ServerBootstrap().channel(channelClass).childHandler(ChannelAdapter.create(h)).group(loopGroup);
synchronized (g) { synchronized (g) {
data.addAll(Lists.transform(AkarinGlobalConfig.extraAddress, s -> { data.addAll(Lists.transform(AkarinGlobalConfig.extraAddress, s -> {