Working on network handler

This commit is contained in:
DaMachinator 2018-01-19 21:52:53 -05:00 committed by Arcanitor
parent 9ee1354874
commit 2c644deb5a
2 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package arcanitor.civilengineering; package arcanitor.civilengineering;
import arcanitor.civilengineering.eventhandlers.FMLEventHandler; import arcanitor.civilengineering.eventhandlers.FMLEventHandler;
import arcanitor.civilengineering.network.NetworkHandler;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.*; import net.minecraftforge.fml.common.event.*;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -22,6 +23,7 @@ public class CivilEngineering {
public static CivilEngineering instance; public static CivilEngineering instance;
public static Logger logger; public static Logger logger;
public static Thread networkThread = new Thread(new NetworkHandler());
@Mod.EventHandler @Mod.EventHandler
@ -47,4 +49,9 @@ public class CivilEngineering {
FMLEventHandler.serverStarting(event); FMLEventHandler.serverStarting(event);
} }
@Mod.EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
logger.info("Demolishing chat bridge.");
FMLEventHandler.serverStopping(event);
}
} }

View File

@ -8,6 +8,7 @@ import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import java.io.File; import java.io.File;
@ -26,6 +27,9 @@ public class FMLEventHandler {
} }
} }
public static void serverStarting(FMLServerStartingEvent event) { public static void serverStarting(FMLServerStartingEvent event) {
(new Thread(new NetworkHandler())).start(); CivilEngineering.networkThread.start();
}
public static void serverStopping(FMLServerStoppingEvent event) {
CivilEngineering.networkThread.interrupt();
} }
} }