Advertisement
Guest User

Untitled

a guest
Jan 8th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. package me.thegeekyguy101.deobf;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.FlowLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.io.BufferedInputStream;
  8. import java.io.BufferedOutputStream;
  9. import java.io.File;
  10. import java.io.FileInputStream;
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.util.zip.ZipEntry;
  14. import java.util.zip.ZipInputStream;
  15.  
  16. import javax.swing.JButton;
  17. import javax.swing.JFileChooser;
  18. import javax.swing.JFrame;
  19. import javax.swing.JPanel;
  20.  
  21. public class Main extends JFrame implements ActionListener {
  22.  
  23. static String tempDir = System.getProperty("java.io.tmpdir");
  24. public static File Deobf = new File(tempDir + "Deobf");
  25. public static String Deobf2 = Deobf.toString();
  26.  
  27. private JFrame f = new JFrame("Minecraft Mod Deobf");
  28.  
  29. private JButton source = new JButton("Select source zip");
  30. private JButton Run = new JButton("Start");
  31.  
  32. public File sourceFile;
  33.  
  34. public Main() {
  35. f.setLayout(new BorderLayout());
  36.  
  37. JPanel P = new JPanel();
  38. P.setLayout(new FlowLayout());
  39. P.add(source);
  40. P.add(Run);
  41. source.addActionListener(this);
  42. Run.addActionListener(this);
  43.  
  44. f.add(P, BorderLayout.CENTER);
  45.  
  46. f.setVisible(true);
  47. f.setSize(550, 200);
  48. }
  49.  
  50. public static void main(String[] args) {
  51. new Main();
  52. }
  53.  
  54. public void actionPerformed(ActionEvent e) {
  55. if(e.getSource()==source){
  56. JFileChooser chooser = new JFileChooser();
  57. int returnVal = chooser.showOpenDialog(null);
  58. if(returnVal == JFileChooser.APPROVE_OPTION) {
  59. sourceFile = chooser.getSelectedFile();
  60. }
  61. }
  62. if(e.getSource() == Run) {
  63. this.preDeobf();
  64. this.UnZip();
  65. try {
  66. this.Deobf();
  67. } catch (Exception e1) {
  68. // TODO Auto-generated catch block
  69. e1.printStackTrace();
  70. }
  71. }
  72. }
  73.  
  74. public void UnZip() {
  75. try {
  76. byte[] data = new byte[1000];
  77. int byteRead;
  78.  
  79. BufferedOutputStream bout = null;
  80. ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(sourceFile)));
  81. ZipEntry entry;
  82. while ((entry = zin.getNextEntry()) != null) {
  83. String filename = entry.getName();
  84. File newfile = new File(Deobf2 + File.separator + filename);
  85.  
  86. System.out.println("file unzip : " + newfile.getAbsoluteFile());
  87.  
  88. new File(newfile.getParent()).mkdirs();
  89.  
  90. FileOutputStream fos = new FileOutputStream(newfile);
  91.  
  92. int len;
  93. while ((len = zin.read(data)) > 0) {
  94. fos.write(data, 0, len);
  95. }
  96.  
  97. fos.close();
  98. entry = zin.getNextEntry();
  99. }
  100. zin.closeEntry();
  101. zin.close();
  102.  
  103. System.out.println("Done");
  104. } catch (Exception e) {
  105. e.printStackTrace();
  106. }
  107. }
  108.  
  109. public void preDeobf() {
  110. if (Deobf.exists()) {
  111. Deobf.delete();
  112. Deobf.mkdir();
  113. } else if (!Deobf.exists()) {
  114. Deobf.mkdir();
  115. }
  116. }
  117.  
  118. public void Deobf() throws Exception {
  119. try {
  120. Process p = Runtime.getRuntime().exec("cmd /c start fernflower.jar " + Deobf + " source");
  121. p.waitFor();
  122. } catch (Exception e) {
  123. e.printStackTrace();
  124. }
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement