1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fukkitrage;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipInputStream;

/**
 *
 * @author Taylor
 */
public class FukkitRage {
public static final String PREFIX = "#FukkitRage :: ";
public static final String SCAN_FOR_FILES_IN = "C:\\Users\\Taylor\\Dropbox\\Rhodesia\\Projects\\MINECRAFT PLUGINS\\FukkitRage\\plugins";
public static final String FIND [] = {"org.bukkit.craftbukkit"};
public static final String REPLACE [] = {"org.bukkit.craftbukkit.v1_4_6"};
public static FileFilter JARSONLY = new FileFilter() {@Override	public boolean accept(File f) {	return (f.getName().endsWith(".jar"));}	};
	public static void main(String[] args) {
		System.out.println(PREFIX+"starting...");
		File dir = new File(SCAN_FOR_FILES_IN);
		File[] plugins = dir.listFiles(JARSONLY);
		if (plugins.length<=0){
			System.out.println("no files in plugin directory. Aborting mission.");
		}else{
			for (int i = 0; i < plugins.length;i++){
				try {
					System.out.println("=====================================");
					System.out.println(PREFIX+"loading "+ plugins[i].getName());
					JarFile plugin = new JarFile(plugins[i]);
					for (Enumeration<JarEntry> e = plugin.entries(); e.hasMoreElements();){
						JarEntry je = e.nextElement();
						//for seeing which file is currently being edited.
						System.out.print(je.getName()+"   ");
						//is it a directory?
						System.out.println(je.isDirectory());
						
						//check if it is a class file or not.
						if (!je.isDirectory() && je.getName().endsWith(".class")){
							InputStream is = plugin.getInputStream(je);
							byte [] oByte = new byte[is.available()];
							byte [] nByte;
							is.read(oByte, 0, is.available());
							String content = new String(oByte);
							//attempt to print out the contents to file.
							System.out.println(content);
						}
					}
				} catch (IOException ex) {
					System.err.println(ex);
				}
					System.out.println("=====================================");
			}
		}
	}
}