@Override public void refreshList(String[] sss) throws Exception { String content = NetUtils.doGet("http://optifine.net/downloads"); if (versions != null) return; versionMap = new HashMap<>(); versions = new ArrayList<>(); content = content.replace(" ", " ").replace(">", ">").replace("<", "<"); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder db = factory.newDocumentBuilder(); Document doc = db.parse(new StringBufferInputStream(content)); Element r = doc.getDocumentElement(); NodeList tables = r.getElementsByTagName("table"); for (int i = 0; i < tables.getLength(); i++) { Element e = (Element) tables.item(i); if ("downloadTable".equals(e.getAttribute("class"))) { NodeList tr = e.getElementsByTagName("tr"); for (int k = 0; k < tr.getLength(); k++) { NodeList downloadLine = ((Element) tr.item(k)).getElementsByTagName("td"); OptiFineVersion v = new OptiFineVersion(); for (int j = 0; j < downloadLine.getLength(); j++) { Element td = (Element) downloadLine.item(j); if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineMirror")) v.mirror = ((Element) td.getElementsByTagName("a").item(0)).getAttribute("href"); if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDownload")) v.dl = ((Element) td.getElementsByTagName("a").item(0)).getAttribute("href"); if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineDate")) v.date = td.getTextContent(); if (StrUtils.startsWith(td.getAttribute("class"), "downloadLineFile")) v.ver = td.getTextContent(); } if (StrUtils.isBlank(v.mcver)) { Pattern p = Pattern.compile("OptiFine (.*?) "); Matcher m = p.matcher(v.ver); while (m.find()) v.mcver = StrUtils.formatVersion(m.group(1)); } InstallerVersion iv = new InstallerVersion(v.ver, StrUtils.formatVersion(v.mcver)); iv.installer = iv.universal = v.mirror; root.add(v); versions.add(iv); List<InstallerVersion> ivl = ArrayUtils.tryGetMapWithList(versionMap, StrUtils.formatVersion(v.mcver)); ivl.add(iv); } } } } catch (ParserConfigurationException | SAXException | IOException | DOMException ex) { throw new RuntimeException(ex); } Collections.sort(versions, InstallerVersionComparator.INSTANCE); }