diff --git a/src/forgemodpackbuilder/GUI.form b/src/forgemodpackbuilder/GUI.form index 34b2eea..c5d9e8d 100644 --- a/src/forgemodpackbuilder/GUI.form +++ b/src/forgemodpackbuilder/GUI.form @@ -24,9 +24,10 @@ - + + @@ -39,8 +40,8 @@ - - + + @@ -51,7 +52,7 @@ - + @@ -96,7 +97,8 @@ - + + @@ -199,11 +201,12 @@ - - - - - + + + + + + @@ -246,5 +249,7 @@ + + diff --git a/src/forgemodpackbuilder/GUI.java b/src/forgemodpackbuilder/GUI.java index d045f78..7d56d01 100644 --- a/src/forgemodpackbuilder/GUI.java +++ b/src/forgemodpackbuilder/GUI.java @@ -8,6 +8,7 @@ package forgemodpackbuilder; import java.awt.event.KeyEvent; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.DefaultListModel; @@ -20,8 +21,8 @@ import javax.swing.JOptionPane; public class GUI extends javax.swing.JFrame { static String datei = null; - static String[] mods1 = new String[300]; - static String[] mods2 = new String[300]; + static ArrayList mods0 = new ArrayList(); + static ArrayList mods1 = new ArrayList(); static String version = "1.10.2"; /** @@ -56,6 +57,7 @@ public class GUI extends javax.swing.JFrame { jButton8 = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); jButton7 = new javax.swing.JButton(); + jProgressBar1 = new javax.swing.JProgressBar(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("ForgeModpackBuilder"); @@ -109,7 +111,7 @@ public class GUI extends javax.swing.JFrame { } }); - jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1.10.2", "1.9.4", "1.8.9", "1.7.10" })); + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Modpacks", "1.10.2", "1.9.4", "1.8.9", "1.7.10" })); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); @@ -151,6 +153,7 @@ public class GUI extends javax.swing.JFrame { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(4, 4, 4) @@ -162,8 +165,8 @@ public class GUI extends javax.swing.JFrame { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) @@ -173,7 +176,7 @@ public class GUI extends javax.swing.JFrame { .addComponent(jButton8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 537, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 537, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE) @@ -207,7 +210,8 @@ public class GUI extends javax.swing.JFrame { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) .addComponent(jScrollPane3)) - .addGap(26, 26, 26)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); @@ -228,24 +232,46 @@ public class GUI extends javax.swing.JFrame { private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: - File dir = new File("./modpack/modpack"); - dir.mkdir(); - dir = new File("./modpack/modpack/mods"); - dir.mkdir(); - for (int i = 0; i < 200; i++) { - mods1[i] = null; - mods2[i] = null; + //jProgressBar1.setValue(10); + String s = (String) jComboBox1.getSelectedItem(); + System.out.println(s); + version = s; + try { + if (!version.equals("Modpacks")) { + File dir = new File("./modpack/" + version); + dir.mkdir(); + dir = new File("./modpack/" + version + "/mods"); + dir.mkdir(); + } + File dir = new File("./modpack/modpack"); + dir.mkdir(); + dir = new File("./modpack/modpack/mods"); + dir.mkdir(); + mods0.clear(); + mods1.clear(); + if (version.equals("Modpacks")) { + ModpackSuche.main(null); + } else { + Suche.main(null); + } + Suche1.main(null); + System.out.println("Tabelle 1 Mods = " + mods0.size()); + DefaultListModel dim = new DefaultListModel(); + DefaultListModel dim1 = new DefaultListModel(); + for (int i = 0; i < mods0.size(); i++) { + dim.addElement(mods0.get(i)); + } + System.out.println("Tabelle 2 Mods = " + mods1.size()); + for (int i = 0; i < mods1.size(); i++) { + dim1.addElement(mods1.get(i)); + } + jList1.setModel(dim); + jList2.setModel(dim1); + } catch (java.lang.NullPointerException ex) { + System.out.println("VerbindungsFehler 404!!!"); + } catch (IOException ex) { + System.out.println("Fehler!!!"); } - Suche.main(mods1); - Suche1.main(mods2); - DefaultListModel dim = new DefaultListModel(); - DefaultListModel dim1 = new DefaultListModel(); - for (int i = 0; i < 200; i++) { - dim.addElement(mods1[i]); - dim1.addElement(mods2[i]); - } - jList1.setModel(dim); - jList2.setModel(dim1); }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed @@ -278,13 +304,6 @@ public class GUI extends javax.swing.JFrame { private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed // TODO add your handling code here: - String s = (String) jComboBox1.getSelectedItem(); - System.out.println(s); - version = s; - File dir = new File("./modpack/" + version); - dir.mkdir(); - dir = new File("./modpack/" + version + "/mods"); - dir.mkdir(); jButton2ActionPerformed(evt); }//GEN-LAST:event_jComboBox1ActionPerformed @@ -292,19 +311,32 @@ public class GUI extends javax.swing.JFrame { private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed // TODO add your handling code here: try { - JOptionPane.showMessageDialog(null, "Bitte geben sie den Pfad zu dem Modpack ein!"); - OeffnenDialogClass.main(null); - OeffnenDialogClass a = new OeffnenDialogClass(); - System.out.println("GUI = " + datei); - UnZip.modpack = datei; - JOptionPane.showMessageDialog(null, "Bitte geben sie einen Installationsort für das Modpack!"); - OeffnenDialogClass.main(null); - System.out.println("GUI = " + datei); - UnZip.modpack1 = datei; - UnZip.main(); + if (!version.equals("Modpacks")) { + JOptionPane.showMessageDialog(null, "Bitte geben sie den Pfad zu dem Modpack ein!"); + OeffnenDialogClass.main(null); + OeffnenDialogClass a = new OeffnenDialogClass(); + System.out.println("GUI = " + datei); + UnZip.modpack = datei; + JOptionPane.showMessageDialog(null, "Bitte geben sie einen Installationsort für das Modpack!"); + OeffnenDialogClass.main(null); + System.out.println("GUI = " + datei); + UnZip.modpack1 = datei; + UnZip.main(); + } else { + ModpackDownloader.modpack = jList1.getSelectedValue(); + JOptionPane.showMessageDialog(null, "Bitte geben sie einen Installationsort für das Modpack!"); + OeffnenDialogClass.main(null); + System.out.println("GUI = " + datei); + File dir = new File(datei + "/mods"); + dir.mkdir(); + ModpackDownloader.install = datei; + ModpackDownloader.main(null); + } jButton4ActionPerformed(evt); } catch (java.lang.NullPointerException ex) { - System.out.println("Keine Eingabe"); + System.out.println("Keine Eingabe!!!"); + }catch (IOException ex) { + System.out.println("Fehler!!!"); } //jButton3ActionPerformed(evt); }//GEN-LAST:event_jButton6ActionPerformed @@ -336,7 +368,7 @@ public class GUI extends javax.swing.JFrame { // TODO add your handling code here: downloader.main(null); downloader1.main(null); - VerzeichnisDurchsuchen3.main(null); + Suche3.main(null); DateiKopierenClass1.main(null); DateiKopierenClass2.main(null); String file = "./modpack/modpack/" + GUI.datei.substring(GUI.datei.lastIndexOf("/") + 1); @@ -415,6 +447,7 @@ public class GUI extends javax.swing.JFrame { private javax.swing.JLabel jLabel2; private javax.swing.JList jList1; private javax.swing.JList jList2; + private javax.swing.JProgressBar jProgressBar1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JTextField jTextField1; diff --git a/src/forgemodpackbuilder/ModpackDownloader.java b/src/forgemodpackbuilder/ModpackDownloader.java new file mode 100644 index 0000000..9666630 --- /dev/null +++ b/src/forgemodpackbuilder/ModpackDownloader.java @@ -0,0 +1,102 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package forgemodpackbuilder; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; + +/** + * + * @author simonr + */ +public class ModpackDownloader { + + static String install; + static String modpack = "Xerxes"; + static ArrayList text = new ArrayList(); + + public static void main(String[] args) throws MalformedURLException, IOException { + + final URL url = new URL("https://www.dropbox.com/s/n91j0wjb88s8341/URL.txt?dl=1"); + final URLConnection conn = url.openConnection(); + try (InputStream is = new BufferedInputStream(conn.getInputStream())) { + final OutputStream os; + os = new BufferedOutputStream(new FileOutputStream("./modpack/Modpacks/URL.txt")); + byte[] chunk = new byte[1024]; + int chunkSize; + while ((chunkSize = is.read(chunk)) != -1) { + os.write(chunk, 0, chunkSize); + } + os.flush(); // Necessary for Java < 6 + os.close(); + + //Modpack URL Suchen + FileReader fr = new FileReader("./modpack/Modpacks/URL.txt"); + BufferedReader br = new BufferedReader(fr); + + String zeile = ""; + + int b = 0; + while (!(zeile.equals(modpack))) { + zeile = br.readLine(); + System.out.println(zeile); + text.add(zeile); + b++; + } + System.out.println(text.get(b - 2)); + + br.close(); + + //Modpack Installieren + ModpackDownloader2.URL = text.get(b - 2); + ModpackDownloader2.output = "./modpack/Modpacks/Modpack.txt"; + ModpackDownloader2.main(null); + text.clear(); + + FileReader fr1 = new FileReader("./modpack/Modpacks/Modpack.txt"); + BufferedReader br1 = new BufferedReader(fr1); + + String zeile1 = ""; + + while ((zeile1 = br1.readLine()) != null) { + System.out.println(zeile1); + + FileReader fr2 = new FileReader("./modpack/Modpacks/URL.txt"); + BufferedReader br2 = new BufferedReader(fr2); + + b = 0; + zeile = ""; + while (!(zeile.equals(modpack))) { + zeile = br2.readLine(); + System.out.println(zeile); + text.add(zeile); + b++; + } + + br2.close(); + + ModpackDownloader2.URL = text.get(b - 2); + ModpackDownloader2.output = install + "/mods/" + zeile1; + ModpackDownloader2.main(null); + text.clear(); + + } + + br1.close(); + + } + } +} diff --git a/src/forgemodpackbuilder/ModpackDownloader2.java b/src/forgemodpackbuilder/ModpackDownloader2.java new file mode 100644 index 0000000..80b8178 --- /dev/null +++ b/src/forgemodpackbuilder/ModpackDownloader2.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package forgemodpackbuilder; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +/** + * + * @author simonr + */ +public class ModpackDownloader2 { + + static String URL; + static String output; + + public static void main(String[] args) throws MalformedURLException, IOException { + + final URL url = new URL(URL); + final URLConnection conn = url.openConnection(); + try (InputStream is = new BufferedInputStream(conn.getInputStream())) { + final OutputStream os; + os = new BufferedOutputStream(new FileOutputStream(output)); + byte[] chunk = new byte[1024]; + int chunkSize; + while ((chunkSize = is.read(chunk)) != -1) { + os.write(chunk, 0, chunkSize); + } + os.flush(); // Necessary for Java < 6 + os.close(); + + } + } +} diff --git a/src/forgemodpackbuilder/ModpackSuche.java b/src/forgemodpackbuilder/ModpackSuche.java new file mode 100644 index 0000000..b3a78cd --- /dev/null +++ b/src/forgemodpackbuilder/ModpackSuche.java @@ -0,0 +1,58 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package forgemodpackbuilder; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * + * @author simonr + */ +public class ModpackSuche { + + public static void main(String[] args) throws IOException { + + final URL url = new URL("https://www.dropbox.com/s/fjy9lnv5ga00hq4/Modpacks.txt?dl=1"); + final URLConnection conn = url.openConnection(); + try (InputStream is = new BufferedInputStream(conn.getInputStream())) { + final OutputStream os; + os = new BufferedOutputStream(new FileOutputStream("./modpack/Modpacks/Modpacks.txt")); + byte[] chunk = new byte[1024]; + int chunkSize; + while ((chunkSize = is.read(chunk)) != -1) { + os.write(chunk, 0, chunkSize); + } + os.flush(); // Necessary for Java < 6 + os.close(); + + // Datei durchsuchen + FileReader fr = new FileReader("./modpack/Modpacks/Modpacks.txt"); + BufferedReader br = new BufferedReader(fr); + String zeile; + + while ((zeile = br.readLine()) != null) { + GUI.mods0.add(zeile); + } + System.out.println("Zeilen = " + GUI.mods0.size()); + + for (int i = 0; i < GUI.mods0.size(); i++) { + System.out.println(GUI.mods0.get(i)); + } + br.close(); + + } + + } +} diff --git a/src/forgemodpackbuilder/Modpacktxt.java b/src/forgemodpackbuilder/Modpacktxt.java new file mode 100644 index 0000000..049c8e2 --- /dev/null +++ b/src/forgemodpackbuilder/Modpacktxt.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package forgemodpackbuilder; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; + +/** + * + * @author simonr + */ +public class Modpacktxt { + + static String name; + + public static void main(String[] args) throws IOException { + + FileWriter fw = new FileWriter(name + ".txt"); + BufferedWriter bw = new BufferedWriter(fw); + + for (int i = 0; i < GUI.mods1.size(); i++) { + bw.write(GUI.mods1.get(i).substring( GUI.mods1.get(i).lastIndexOf( "/" ) + 1 )); + bw.newLine(); + } + bw.close(); + } + +} diff --git a/src/forgemodpackbuilder/Suche.java b/src/forgemodpackbuilder/Suche.java index 4e00fe4..014a8ec 100644 --- a/src/forgemodpackbuilder/Suche.java +++ b/src/forgemodpackbuilder/Suche.java @@ -28,8 +28,7 @@ public class Suche { if (fileThatYouWantToFilter.startsWith(name) && fileThatYouWantToFilter.endsWith(".jar")) { System.out.println("found" + " " + fileThatYouWantToFilter); - GUI.mods1[i] = "./modpack/" + GUI.version + "/mods/" + fileThatYouWantToFilter; - i++; + GUI.mods0.add("./modpack/" + GUI.version + "/mods/" + fileThatYouWantToFilter); } } } diff --git a/src/forgemodpackbuilder/Suche1.java b/src/forgemodpackbuilder/Suche1.java index df7aea5..e1e6fd4 100644 --- a/src/forgemodpackbuilder/Suche1.java +++ b/src/forgemodpackbuilder/Suche1.java @@ -28,8 +28,7 @@ public class Suche1 { if (fileThatYouWantToFilter.startsWith(name) && fileThatYouWantToFilter.endsWith(".jar")) { System.out.println("found" + " " + fileThatYouWantToFilter); - GUI.mods2[i] = "./modpack/modpack/mods/" + fileThatYouWantToFilter; - i++; + GUI.mods1.add("./modpack/modpack/mods/" + fileThatYouWantToFilter); } } } diff --git a/src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java b/src/forgemodpackbuilder/Suche2.java similarity index 94% rename from src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java rename to src/forgemodpackbuilder/Suche2.java index 6682daf..1b779b6 100644 --- a/src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java +++ b/src/forgemodpackbuilder/Suche2.java @@ -11,7 +11,7 @@ package forgemodpackbuilder; */ import java.io.File; -public class VerzeichnisDurchsuchen2 { +public class Suche2 { static String filename; diff --git a/src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java b/src/forgemodpackbuilder/Suche3.java similarity index 94% rename from src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java rename to src/forgemodpackbuilder/Suche3.java index 9d4df48..5e0cf01 100644 --- a/src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java +++ b/src/forgemodpackbuilder/Suche3.java @@ -11,7 +11,7 @@ package forgemodpackbuilder; */ import java.io.File; -public class VerzeichnisDurchsuchen3 { +public class Suche3 { public static void main(String[] args) { diff --git a/src/forgemodpackbuilder/UnZip.java b/src/forgemodpackbuilder/UnZip.java index 4a9a53a..ab3ac2f 100644 --- a/src/forgemodpackbuilder/UnZip.java +++ b/src/forgemodpackbuilder/UnZip.java @@ -29,6 +29,6 @@ public class UnZip { zipFile.extractAll(destination); } catch (ZipException e) { e.printStackTrace(); - } + } } } \ No newline at end of file diff --git a/src/forgemodpackbuilder/frage.java b/src/forgemodpackbuilder/frage.java index 80487f2..afdb713 100644 --- a/src/forgemodpackbuilder/frage.java +++ b/src/forgemodpackbuilder/frage.java @@ -5,6 +5,10 @@ */ package forgemodpackbuilder; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * * @author simonr @@ -80,6 +84,12 @@ public class frage extends javax.swing.JFrame { Zip a = new Zip(); a.modpack = name; a.archiveDir(null); + Modpacktxt.name = name; + try { + Modpacktxt.main(null); + } catch (IOException ex) { + Logger.getLogger(frage.class.getName()).log(Level.SEVERE, null, ex); + } this.dispose(); }//GEN-LAST:event_jButton1ActionPerformed