public static void Initialise()
 {
     #if Full_API
     if (Terraria.Main.dedServ)
     {
         var ctx = new HookContext()
         {
             Sender = HookContext.ConsoleSender
         };
         var args = new HookArgs.ServerStateChange()
         {
             ServerChangeState = ServerState.Initialising
         };
         HookPoints.ServerStateChange.Invoke(ref ctx, ref args);
     }
     #endif
 }
        public static bool Initialise()
        {
            #if Full_API
            if (Terraria.Main.dedServ)
            {
                var ctx = new HookContext()
                {
                    Sender = HookContext.ConsoleSender
                };
                var args = new HookArgs.ServerStateChange()
                {
                    ServerChangeState = ServerState.Starting
                };
                HookPoints.ServerStateChange.Invoke(ref ctx, ref args);

                return ctx.Result != HookResult.IGNORE;
            }
            #endif

            return true; //Allow continue
        }
        public static void StopServer(bool disconnect = true)
        {
            var ctx = new HookContext
            {
                Sender = HookContext.ConsoleSender
            };

            var args = new HookArgs.ServerStateChange
            {
                ServerChangeState = ServerState.Stopping
            };

            HookPoints.ServerStateChange.Invoke(ref ctx, ref args);

            //Statics.IsActive = Statics.keepRunning; //To keep console active & program alive upon restart;
            if (disconnect)
            {
                ProgramLog.Log("Disabling Plugins");
                PluginManager.DisablePlugins();
            }

            Console.Write("Saving world...");
            Terraria.IO.WorldFile.saveWorld(false);

            Thread.Sleep(5000);
            ProgramLog.Log("Closing Connections...");
            Netplay.disconnect = disconnect;

            Netplay.IsServerRunning = false;
        }
        public static void WorldLoadEnd()
        {
            //Since this is hook is at the end of the world loading then we can clear the new progress loading
            #if Full_API
            Terraria.Main.statusText = String.Empty;
            #endif

            var ctx = new HookContext()
            {
                Sender = HookContext.ConsoleSender
            };
            var args = new HookArgs.ServerStateChange()
            {
                ServerChangeState = ServerState.WorldLoaded
            };
            HookPoints.ServerStateChange.Invoke(ref ctx, ref args);
        }