diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 01311ea4..dfdc1100 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -130,6 +130,7 @@ namespace TShockAPI ChatCommands.Add(new Command("save", "cfg", Save)); ChatCommands.Add(new Command("maxspawns", "cfg", MaxSpawns)); ChatCommands.Add(new Command("spawnrate", "cfg", SpawnRate)); + ChatCommands.Add(new Command("setspawn", "cfg", SetSpawn)); ChatCommands.Add(new Command("time", "time", Time)); ChatCommands.Add(new Command("slap", "pvpfun", Slap)); ChatCommands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild)); @@ -859,6 +860,14 @@ namespace TShockAPI #region Server Config Commands + private static void SetSpawn(CommandArgs args) + { + Main.spawnTileX = args.Player.TileX; + Main.spawnTileY = args.Player.TileY; + ConfigurationManager.WriteJsonConfiguration(); + args.Player.SendMessage("Set server spawn point to your position"); + } + private static void DebugConfiguration(CommandArgs args) { args.Player.SendMessage("TShock Config:"); diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 7dcc74a5..49bad490 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -51,5 +51,8 @@ namespace TShockAPI public int BackupKeepFor = 60; public bool ListServer = false; + + public int spawnTileX; + public int spawnTileY; } } \ No newline at end of file diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 47844ae4..db080b18 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -110,6 +110,8 @@ namespace TShockAPI BackupInterval = cfg.BackupInterval; BackupKeepFor = cfg.BackupKeepFor; ListServer = cfg.ListServer; + Main.spawnTileX = cfg.spawnTileX; + Main.spawnTileY = cfg.spawnTileY; } public static void WriteJsonConfiguration() @@ -142,6 +144,9 @@ namespace TShockAPI cfg.BackupInterval = BackupInterval; cfg.BackupKeepFor = BackupKeepFor; cfg.ListServer = ListServer; + cfg.spawnTileX = Main.spawnTileX; + cfg.spawnTileY = Main.spawnTileY; + string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.ConfigPath); tr.Write(json);