package protocolsupport.injector.network;

import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.ServerConnection;
import protocolsupport.ProtocolSupport;
import protocolsupport.utils.Utils;
import protocolsupport.utils.Utils.Converter;

public class NettyInjector {

	private static final boolean useNonBlockingServerConnection = Utils.getJavaPropertyValue("protocolsupport.nonblockingconection", false, Converter.STRING_TO_BOOLEAN);

	public static void inject() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
		ServerConnection connection = MinecraftServer.getServer().getServerConnection();
		if (connection == null && useNonBlockingServerConnection) {
			NonBlockingServerConnection.inject();
			ProtocolSupport.logInfo("Using NonBlockingServerConnection");
		} else {
			BasicInjector.inject();
			ProtocolSupport.logInfo("Using injected ServerConnection");
		}
	}

}

@@ -296,16 +296,163 @@
 ctor %7B%0A%0A
+%09private static final boolean allowUseEpollChannel = Utils.getJavaPropertyValue(%22protocolsupport.allowepoll%22, false, Converter.STRING_TO_BOOLEAN);%0A
 %09private
@@ -822,16 +822,147 @@
 tion();%0A
+%09%09if (!allowUseEpollChannel) %7B%0A%09%09%09MinecraftServer.getServer().getPropertyManager().setProperty(%22use-native-transport%22, false);%0A%09%09%7D%0A
 %09%09if (co

Disable native transport by default unless allowed by system property.