First commit

This commit is contained in:
Clisprail
2013-04-03 20:21:15 +02:00
commit c230a353b1
44 changed files with 2104 additions and 0 deletions
@@ -0,0 +1,22 @@
package org.parabot.environment.servers;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* A server manifest
* @author Clisprail
*
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ServerManifest {
String author();
String name();
double version();
Type type();
}
@@ -0,0 +1,53 @@
package org.parabot.environment.servers;
import java.applet.Applet;
import java.applet.AppletStub;
import java.net.URL;
import javax.swing.JMenuBar;
import org.parabot.core.Context;
/**
* Provides a server to the bot
*
* @author Clisprail
*
*/
public abstract class ServerProvider {
public Context context = new Context(this);
/**
* Hooks to parse
* @return URL to hooks file
*/
public URL getHooks() {
return null;
}
/**
* Jar to parse
* @return URL to client jar
*/
public abstract String getJar();
public abstract Applet fetchApplet();
public String getAccessorsPackage() {
return null;
}
/**
* Add custom items to the bot menu bar
* @param menu bar to add items on
*/
public void addMenuItems(JMenuBar bar) {
}
public AppletStub getStub() {
return null;
}
public void parseJar() {
context.getClassPath().addJar(getJar());
}
}
@@ -0,0 +1,14 @@
package org.parabot.environment.servers;
/**
*
* Bot type
*
* @author Clisprail
*
*/
public enum Type {
INJECTION, REFLECTION, COLOR, OTHER
}
@@ -0,0 +1,40 @@
package org.parabot.environment.servers.loader;
import java.util.ArrayList;
import java.util.List;
import org.objectweb.asm.tree.ClassNode;
import org.parabot.core.asm.ASMClassLoader;
import org.parabot.core.classpath.ClassPath;
import org.parabot.environment.servers.ServerProvider;
/**
*
* @author Clisprail
*
*
*/
public class ServerLoader extends ASMClassLoader {
private ClassPath classPath = null;
public ServerLoader(ClassPath classPath) {
super(classPath);
this.classPath = classPath;
}
/**
* Gets all classes that extends ServerProvider
* @return string array of class names that extends ServerProvider
*/
public final String[] getServerClassNames() {
final List<String> classNames = new ArrayList<String>();
for (ClassNode c : classPath.classes.values())
if (c.superName.replace('/', '.').equals(
ServerProvider.class.getName())) {
classNames.add(c.name.replace('/', '.'));
}
return classNames.toArray(new String[classNames.size()]);
}
}