コード例 #1
0
        public static void HouseReload(CommandArgs args)
        {
            HConfigFile.ForceLoad();
            var reader = TShock.DB.QueryReader("Select * from HousingDistrict");

            TShock.Log.Info("House Config Reloaded");
            args.Player.SendMessage("House Config Reloaded", Color.Lime);
            HousingDistricts.Houses = new List <House>();
            while (reader.Read())
            {
                if (reader.Get <string>("WorldID") != Main.worldID.ToString())
                {
                    continue;
                }

                int           id          = reader.Get <int>("ID");
                List <string> owners      = reader.Get <string>("Owners").Split(',').ToList();
                int           locked      = reader.Get <int>("Locked");
                int           chatenabled = reader.Get <int>("ChatEnabled") == 1 ? 1 : 0;
                List <string> visitors    = reader.Get <string>("Visitors").Split(',').ToList();
                HousingDistricts.Houses.Add(new House(new Rectangle(reader.Get <int>("TopX"), reader.Get <int>("TopY"), reader.Get <int>("BottomX"), reader.Get <int>("BottomY")),
                                                      owners, id, reader.Get <string>("Name"), locked, chatenabled, visitors));
            }
            TShock.Log.Info("Houses Reloaded");
            args.Player.SendMessage("Houses Reloaded", Color.Lime);
        }
コード例 #2
0
        public override void Initialize()
        {
            HConfigFile.ForceLoad();

            ServerApi.Hooks.GameInitialize.Register(this, OnInitialize, -5);
            ServerApi.Hooks.ServerChat.Register(this, OnChat, 5);
            ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreetPlayer, -5);
            ServerApi.Hooks.ServerLeave.Register(this, OnLeave, 5);
            ServerApi.Hooks.NetGetData.Register(this, GetData, 10);
            ServerApi.Hooks.GamePostInitialize.Register(this, PostInitialize, -5);
            GetDataHandlers.InitGetDataHandler();
            if (!HConfig.DisableUpdateTimer)
            {
                Update.Elapsed += OnUpdate;
                Update.Start();
                URunning = true;
            }
        }
コード例 #3
0
 public static void SetupConfig()
 {
     try
     {
         if (File.Exists(HConfigPath))
         {
             HousingDistricts.HConfig = HConfigFile.Read(HConfigPath);
             // Add all the missing config properties in the json file
         }
         HousingDistricts.HConfig.Write(HConfigPath);
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Error in config file");
         Console.ForegroundColor = ConsoleColor.Gray;
         Log.Error("Config Exception");
         Log.Error(ex.ToString());
     }
 }
コード例 #4
0
ファイル: HConfig.cs プロジェクト: newyrose/HousingDistricts
        static HConfigFile Read()
        {
            HConfigFile cf;

            if (!File.Exists(HConfigPath))
            {
                TShock.Log.ConsoleInfo("Housing Districts config not found, creating new one...");
                cf = new HConfigFile();
                cf.Write();
                return(cf);
            }

            try
            {
                cf = JsonConvert.DeserializeObject <HConfigFile>(File.ReadAllText(HConfigPath));
                cf.Write();                 // Add missing config options
            }
            catch
            {
                TShock.Log.ConsoleError("Housing Districts config file is broken. A dummy config has been loaded.");
                cf = new HConfigFile();
            }
            return(cf);
        }
コード例 #5
0
 public HousingDistricts(Main game)
     : base(game)
 {
     HConfig = new HConfigFile();
     Order = -1;
 }
コード例 #6
0
ファイル: HConfig.cs プロジェクト: newyrose/HousingDistricts
 public static void ForceLoad()
 {
     _config = Read();
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: Olink/Twitchy-s-Housing-Mod
 public HousingDistricts(Main game)
     : base(game)
 {
     HConfig = new HConfigFile();
     Order   = -1;
 }