コード例 #1
0
        private void OnInitialize(EventArgs args)
        {
            Directory.CreateDirectory("worldregen");

            string path = Path.Combine(TShock.SavePath, "WorldRegeneration.json");
            Config = Config.Read(path);
            if (!File.Exists(path))
            {
                Config.Write(path);
            }

            #region Commands
            Action<Command> Add = c =>
            {
                TShockAPI.Commands.ChatCommands.RemoveAll(c2 => c2.Names.Select(s => s.ToLowerInvariant()).Intersect(c.Names.Select(s => s.ToLowerInvariant())).Any());
                TShockAPI.Commands.ChatCommands.Add(c);
            };

            Add(new Command(Permissions.saveworld, Commands.SaveWorld, "saveworld")
            {
                AllowServer = true,
                HelpText = "Save the world and its contents."
            });

            Add(new Command(Permissions.loadworld, Commands.LoadWorld, "loadworld")
            {
                AllowServer = true,
                HelpText = "Load the world and its contents."
            });

            Add(new Command(Permissions.worldregen, Commands.WorldRegen, "worldregen")
            {
                AllowServer = true,
                HelpText = "Various sub-commands for world regeneration."
            });
            #endregion

            RegenTimer.Elapsed += OnWorldRegeneration;
            RegenTimer.Start();
        }
コード例 #2
0
 public void OnReload(ReloadEventArgs args)
 {
     string path = Path.Combine(TShock.SavePath, "WorldRegeneration.json");
     Config = Config.Read(path);
     if (!File.Exists(path))
     {
         Config.Write(path);
     }
     args.Player.SendSuccessMessage("[World Regeneration] Reloaded configuration file and data!");
 }