Puedo hacer esto de alguna manera...?¿
He creado la clase:
Código:
package agePrueba;
public class extenItem extends eu.irreality.age.Item {
public extenItem () {
super ();
}
public String miItem () {
return this.getBestReferenceName(true);
}
}
Pero luego al llamarla desde AGE:
Código:
bsh.TargetError found at intro routine
**********BeanShell Runtime Error Report**********
*Error: java.lang.Error: Unresolved compilation problems:
eu cannot be resolved to a type
The method getBestReferenceName(boolean) is undefined for the type extenItem
*Location: inline evaluation of: ``/* * * Redefinimos ciertos mensajes por defecto. * */ String getMessage ( St . . . ''
*Line: 133
*Offending text: new agePruebas .extenItem ( )
*Message: Sourced file: inline evaluation of: ``intro( arg0, arg1);'' : Object constructor
*Script stack trace:
Called from method: intro : at Line: 1 : in file: inline evaluation of: ``intro( arg0, arg1);'' : intro ( arg0 , arg1 )
*Exception was generated in native code. Stack trace follows: java.lang.Error: Unresolved compilation problems:
eu cannot be resolved to a type
The method getBestReferenceName(boolean) is undefined for the type extenItem
at agePruebas.extenItem.<init>(extenItem.java:3)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at bsh.Reflect.constructObject(Unknown Source)
.....
No reconoce el tipo " eu.irreality.age.Item ". Intenté compilar con eclipse desde el propio proyecto de AGE que me descargué de git, pero da errores (no sé como hacerlo ), así que lo compilé desde un proyecto nuevo e independiente.
También supongo que debo usar otro constructor para el Item, he visto que existen:
Código:
public Item ( World mundo , String itemfile ) throws IOException , FileNotFoundException
public Item ( World mundo , org.w3c.dom.Node n ) throws XMLtoWorldException
Pero no sé lo que es "org.w3c.dom.Node n", ni "String itemfile".
EDITO:
Para ver si tenía el enlace con la clase compilada hice otra clase en el mismo proyecto:
Código:
package agePrueba;
public class Imprimir {
public Imprimir() {
// TODO Auto-generated constructor stub
}
public String comunicacion () {
return "Comunicación ok";
}
}
Y usando :
Código:
URL clases = world.getResource("myItem.jar");
addClassPath( clases );
aux = new agePrueba.Imprimir();
//oneItem = new agePrueba.extenItem (); -> en cuanto quito el comentario de esta línea todo casca.
mobile("jugador").write ( aux.comunicacion () );
E imprime correctamente el mensaje "Comunicación ok"