public static void saveAltars() { Set<Entry<Location, Altar>> sal = AltarManager.getAltars(); for (Entry<Location, Altar> al : sal) { try { Altar a = al.getValue(); if (a.marked()) { ResultSet r = new SQLQuery("select location from £.altar where id=" + a.getDBId() + ";", msqlc) .excecuteQuery(); while (r.next()) { new SQLQuery("delete from £.altar where id=" + a.getDBId() + ";", msqlc) .excecuteUpdate(); new SQLQuery("delete from £.locations where id=" + r.getInt(1) + ";", msqlc) .excecuteUpdate(); } } else { int idDB = a.getDBId(); if (idDB == -1) { Location l = a.getLocation(); new SQLQuery( "insert into £.locations(world,chunkx,chunkz,x,y,z) values('" + l.getWorld().getName() + "'," + l.getChunk().getX() + "," + l.getChunk().getZ() + "," + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ() + ");", msqlc) .excecuteUpdate(); ResultSet r = new SQLQuery("select max(id) from £.locations", msqlc).excecuteQuery(); while (r.next()) { new SQLQuery( "insert into £.altar(god,type,location) values(" + Utility.getDBNumberFromGodType(a.getGod().getGodType()) + ",'" + a.getType() + "'," + r.getInt(1) + ")", msqlc) .excecuteUpdate(); } } } } catch (SQLException e) { e.printStackTrace(); } } }