private void RemoveEmptyElevatorCabins(string command, string[] args) { if (!Context.IsMainPlayer) { Monitor.Log("You must be the server to do that"); return; } var toRemove = new List <Building>(); foreach (Cabin cabin in CabinHelper.GetCabinsInsides()) { if (cabin.getFarmhand().Value.Name.Length == 0) { toRemove.Add(CabinHelper.FindCabinOutside(cabin.getFarmhand())); } } foreach (Building building in toRemove) { Game1.getFarm().buildings.Remove(building); } Monitor.Log($"Removed {toRemove.Count} unused cabins"); }