public static InfChest GetChest(int x, int y) { string query = $"SELECT * FROM InfChests3 WHERE X = {x} AND Y = {y} AND WorldID = {Main.worldID};"; using (var reader = db.QueryReader(query)) { if (reader.Read()) { InfChest chest = new InfChest(reader.Get <int>("UserID"), x, y, Main.worldID) { id = reader.Get <int>("ID"), isPublic = reader.Get <int>("Public") == 1 ? true : false, refill = reader.Get <int>("Refill") }; chest.StringToGroups(reader.Get <string>("Groups")); chest.StringToUsers(reader.Get <string>("Users")); chest.StringToItems(reader.Get <string>("Items")); return(chest); } else { return(null); } } }
public static List <Chest> GetAllChests() { string query = "SELECT * FROM InfChests3 WHERE WorldID = " + Main.worldID + ";"; using (var reader = db.QueryReader(query)) { List <Chest> chests = new List <Chest>(); while (reader.Read()) { InfChest ichest = new InfChest(-1, reader.Get <int>("X"), reader.Get <int>("Y"), Main.worldID); ichest.StringToItems(reader.Get <string>("Items")); Chest chest = new Chest() { item = ichest.items, x = ichest.x, y = ichest.y }; chests.Add(chest); } return(chests); } }