Added /setspawn command, uses "cfg" permmission. Sets the spawn point of the server
This commit is contained in:
parent
5a38810305
commit
f790d9378c
3 changed files with 17 additions and 0 deletions
|
|
@ -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:");
|
||||
|
|
|
|||
|
|
@ -51,5 +51,8 @@ namespace TShockAPI
|
|||
public int BackupKeepFor = 60;
|
||||
|
||||
public bool ListServer = false;
|
||||
|
||||
public int spawnTileX;
|
||||
public int spawnTileY;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue