public static StarverConfig Read(string path) { if (!File.Exists(path)) { var config = new StarverConfig(); config.Save(path); return(config); } return(JsonConvert.DeserializeObject <StarverConfig>(File.ReadAllText(path))); }
public override void Initialize() { Instance = this; AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { var path = Path.Combine("Nugets", args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"); if (File.Exists(path)) { return(Assembly.LoadFrom(path)); } return(null); }; Config = StarverConfig.Read(ConfigPath); Skills = new SkillManager(); PlayerDatas = new PlayerDataManager(StorageType.MySql); Players = new StarverPlayer[TShock.Players.Length]; #region Test #if false var data = new PlayerData(-444) { Level = 3 }; var skills = new PlayerSkillData[5]; skills[0] = new PlayerSkillData { ID = (byte)SkillIDs.LawAias, BindByProj = true, BindID = ProjectileID.Spear }; data.SetSkillDatas(skills); PlayerDatas.SaveData(data); #endif #endregion #region Hooks ServerApi.Hooks.ServerJoin.Register(this, OnJoin); ServerApi.Hooks.ServerLeave.Register(this, OnLeave); ServerApi.Hooks.NpcStrike.Register(this, OnNpcStrike); ServerApi.Hooks.GameUpdate.Register(this, OnUpdate); ServerApi.Hooks.NetGetData.Register(this, OnGetData); TShockAPI.Hooks.PlayerHooks.PlayerPostLogin += OnPostLogin; GetDataHandlers.NewProjectile += OnNewProjectile; #endregion #region Commands Commands.ChatCommands.Add(new Command(Perms.Normal, MainCommand, "starver")); Commands.ChatCommands.Add(new Command(Perms.Aura.Normal, AuraCommand, "aura", "au")); #endregion }