Jump to content

Trying to use multiple classes


Recommended Posts

Posted

Hi.

Trying to split up my script into multiple classes but getting null pointer error when trying to access methods from a different class like in this example:

public class Main extends Script {
    Test test = new Test();

    @Override
    public void onStart() throws InterruptedException {
        test.exchangeContext(getBot());
    }

    @Override
    public int onLoop() throws InterruptedException {
        test.testLog();
        return 256;
    }

    @Override
    public void onExit() throws InterruptedException {}
}

 

public class Test extends MethodProvider {

    TestTwo testTwo = new TestTwo();

    public void testLog() {
        testTwo.logFromTestTwo();
    }

}

 

public class TestTwo extends MethodProvider {

    public void logFromTestTwo() {
        log("Test Two");
    }

}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...