Notorious 342 Share Posted March 16, 2015 The NPEs occured in a subclass of my main class which extends AbstractScript. You should only have one class extends from AbstractScript, and that class must also have a ScriptManifest. If you want to have access to the methods available inside of the AbstractScript class outside of the class itself, then you can always pass a reference of the script as a argument to other class and/or method. For example: //The example class you need the AbstractScript methods. public class ExampleClass { private AbstractScript script; public ExampleClass (AbstractScript script) { this.script = script; } public int getHealth () { return script.getLocalPlayer().getHealth(); //We access the methods through the script variable } } Now if we need to initiate the class from inside our AbstractScript class we would do: ExampleClass example; //DO NOT INITIATE VARIABLE HERE!!! DO IT IN THE ONSTART() @Override public void onStart () { example = new ExampleClass(this); //Since we're inside of AbstractScript, we can pass the reference using the keyword "this" example.getHealth(); //Can use this method now } I hope this helps to clarify some things. Link to comment Share on other sites More sharing options...
Kristoffer 24 Author Share Posted March 16, 2015 Yeah, I knew that. I just thought extending AbstractScript in a class and then extending that class to use the methods would also work. But as you described above is how I did it/have done it before. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.