khhs167

ThreadDownloadResources.run

Sep 30th, 2022
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | Gaming | 0 0
  1. public void run() {
  2.         try {
  3.             URL downloadURL = new URL("https://raw.githubusercontent.com/Khhs167/khhs167.github.io/main/oldmc/sounddl/");
  4.             URL dataURL = new URL("https://raw.githubusercontent.com/Khhs167/khhs167.github.io/main/oldmc/sounddl/index.xml");
  5.  
  6.             DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
  7.             DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
  8.             Document xmlFile = documentBuilder.parse(dataURL.openStream());
  9.             NodeList resources = xmlFile.getElementsByTagName("Contents");
  10.  
  11.             for(int i = 0; i < 2; ++i) {
  12.                 for(int j = 0; j < resources.getLength(); ++j) {
  13.                     Node resource = resources.item(j);
  14.                     if(resource.getNodeType() == Node.ELEMENT_NODE) {
  15.                         Element resourceElement = (Element)resource;
  16.                         String name = ((Element)resourceElement.getElementsByTagName("Key").item(0)).getChildNodes().item(0).getNodeValue();
  17.                         long   size = Long.parseLong(((Element)resourceElement.getElementsByTagName("Size").item(0)).getChildNodes().item(0).getNodeValue());
  18.                         if(size > 0L) {
  19.                             this.downloadAndInstallResource(downloadURL, name, size, i);
  20.                             if(this.closing) {
  21.                                 return;
  22.                             }
  23.                         }
  24.                     }
  25.                 }
  26.             }
  27.         } catch (Exception exception13) {
  28.             this.loadResource(this.resourcesFolder, "");
  29.             exception13.printStackTrace();
  30.         }
  31.  
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment