public override void exec() { if (ply.Group.HasPermission("kits-reload")) { Console.WriteLine("Kits are being reloaded from file."); KitReader reader = new KitReader(); Kits.kits = reader.readFile(Path.Combine(TShockAPI.TShock.SavePath, "kits.cfg")); } else { ply.SendMessage("You do not have access to this command.", Color.Red); } }
public SignCommands(Main game) : base(game) { getConfig = new scConfig(); Order = 4; /* * Full Credit for kits goes to Olink's Kit Plugin! */ savepath = Path.Combine(TShockAPI.TShock.SavePath, "PluginConfigs/SignCommandKits.json"); KitReader reader = new KitReader(); if (File.Exists(savepath)) { kits = reader.readFile(savepath); //Console.WriteLine(kits.kits.Count + " kits have been loaded."); } else { kits = reader.writeFile(savepath); //Console.WriteLine("Basic kit file being created. 1 kit containing copper armor created. "); } }
public static void ReloadConfig(CommandArgs args) { bool iskits = false; try { if (File.Exists(TempConfigPath)) { getConfig = scConfig.Read(TempConfigPath); } getConfig.Write(TempConfigPath); args.Player.SendMessage("Sign Command Config Reloaded Successfully.", Color.MediumSeaGreen); iskits = true; KitReader reader = new KitReader(); kits = reader.readFile(Path.Combine(TShockAPI.TShock.SavePath, "kits.cfg")); return; } catch (Exception ex) { if (iskits) { args.Player.SendMessage("However, Kits failed to reload!", Color.IndianRed); } else { args.Player.SendMessage("Error: Could not reload Sign Command config, Check log for more details.", Color.IndianRed); Log.Error("Config Exception in Sign Commands config file"); Log.Error(ex.ToString()); } } }