package protocolsupport;

import java.util.logging.Level;

import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import protocolsupport.injector.BungeeNettyChannelInjector;
import protocolsupport.injector.pe.PEProxyServer;
import protocolsupport.utils.Utils;

public class ProtocolSupport extends Plugin {

	private PEProxyServer peserver;

	@Override
	public void onLoad() {
		try {
			getProxy().getPluginManager().registerCommand(this, new CommandHandler());
			BungeeNettyChannelInjector.inject();
		} catch (Throwable t) {
			t.printStackTrace();
			ProxyServer.getInstance().stop();
		}
	}

	@Override
	public void onEnable() {
		if (Utils.getJavaPropertyValue("enablepe", false, Boolean::parseBoolean)) {
			getLogger().log(Level.INFO, "Enabling MCPE support");
			(peserver = new PEProxyServer()).start();
		}
	}

	@Override
	public void onDisable() {
		peserver.stop();
	}

}

@@ -881,16 +881,43 @@
 ble() %7B%0A
+%09%09if (peserver != null) %7B%0A%09
 %09%09peserv
@@ -927,14 +927,18 @@
 stop();%0A
+%09%09%7D%0A
 %09%7D%0A%0A%7D%0A

Stop PE server only if it was running