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 KitList writeFile(String file) { TextWriter tw = new StreamWriter(file); KitList kits = new KitList(); List<KitItem> testItems = new List<KitItem>(); testItems.Add(new KitItem(76, 1)); testItems.Add(new KitItem(80, 1)); testItems.Add(new KitItem(89, 1)); kits.kits.Add(new Kit("basics", "default-kit", testItems)); tw.Write(JsonConvert.SerializeObject(kits, Formatting.Indented)); tw.Close(); return kits; }
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()); } } }