protected override void Initialized(object state)
        {
            ProgramLog.Log("TDSM Rebind core build {0}", this.Version);

            //Register hook sources
            PluginManager.RegisterHookSource(typeof(TDSMHookPoints));

            CommandDictionary = new Dictionary<string, string>();

            Ops = new PairFileRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt"));
            Whitelist = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "whitelist.txt"), false);

            AddComponents<Entry>();
            RunComponent(ComponentEvent.Initialise);

            ProgramLog.Log("TDSM Rebind core enabled");
        }
        protected override void Initialized(object state)
        {
            ProgramLog.Log("TDSM Rebind core build {0}", this.Version);

            //Register hook sources
            PluginManager.RegisterHookSource(typeof(TDSMHookPoints));
            PluginManager.RegisterHookSource(typeof(Events.HookPoints));

            CommandDictionary = new Dictionary <string, string>();

            Ops       = new PairFileRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt"));
            Whitelist = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "whitelist.txt"), false);

            string configFile;

            if (!String.IsNullOrEmpty(configFile = Terraria.Initializers.LaunchInitializer.TryParameter("-config")))
            {
                Config.LoadFromFile(configFile);
            }

            Config.LoadFromArguments();

            if (!String.IsNullOrEmpty(Config.DatabaseProvider))
            {
                OTA.Data.DatabaseFactory.Initialise(Config.DatabaseProvider, Config.DatabaseConnectionString);
                Storage.IsAvailable = true;
                OTA.Permissions.Permissions.SetHandler(new OTAPIPermissions());
                Dapper.SqlMapper.AddTypeMap(typeof(PasswordFormat), System.Data.DbType.Int32);
                Dapper.SqlMapper.AddTypeMap(typeof(Byte), System.Data.DbType.Byte);

                //Test if we have a connection
                try
                {
                    using (var ctx = DatabaseFactory.CreateConnection())
                    {
                        using (var txn = ctx.BeginTransaction())
                        {
                            try
                            {
                                var count = ctx.ExecuteScalar <long>($"select 1;", transaction: txn);
//#if DEBUG
//                                ProgramLog.Debug.EnableConsoleOutput = true;
//#endif
                                if (count != 1)
                                {
                                    ProgramLog.Debug.Log("Failed to get a valid number from the database.");
                                }
                                else
                                {
                                    ProgramLog.Debug.Log("Database connected.");
                                }
                            }
                            finally
                            {
                                txn.Commit();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProgramLog.Error.Log(ex, "Failed to connect to the database.");
                }
            }

            ProgramLog.LogRotation = Config.LogRotation;

            Hook(OTA.Commands.Events.CommandEvents.Listening, OnListeningForCommands);

            AddComponents <Entry>();
            if (!RunComponent(ComponentEvent.Initialise))
            {
                this.Disable();
                ProgramLog.Log("TDSM Rebind core disabled as components are not running.");
                return;
            }

            ProgramLog.Log("TDSM Rebind core enabled");
        }
        protected override void Initialized(object state)
        {
            ProgramLog.Log("TDSM Rebind core build {0}", this.Version);

            //Register hook sources
            PluginManager.RegisterHookSource(typeof(TDSMHookPoints));
            PluginManager.RegisterHookSource(typeof(Events.HookPoints));

            CommandDictionary = new Dictionary<string, string>();

            Ops = new PairFileRegister(System.IO.Path.Combine(Globals.DataPath, "ops.txt"));
            Whitelist = new DataRegister(System.IO.Path.Combine(Globals.DataPath, "whitelist.txt"), false);

            string configFile;
            if (!String.IsNullOrEmpty(configFile = Terraria.Initializers.LaunchInitializer.TryParameter("-config")))
                Config.LoadFromFile(configFile);

            Config.LoadFromArguments();

            if (!String.IsNullOrEmpty(Config.DatabaseProvider))
            {
                OTA.Data.DatabaseFactory.Initialise(Config.DatabaseProvider, Config.DatabaseConnectionString);
                Storage.IsAvailable = true;
                OTA.Permissions.Permissions.SetHandler(new OTAPIPermissions());
                Dapper.SqlMapper.AddTypeMap(typeof(PasswordFormat), System.Data.DbType.Int32);
                Dapper.SqlMapper.AddTypeMap(typeof(Byte), System.Data.DbType.Byte);

                //Test if we have a connection
                try
                {
                    using (var ctx = DatabaseFactory.CreateConnection())
                    {
                        using (var txn = ctx.BeginTransaction())
                        {
                            try
                            {
                                var count = ctx.ExecuteScalar<long>($"select 1;", transaction: txn);
            //#if DEBUG
            //                                ProgramLog.Debug.EnableConsoleOutput = true;
            //#endif
                                if (count != 1)
                                    ProgramLog.Debug.Log("Failed to get a valid number from the database.");
                                else ProgramLog.Debug.Log("Database connected.");
                            }
                            finally
                            {
                                txn.Commit();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProgramLog.Error.Log(ex, "Failed to connect to the database.");
                }
            }

            ProgramLog.LogRotation = Config.LogRotation;

            Hook(OTA.Commands.Events.CommandEvents.Listening, OnListeningForCommands);

            AddComponents<Entry>();
            if (!RunComponent(ComponentEvent.Initialise))
            {
                this.Disable();
                ProgramLog.Log("TDSM Rebind core disabled as components are not running.");
                return;
            }

            ProgramLog.Log("TDSM Rebind core enabled");
        }