From e62de4e88348726519ff80485bfe4264484b9611 Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Mon, 17 Oct 2016 06:30:35 +0200 Subject: [PATCH] Bau dir dein Modpack --- build.xml | 73 + manifest.mf | 3 + nbproject/build-impl.xml | 1419 +++++++++++++++++ nbproject/genfiles.properties | 8 + nbproject/project.properties | 78 + nbproject/project.xml | 15 + .../AktuellesDatumJava8.java | 28 + .../DateiKopierenClass.java | 44 + .../DateiKopierenClass1.java | 45 + .../DateiKopierenClass2.java | 46 + .../FileDeleteExample.java | 27 + src/forgemodpackbuilder/GUI.form | 247 +++ src/forgemodpackbuilder/GUI.java | 413 +++++ .../OeffnenDialogClass.java | 54 + src/forgemodpackbuilder/ProcExecExamples.java | 45 + src/forgemodpackbuilder/Suche.java | 37 + src/forgemodpackbuilder/Suche1.java | 37 + src/forgemodpackbuilder/UnZip.java | 34 + .../VerzeichnisDurchsuchen2.java | 30 + .../VerzeichnisDurchsuchen3.java | 28 + src/forgemodpackbuilder/Zip.java | 50 + src/forgemodpackbuilder/downloader.java | 36 + src/forgemodpackbuilder/downloader1.java | 61 + src/forgemodpackbuilder/frage.form | 74 + src/forgemodpackbuilder/frage.java | 126 ++ 25 files changed, 3058 insertions(+) create mode 100644 build.xml create mode 100644 manifest.mf create mode 100644 nbproject/build-impl.xml create mode 100644 nbproject/genfiles.properties create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 src/forgemodpackbuilder/AktuellesDatumJava8.java create mode 100644 src/forgemodpackbuilder/DateiKopierenClass.java create mode 100644 src/forgemodpackbuilder/DateiKopierenClass1.java create mode 100644 src/forgemodpackbuilder/DateiKopierenClass2.java create mode 100644 src/forgemodpackbuilder/FileDeleteExample.java create mode 100644 src/forgemodpackbuilder/GUI.form create mode 100644 src/forgemodpackbuilder/GUI.java create mode 100644 src/forgemodpackbuilder/OeffnenDialogClass.java create mode 100644 src/forgemodpackbuilder/ProcExecExamples.java create mode 100644 src/forgemodpackbuilder/Suche.java create mode 100644 src/forgemodpackbuilder/Suche1.java create mode 100644 src/forgemodpackbuilder/UnZip.java create mode 100644 src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java create mode 100644 src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java create mode 100644 src/forgemodpackbuilder/Zip.java create mode 100644 src/forgemodpackbuilder/downloader.java create mode 100644 src/forgemodpackbuilder/downloader1.java create mode 100644 src/forgemodpackbuilder/frage.form create mode 100644 src/forgemodpackbuilder/frage.java diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..3fe5784 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ForgeModpackBuilder. + + + diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..ec99f4a --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1419 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..17c6539 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=e9df12b1 +build.xml.script.CRC32=45621513 +build.xml.stylesheet.CRC32=8064a381@1.79.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=e9df12b1 +nbproject/build-impl.xml.script.CRC32=869e51d9 +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..6b7fb8a --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,78 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=ForgeModpackBuilder +application.vendor=simonr +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ForgeModpackBuilder.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.zip4j_1.3.2.jar=/home/simonr/Downloads/zip4j_1.3.2.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.zip4j_1.3.2.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=forgemodpackbuilder.GUI +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..c218fd9 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + ForgeModpackBuilder + + + + + + + + + diff --git a/src/forgemodpackbuilder/AktuellesDatumJava8.java b/src/forgemodpackbuilder/AktuellesDatumJava8.java new file mode 100644 index 0000000..52d10ed --- /dev/null +++ b/src/forgemodpackbuilder/AktuellesDatumJava8.java @@ -0,0 +1,28 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class AktuellesDatumJava8 { + + static void formatDateTime() { + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter df; + df = DateTimeFormatter.ISO_LOCAL_DATE; // 2016-18-31 + System.out.println(now.format(df)); + Zip.datum = now.format(df); + } + + public static void main(String[] args) { + formatDateTime(); + } +} diff --git a/src/forgemodpackbuilder/DateiKopierenClass.java b/src/forgemodpackbuilder/DateiKopierenClass.java new file mode 100644 index 0000000..5336f5f --- /dev/null +++ b/src/forgemodpackbuilder/DateiKopierenClass.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; + +/** + * + * @author simonr + */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; + +public class DateiKopierenClass { + + public static void main(String[] args) throws IOException { + File inF = new File(GUI.datei); + File outF = new File("./modpack/modpack/mods/" + GUI.datei.substring( GUI.datei.lastIndexOf( "/" ) + 1 )); + copyFile(inF, outF); + } + + public static void copyFile(File in, File out) throws IOException { + FileChannel inChannel = null; + FileChannel outChannel = null; + try { + inChannel = new FileInputStream(in).getChannel(); + outChannel = new FileOutputStream(out).getChannel(); + inChannel.transferTo(0, inChannel.size(), outChannel); + } catch (IOException e) { + throw e; + } finally { + try { + if (inChannel != null) + inChannel.close(); + if (outChannel != null) + outChannel.close(); + } catch (IOException e) {} + } + } +} diff --git a/src/forgemodpackbuilder/DateiKopierenClass1.java b/src/forgemodpackbuilder/DateiKopierenClass1.java new file mode 100644 index 0000000..572300f --- /dev/null +++ b/src/forgemodpackbuilder/DateiKopierenClass1.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; + +public class DateiKopierenClass1 { + + public static void main(String[] args) throws IOException { + File inF = new File(GUI.datei); + File outF = new File("./modpack/modpack/" + GUI.datei.substring( GUI.datei.lastIndexOf( "/" ) + 1 )); + copyFile(inF, outF); + } + + public static void copyFile(File in, File out) throws IOException { + FileChannel inChannel = null; + FileChannel outChannel = null; + try { + inChannel = new FileInputStream(in).getChannel(); + outChannel = new FileOutputStream(out).getChannel(); + inChannel.transferTo(0, inChannel.size(), outChannel); + } catch (IOException e) { + throw e; + } finally { + try { + if (inChannel != null) + inChannel.close(); + if (outChannel != null) + outChannel.close(); + } catch (IOException e) {} + } + } +} + diff --git a/src/forgemodpackbuilder/DateiKopierenClass2.java b/src/forgemodpackbuilder/DateiKopierenClass2.java new file mode 100644 index 0000000..f681842 --- /dev/null +++ b/src/forgemodpackbuilder/DateiKopierenClass2.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.channels.FileChannel; + +public class DateiKopierenClass2 { + + public static void main(String[] args) throws IOException { + File inF = new File("./modpack/Minecraft.jar"); + File outF = new File("./modpack/modpack/Minecraft.jar"); + copyFile(inF, outF); + } + + public static void copyFile(File in, File out) throws IOException { + FileChannel inChannel = null; + FileChannel outChannel = null; + try { + inChannel = new FileInputStream(in).getChannel(); + outChannel = new FileOutputStream(out).getChannel(); + inChannel.transferTo(0, inChannel.size(), outChannel); + } catch (IOException e) { + throw e; + } finally { + try { + if (inChannel != null) + inChannel.close(); + if (outChannel != null) + outChannel.close(); + } catch (IOException e) {} + } + } +} + + diff --git a/src/forgemodpackbuilder/FileDeleteExample.java b/src/forgemodpackbuilder/FileDeleteExample.java new file mode 100644 index 0000000..b78771d --- /dev/null +++ b/src/forgemodpackbuilder/FileDeleteExample.java @@ -0,0 +1,27 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.File; + +public class FileDeleteExample { + + public static void main(String[] args) { + File file = new File(GUI.datei); + + //Zuvor alle mit dem File assoziierten Streams schließen... + + if(file.exists()){ + file.delete(); + } + + System.out.println("File deleted"); + } +} diff --git a/src/forgemodpackbuilder/GUI.form b/src/forgemodpackbuilder/GUI.form new file mode 100644 index 0000000..cc7b9d9 --- /dev/null +++ b/src/forgemodpackbuilder/GUI.form @@ -0,0 +1,247 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/forgemodpackbuilder/GUI.java b/src/forgemodpackbuilder/GUI.java new file mode 100644 index 0000000..122fc60 --- /dev/null +++ b/src/forgemodpackbuilder/GUI.java @@ -0,0 +1,413 @@ +/* + * 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.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; + +/** + * + * @author simonr + */ +public class GUI extends javax.swing.JFrame { + + static String datei = null; + static String[] mods1 = new String[300]; + static String[] mods2 = new String[300]; + static String version = "1.10.2"; + + /** + * Creates new form GUI + */ + public GUI() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList<>(); + jLabel2 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jScrollPane3 = new javax.swing.JScrollPane(); + jList2 = new javax.swing.JList<>(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jButton4 = new javax.swing.JButton(); + jButton5 = new javax.swing.JButton(); + jComboBox1 = new javax.swing.JComboBox<>(); + jButton6 = new javax.swing.JButton(); + jButton8 = new javax.swing.JButton(); + jTextField1 = new javax.swing.JTextField(); + jButton7 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("ForgeModpackBuilder"); + + jLabel1.setText("Version"); + + jScrollPane1.setViewportView(jList1); + jList1.getAccessibleContext().setAccessibleDescription(""); + + jLabel2.setText("Mods:"); + + jButton1.setText("Hinzufügen"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jScrollPane3.setViewportView(jList2); + + jButton2.setText("Laden"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText("Minecraft starten"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jButton4.setText("Forge installieren"); + jButton4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton4ActionPerformed(evt); + } + }); + + jButton5.setText("Modpack erstellen"); + jButton5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton5ActionPerformed(evt); + } + }); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "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); + } + }); + + jButton6.setText("Modpack Laden und Installieren"); + jButton6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton6ActionPerformed(evt); + } + }); + + jButton8.setText("Entfernen"); + jButton8.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton8ActionPerformed(evt); + } + }); + + jTextField1.setToolTipText(""); + jTextField1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField1ActionPerformed(evt); + } + }); + + jButton7.setText("Bibliotheken download"); + jButton7.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton7ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(4, 4, 4) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(58, 58, 58) + .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(18, 18, 18) + .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE) + .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() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton8) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 537, javax.swing.GroupLayout.PREFERRED_SIZE)) + .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) + .addGroup(layout.createSequentialGroup() + .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jButton3) + .addComponent(jButton4) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton6)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2) + .addComponent(jButton5) + .addComponent(jButton8) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton7))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .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)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + System.out.println("Ausgewählt = " + jList1.getSelectedValue()); + datei = jList1.getSelectedValue(); + try { + DateiKopierenClass.main(null); + } catch (IOException ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } + jButton2ActionPerformed(evt); + + }//GEN-LAST:event_jButton1ActionPerformed + + 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; + } + 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 + // TODO add your handling code here: + ProcExecExamples.funktion = 1; + try { + ProcExecExamples.main(null); + } catch (Exception ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton3ActionPerformed + + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed + // TODO add your handling code here: + ProcExecExamples.funktion = 2; + try { + ProcExecExamples.main(null); + } catch (Exception ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton4ActionPerformed + + private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed + try { + downloader.main(null); + downloader1.main(null); + // TODO add your handling code here: + VerzeichnisDurchsuchen3.main(null); + DateiKopierenClass1.main(null); + DateiKopierenClass2.main(null); + String file = "./modpack/modpack/" + GUI.datei.substring(GUI.datei.lastIndexOf("/") + 1); + new File(file).renameTo(new File("./modpack/modpack/forge.jar")); + frage.main(null); + } catch (IOException ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } catch (Throwable ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton5ActionPerformed + + 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 + + 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; + UnZip.main(); + jButton4ActionPerformed(evt); + } catch (java.lang.NullPointerException ex) { + System.out.println("Keine Eingabe"); + } + //jButton3ActionPerformed(evt); + }//GEN-LAST:event_jButton6ActionPerformed + + private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed + // TODO add your handling code here: + System.out.println(jList2.getSelectedValue()); + datei = jList2.getSelectedValue(); + try { + FileDeleteExample.main(null); + } catch (java.lang.NullPointerException ex) { + System.out.println("Datei nicht Vorhanden!!!"); + } + jButton2ActionPerformed(evt); + + }//GEN-LAST:event_jButton8ActionPerformed + + private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed + // TODO add your handling code here: + Suche.name = jTextField1.getText(); + System.out.println(Suche1.name); + Suche.main(null); + jButton2ActionPerformed(evt); + + }//GEN-LAST:event_jTextField1ActionPerformed + + private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed + try { + // TODO add your handling code here: + downloader.main(null); + downloader1.main(null); + VerzeichnisDurchsuchen3.main(null); + DateiKopierenClass1.main(null); + DateiKopierenClass2.main(null); + String file = "./modpack/modpack/" + GUI.datei.substring(GUI.datei.lastIndexOf("/") + 1); + new File(file).renameTo(new File("./modpack/modpack/forge.jar")); + } catch (Throwable ex) { + Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_jButton7ActionPerformed + + DefaultListModel dim2 = new DefaultListModel(); + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(GUI.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(GUI.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(GUI.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(GUI.class + .getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(() -> { + new GUI().setVisible(true); + File dir = new File("./modpack"); + dir.mkdir(); + System.out.println(System.getProperty("user.home")); + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JButton jButton4; + private javax.swing.JButton jButton5; + private javax.swing.JButton jButton6; + private javax.swing.JButton jButton7; + private javax.swing.JButton jButton8; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JList jList1; + private javax.swing.JList jList2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/forgemodpackbuilder/OeffnenDialogClass.java b/src/forgemodpackbuilder/OeffnenDialogClass.java new file mode 100644 index 0000000..e361262 --- /dev/null +++ b/src/forgemodpackbuilder/OeffnenDialogClass.java @@ -0,0 +1,54 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; + +import javax.swing.JFileChooser; + +public class OeffnenDialogClass { + + public static void main(String[] args) { + OeffnenDialogClass odc = new OeffnenDialogClass(); + odc.oeffnen(); + } + + private void oeffnen() { + final JFileChooser chooser = new JFileChooser("Verzeichnis wählen"); + chooser.setDialogType(JFileChooser.OPEN_DIALOG); + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + final File file = new File("/home"); + + chooser.setCurrentDirectory(file); + + chooser.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + if (e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY) + || e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { + final File f = (File) e.getNewValue(); + } + } + }); + + chooser.setVisible(true); + final int result = chooser.showOpenDialog(null); + + if (result == JFileChooser.APPROVE_OPTION) { + File inputVerzFile = chooser.getSelectedFile(); + String inputVerzStr = inputVerzFile.getPath(); + GUI.datei = inputVerzStr; + System.out.println(inputVerzStr); + } + System.out.println("Abbruch"); + chooser.setVisible(false); + } +} diff --git a/src/forgemodpackbuilder/ProcExecExamples.java b/src/forgemodpackbuilder/ProcExecExamples.java new file mode 100644 index 0000000..df93a5d --- /dev/null +++ b/src/forgemodpackbuilder/ProcExecExamples.java @@ -0,0 +1,45 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.*; + +public class ProcExecExamples { + + public static int funktion = 1; + + public static void main(String[] args) throws Exception { + + if (isWindowsSystem()) { + System.out.println("Windows"); + Runtime.getRuntime().exec("cmd /c help"); + } + if (isLinuxSystem()) { + System.out.println("Linux"); + if (funktion == 1) { + Runtime.getRuntime().exec("java -jar " + System.getProperty("user.home") + "/.minecraft/Minecraft.jar"); + } + if (funktion == 2) { + Runtime.getRuntime().exec("java -jar " + System.getProperty("user.home") + "/.minecraft/forge.jar"); + } + + } + } + + static boolean isWindowsSystem() { + String osName = System.getProperty("os.name").toLowerCase(); + return osName.indexOf("windows") >= 0; + } + + static boolean isLinuxSystem() { + String osName = System.getProperty("os.name").toLowerCase(); + return osName.indexOf("linux") >= 0; + } +} diff --git a/src/forgemodpackbuilder/Suche.java b/src/forgemodpackbuilder/Suche.java new file mode 100644 index 0000000..4e00fe4 --- /dev/null +++ b/src/forgemodpackbuilder/Suche.java @@ -0,0 +1,37 @@ +/* + * 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.File; + +/** + * + * @author simonr + */ +public class Suche { + + static String name = ""; + + public static void main(String[] args) { + + String pathToScan = "./modpack/" + GUI.version + "/mods"; + String fileThatYouWantToFilter; + File folderToScan = new File(pathToScan); // import -> import java.io.File; + File[] listOfFiles = folderToScan.listFiles(); + int i = 0; + for (File listOfFile : listOfFiles) { + if (listOfFile.isFile()) { + fileThatYouWantToFilter = listOfFile.getName(); + if (fileThatYouWantToFilter.startsWith(name) + && fileThatYouWantToFilter.endsWith(".jar")) { + System.out.println("found" + " " + fileThatYouWantToFilter); + GUI.mods1[i] = "./modpack/" + GUI.version + "/mods/" + fileThatYouWantToFilter; + i++; + } + } + } + } +} diff --git a/src/forgemodpackbuilder/Suche1.java b/src/forgemodpackbuilder/Suche1.java new file mode 100644 index 0000000..df7aea5 --- /dev/null +++ b/src/forgemodpackbuilder/Suche1.java @@ -0,0 +1,37 @@ +/* + * 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.File; + +/** + * + * @author simonr + */ +public class Suche1 { + + static String name = ""; + + public static void main(String[] args) { + + String pathToScan = "./modpack/modpack/mods"; + String fileThatYouWantToFilter; + File folderToScan = new File(pathToScan); // import -> import java.io.File; + File[] listOfFiles = folderToScan.listFiles(); + int i = 0; + for (File listOfFile : listOfFiles) { + if (listOfFile.isFile()) { + fileThatYouWantToFilter = listOfFile.getName(); + if (fileThatYouWantToFilter.startsWith(name) + && fileThatYouWantToFilter.endsWith(".jar")) { + System.out.println("found" + " " + fileThatYouWantToFilter); + GUI.mods2[i] = "./modpack/modpack/mods/" + fileThatYouWantToFilter; + i++; + } + } + } + } +} diff --git a/src/forgemodpackbuilder/UnZip.java b/src/forgemodpackbuilder/UnZip.java new file mode 100644 index 0000000..97858de --- /dev/null +++ b/src/forgemodpackbuilder/UnZip.java @@ -0,0 +1,34 @@ +/* + * 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 net.lingala.zip4j.core.ZipFile; +import net.lingala.zip4j.exception.ZipException; + +/** + * + * @author simonr + */ + +public class UnZip { + static String modpack = ""; + static String modpack1 = ""; + public static void main() { + String source = modpack; + String destination = System.getProperty("user.home") + "/.minecraft"; + String password = "mypassword"; + + try { + ZipFile zipFile = new ZipFile(source); + if (zipFile.isEncrypted()) { + zipFile.setPassword(password); + } + zipFile.extractAll(destination); + } catch (ZipException e) { + e.printStackTrace(); + } +} +} \ No newline at end of file diff --git a/src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java b/src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java new file mode 100644 index 0000000..6682daf --- /dev/null +++ b/src/forgemodpackbuilder/VerzeichnisDurchsuchen2.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.File; + +public class VerzeichnisDurchsuchen2 { + + static String filename; + + public static void main(String[] args) { + + File f = new File("./modpack/modpack"); + File[] fileArray = f.listFiles(); + + if (fileArray != null) { // Erforderliche Berechtigungen etc. sind vorhanden + for (int i = 0; i < fileArray.length; i++) { + System.out.println(fileArray[i]); + filename = fileArray[i].toString(); + } + } + } +} diff --git a/src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java b/src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java new file mode 100644 index 0000000..9d4df48 --- /dev/null +++ b/src/forgemodpackbuilder/VerzeichnisDurchsuchen3.java @@ -0,0 +1,28 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import java.io.File; + +public class VerzeichnisDurchsuchen3 { + + public static void main(String[] args) { + + File f = new File("./modpack/" + GUI.version); + File[] fileArray = f.listFiles(); + + if (fileArray != null) { // Erforderliche Berechtigungen etc. sind vorhanden + for (int i = 0; i < 1; i++) { + System.out.println(fileArray[0]); + GUI.datei = fileArray[0].toString(); + } + } + } +} diff --git a/src/forgemodpackbuilder/Zip.java b/src/forgemodpackbuilder/Zip.java new file mode 100644 index 0000000..90415d4 --- /dev/null +++ b/src/forgemodpackbuilder/Zip.java @@ -0,0 +1,50 @@ +/* + * 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; + +/** + * + * @author simonr + */ +import net.lingala.zip4j.core.*; +import net.lingala.zip4j.model.*; +import net.lingala.zip4j.util.*; + +public class Zip { + + String modpack = ""; + static String datum = ""; + + void archiveDir(String path) { + try { + + // Initiate ZipFile object with the path/name of the zip file. + ZipFile zipFile = new ZipFile(modpack + "-" + datum + ".zip"); + + // Folder to add + String folderToAdd = "./modpack/modpack/"; + + // Initiate Zip Parameters which define various properties such + // as compression method, etc. + ZipParameters parameters = new ZipParameters(); + + // set compression method to store compression + parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); + + // Set the compression level + parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); + + // Set the root folder + parameters.setIncludeRootFolder(false); + + // Add folder to the zip file + zipFile.addFolder(folderToAdd, parameters); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/forgemodpackbuilder/downloader.java b/src/forgemodpackbuilder/downloader.java new file mode 100644 index 0000000..30cc2ff --- /dev/null +++ b/src/forgemodpackbuilder/downloader.java @@ -0,0 +1,36 @@ +/* + * 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.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; +/** + * + * @author simonr + */ +public class downloader { + public static void main(String[] args) throws Throwable { + final URL url = new URL("http://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar"); + final URLConnection conn = url.openConnection(); + try (InputStream is = new BufferedInputStream(conn.getInputStream())) { + final OutputStream os; + os = new BufferedOutputStream(new FileOutputStream("./modpack/Minecraft.jar")); + 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/downloader1.java b/src/forgemodpackbuilder/downloader1.java new file mode 100644 index 0000000..fc61f0f --- /dev/null +++ b/src/forgemodpackbuilder/downloader1.java @@ -0,0 +1,61 @@ +/* + * 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.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; + +/** + * + * @author simonr + */ + + +public class downloader1 { + + public static void main(String[] args) throws Throwable { + + String forge10 = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.10.2-12.18.2.2107/forge-1.10.2-12.18.2.2107-installer.jar"; + String forge9 = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.9.4-12.17.0.2051/forge-1.9.4-12.17.0.2051-installer.jar"; + String forge8 = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.8.9-11.15.1.1902-1.8.9/forge-1.8.9-11.15.1.1902-1.8.9-installer.jar"; + String forge7 = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar"; + + String total = ""; + + if (GUI.version.equals("1.10.2")) { + total = forge10; + } + if (GUI.version.equals("1.9.4")) { + total = forge9; + } + if (GUI.version.equals("1.8.9")) { + total = forge8; + } + if (GUI.version.equals("1.7.10")) { + total = forge7; + } + + final URL url = new URL(total); + final URLConnection conn = url.openConnection(); + try (InputStream is = new BufferedInputStream(conn.getInputStream())) { + final OutputStream os; + os = new BufferedOutputStream(new FileOutputStream("./modpack/" + GUI.version + "/" + total.substring(total.lastIndexOf("/") + 1))); + 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/frage.form b/src/forgemodpackbuilder/frage.form new file mode 100644 index 0000000..1119655 --- /dev/null +++ b/src/forgemodpackbuilder/frage.form @@ -0,0 +1,74 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/forgemodpackbuilder/frage.java b/src/forgemodpackbuilder/frage.java new file mode 100644 index 0000000..80487f2 --- /dev/null +++ b/src/forgemodpackbuilder/frage.java @@ -0,0 +1,126 @@ +/* + * 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; + +/** + * + * @author simonr + */ +public class frage extends javax.swing.JFrame { + + /** + * Creates new form frage + */ + public frage() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("Noto Sans", 0, 18)); // NOI18N + jLabel1.setText("Wie soll ihr Modpack heißen!"); + + jButton1.setText("OK"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) + .addComponent(jTextField1) + .addGroup(layout.createSequentialGroup() + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + String name = jTextField1.getText(); + System.out.println(name); + AktuellesDatumJava8.main(null); + Zip a = new Zip(); + a.modpack = name; + a.archiveDir(null); + this.dispose(); + }//GEN-LAST:event_jButton1ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(frage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(frage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(frage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(frage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new frage().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables +}