Reposition class output

This commit is contained in:
Shevchik 2013-12-14 17:52:50 +04:00
parent cc993188fe
commit 38d9aaf229
2 changed files with 9 additions and 4 deletions

View File

@ -59,7 +59,7 @@ public class Chairs extends JavaPlugin {
getHandle.setAccessible(true);
Class<?> entityarrow = getHandle.invoke(arrow).getClass();
Class<?> craftserver = getServer().getClass();
vehiclearrowclass = new GenVehicleArrowClass().genAndLoadClass(arrowclass, entityarrow, craftserver);
vehiclearrowclass = new GenVehicleArrowClass(this).genAndLoadClass(arrowclass, entityarrow, craftserver);
} catch (Exception e) {
e.printStackTrace();
log.severe("Failed to generate VehicleArrow class, exiting");

View File

@ -23,6 +23,11 @@ import org.apache.bcel.generic.Type;
public class GenVehicleArrowClass {
private File datafolder;
public GenVehicleArrowClass(Chairs plugin)
{
this.datafolder = plugin.getDataFolder();
}
public Class<?> genAndLoadClass(String arrowclass, Class<?> entityarrow, Class<?> craftserver) throws IOException, ClassNotFoundException {
ClassGen cg = new ClassGen(
@ -60,10 +65,10 @@ public class GenVehicleArrowClass {
mg.setMaxStack();
cg.addMethod(mg.getMethod());
il.dispose();
cg.getJavaClass().dump("VehicleArrow.class");
File arrowfile = new File("VehicleArrow.class");
cg.getJavaClass().dump(datafolder+File.separator+"VehicleArrow.class");
File arrowfile = new File(datafolder+File.separator+"VehicleArrow.class");
InputStream arrwoinputstrean = new FileInputStream(arrowfile);
File jarfile = new File("VehicleArrow.jar");
File jarfile = new File(datafolder+File.separator+"VehicleArrow.jar");
jarfile.delete();
final ZipOutputStream zipout = new ZipOutputStream(new FileOutputStream(jarfile));
ZipEntry entry = new ZipEntry(arrowfile.getName());