SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Made By EinJavaDev | Nils S.
  3.  * ©ERAPED | Nils S. Network-Systems
  4.  */
  5.  
  6. package de.EinJavaDev.ERAPED.FileUtils;
  7.  
  8. import com.google.gson.Gson;
  9. import com.google.gson.GsonBuilder;
  10. import de.EinJavaDev.ERAPED.utils.Logger;
  11. import org.json.JSONObject;
  12.  
  13. import java.io.*;
  14. import java.net.URL;
  15. import java.net.URLConnection;
  16. import java.nio.file.Files;
  17. import java.nio.file.Paths;
  18.  
  19. public class Spigot_DownloadStream {
  20.  
  21.     public static File Spigot = new File("./Master/Reposetorys/Spigot/spigot-1.14.4.jar");
  22.  
  23.     private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
  24.  
  25.     private File reposetory = new File("./Master/Reposetorys/Spigot");
  26.  
  27.     private String spigot1_8_8 = "https://cdn.getbukkit.org/spigot/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar";
  28.     private String spigot1_9 = "https://cdn.getbukkit.org/spigot/spigot-1.9-R0.1-SNAPSHOT-latest.jar";
  29.     private String spigot1_9_2 = "https://cdn.getbukkit.org/spigot/spigot-1.9.2-R0.1-SNAPSHOT-latest.jar";
  30.     private String spigot1_9_4 = "https://cdn.getbukkit.org/spigot/spigot-1.9.4-R0.1-SNAPSHOT-latest.jar";
  31.     private String spigot1_10 = "https://cdn.getbukkit.org/spigot/spigot-1.10-R0.1-SNAPSHOT-latest.jar";
  32.     private String spigot1_10_2 = "https://cdn.getbukkit.org/spigot/spigot-1.10.2-R0.1-SNAPSHOT-latest.jar";
  33.     private String spigot1_11 = "https://cdn.getbukkit.org/spigot/spigot-1.11.jar";
  34.     private String spigot1_11_1 = "https://cdn.getbukkit.org/spigot/spigot-1.11.1.jar";
  35.     private String spigot1_11_2 = "https://cdn.getbukkit.org/spigot/spigot-1.11.2.jar";
  36.     private String spigot1_12 = "https://cdn.getbukkit.org/spigot/spigot-1.12.jar";
  37.     private String spigot1_12_1 = "https://cdn.getbukkit.org/spigot/spigot-1.12.1.jar";
  38.     private String spigot1_12_2 = "https://cdn.getbukkit.org/spigot/spigot-1.12.2.jar";
  39.     private String spigot1_13_2 = "https://cdn.getbukkit.org/spigot/spigot-1.13.2.jar";
  40.     private String spigot1_14_4 = "https://cdn.getbukkit.org/spigot/spigot-1.14.4.jar";
  41.  
  42.     public Spigot_DownloadStream(){
  43.         getSpigots(spigot1_8_8, "/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar");
  44.         getSpigots(spigot1_9, "/spigot-1.9-R0.1-SNAPSHOT-latest.jar");
  45.         getSpigots(spigot1_9_2, "/spigot-1.9.2-R0.1-SNAPSHOT-latest.jar");
  46.         getSpigots(spigot1_9_4, "/spigot-1.9.4-R0.1-SNAPSHOT-latest.jar");
  47.         getSpigots(spigot1_10, "/spigot-1.10-R0.1-SNAPSHOT-latest.jar");
  48.         getSpigots(spigot1_10_2, "/spigot-1.10.2-R0.1-SNAPSHOT-latest.jar");
  49.         getSpigots(spigot1_11, "/spigot-1.11.jar");
  50.         getSpigots(spigot1_11_1, "/spigot-1.11.2.jar");
  51.         getSpigots(spigot1_11_2, "/spigot-1.11.2.jar");
  52.         getSpigots(spigot1_12, "/spigot-1.12.jar");
  53.         getSpigots(spigot1_12_1, "/spigot-1.12.1.jar");
  54.         getSpigots(spigot1_12_2, "/spigot-1.12.2.jar");
  55.         getSpigots(spigot1_13_2, "/spigot-1.13.2.jar");
  56.         getSpigots(spigot1_14_4, "/spigot-1.14.4.jar");
  57.         InitConfig();
  58.         Logger.debug("Spigot Reposetory Done!");
  59.     }
  60.  
  61.     private void getSpigots(String Url, String FileName){
  62.         URL url ;
  63.         URLConnection con;
  64.         DataInputStream dis;
  65.         FileOutputStream fos;
  66.         byte[] fileData;
  67.         try {
  68.             url = new URL(Url);
  69.             con = url.openConnection();
  70.             dis = new DataInputStream(con.getInputStream());
  71.             fileData = new byte[con.getContentLength()];
  72.             for (int q = 0; q < fileData.length; q++) {
  73.             }
  74.             dis.close();
  75.             fos = new FileOutputStream(new File(reposetory + FileName));
  76.             fos.write(fileData);
  77.             fos.close();
  78.         } catch (Exception m) {
  79.             Logger.error("die " + FileName + " konnte nicht Heruntergeladen werden!");
  80.             m.printStackTrace();
  81.         }
  82.     }
  83.     public void InitConfig(){
  84.         //TODO: SERVER CONFIG
  85.         if (Files.exists(Paths.get("./Master/Versions.json"))) {
  86.             return;
  87.         }
  88.         try {
  89.             File templatecfg = new File("./Master/Reposetorys/Spigot/Config.json");
  90.             JSONObject obj = new JSONObject();
  91.             obj.put("Spigot.1", spigot1_8_8);
  92.             obj.put("Spigot.2", spigot1_9);
  93.             obj.put("Spigot.3", spigot1_9_2);
  94.             obj.put("Spigot.4", spigot1_9_4);
  95.             obj.put("Spigot.5", spigot1_10);
  96.             obj.put("Spigot.6", spigot1_10_2);
  97.             obj.put("Spigot.7", spigot1_11);
  98.             obj.put("Spigot.8", spigot1_11_1);
  99.             obj.put("Spigot.9", spigot1_11_2);
  100.             obj.put("Spigot.10", spigot1_12);
  101.             obj.put("Spigot.11", spigot1_12_1);
  102.             obj.put("Spigot.12", spigot1_12_2);
  103.             obj.put("Spigot.13", spigot1_13_2);
  104.             obj.put("Spigot.14", spigot1_14_4);
  105.             FileWriter fw = new FileWriter(templatecfg);
  106.             fw.write(this.gson.toJson(obj));
  107.             fw.flush();
  108.             fw.close();
  109.         } catch (IOException ex){
  110.             ex.printStackTrace();
  111.         }
  112.     }
  113. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top