Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.thegeekyguy101.deobf;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.zip.ZipEntry;
- import java.util.zip.ZipInputStream;
- import javax.swing.JButton;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- public class Main extends JFrame implements ActionListener {
- static String tempDir = System.getProperty("java.io.tmpdir");
- public static File Deobf = new File(tempDir + "Deobf");
- public static String Deobf2 = Deobf.toString();
- private JFrame f = new JFrame("Minecraft Mod Deobf");
- private JButton source = new JButton("Select source zip");
- private JButton Run = new JButton("Start");
- public File sourceFile;
- public Main() {
- f.setLayout(new BorderLayout());
- JPanel P = new JPanel();
- P.setLayout(new FlowLayout());
- P.add(source);
- P.add(Run);
- source.addActionListener(this);
- Run.addActionListener(this);
- f.add(P, BorderLayout.CENTER);
- f.setVisible(true);
- f.setSize(550, 200);
- }
- public static void main(String[] args) {
- new Main();
- }
- public void actionPerformed(ActionEvent e) {
- if(e.getSource()==source){
- JFileChooser chooser = new JFileChooser();
- int returnVal = chooser.showOpenDialog(null);
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- sourceFile = chooser.getSelectedFile();
- }
- }
- if(e.getSource() == Run) {
- this.preDeobf();
- this.UnZip();
- try {
- this.Deobf();
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
- }
- public void UnZip() {
- try {
- byte[] data = new byte[1000];
- int byteRead;
- BufferedOutputStream bout = null;
- ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(sourceFile)));
- ZipEntry entry;
- while ((entry = zin.getNextEntry()) != null) {
- String filename = entry.getName();
- File newfile = new File(Deobf2 + File.separator + filename);
- System.out.println("file unzip : " + newfile.getAbsoluteFile());
- new File(newfile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newfile);
- int len;
- while ((len = zin.read(data)) > 0) {
- fos.write(data, 0, len);
- }
- fos.close();
- entry = zin.getNextEntry();
- }
- zin.closeEntry();
- zin.close();
- System.out.println("Done");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void preDeobf() {
- if (Deobf.exists()) {
- Deobf.delete();
- Deobf.mkdir();
- } else if (!Deobf.exists()) {
- Deobf.mkdir();
- }
- }
- public void Deobf() throws Exception {
- try {
- Process p = Runtime.getRuntime().exec("cmd /c start fernflower.jar " + Deobf + " source");
- p.waitFor();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement