Ejemplo n.º 1
0
 public override void Initialize()
 {
     CheckUpdates();
     _config = Config.LoadProcedure();
     _dMgr   = DisabledManager.Start();
     if (!TShock.ServerSideCharacterConfig.Enabled)
     {
         TShock.Log.ConsoleError("[TerraJump]You need enable SSC!");
         return;
     }
     ServerApi.Hooks.GameInitialize.Register(this, OnInitialize);
     ServerApi.Hooks.PlayerTriggerPressurePlate.Register(this, OnPlayerTriggerPressurePlate);
     ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
     TShock.Log.Info("Initialization complete!");
 }
Ejemplo n.º 2
0
        public static DisabledManager Start()
        {
            bool tju = false, tjp = false;

            try
            {
                TShock.DB.Query("CREATE TABLE TJUsers(uuid TEXT, disabled INT2, pads TEXT)");
            }
            catch (Exception exe)
            {
                if (exe.HResult != -2147467259)
                {
                    throw new Exception("SQL ERROR: " + exe.HResult);
                }
                tju = true;
            }

            try
            {
                TShock.DB.Query("CREATE TABLE TJPads(x INT, y INT)");
            }
            catch (Exception exe)
            {
                if (exe.HResult != -2147467259)
                {
                    throw new Exception("SQL ERROR: " + exe.HResult);
                }
                tjp = true;
            }

            var dm = new DisabledManager
            {
                UserList     = new List <TjUser>(),
                DisabledPads = new List <PadPoint>(),
                PadDisables  = new List <PadDisable>()
            };

            if (tju)
            {
                var query = TShock.DB.QueryReader("SELECT * FROM TJUsers");
                while (query.Read())
                {
                    var user = new TjUser()
                    {
                        Uuid         = query.Get <string>("uuid"),
                        SelfDisabled = query.Get <int>("disabled") == 1,
                        DisabledPads = JsonConvert.DeserializeObject <List <PadPoint> >(query.Get <string>("pads"))
                    };
                    if (user.DisabledPads == null)
                    {
                        user.DisabledPads = new List <PadPoint>();
                    }
                    dm.UserList.Add(user);
                }
            }

            if (tjp)
            {
                var query = TShock.DB.QueryReader("SELECT * FROM TJPads");
                while (query.Read())
                {
                    dm.DisabledPads.Add(new PadPoint()
                    {
                        X = query.Get <int>("x"),
                        Y = query.Get <int>("y")
                    });
                }
            }

            dm.TryConvert();

            return(dm);
        }