Jump to content

Conditional sleep error


Recommended Posts

Posted

I'm copy and pasting the conditional sleep all the times I need it, but it's giving me the error "The method condition() of type Enchanter must override or implement a supertype method." I've commented where the errors are. Code:

    private void withdrawAmulets() {
        ctx.log("Withdrawing Topaz amulets");

        if (!ctx.getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of fire")) {
    		if(ctx.getBank().withdraw("Topaz amulet", 26)){
    	        new ConditionalSleep(1000,1250) {
    	        @Override
    	          public boolean condition() {
    	              return !needAmulets();
    	          }
    	      }.sleep();
    	    }
        } else {
    		if(ctx.getBank().withdraw("Topaz amulet", 26)){
    	        new ConditionalSleep(1000,1250) { //Syntax error, insert "}" to complete MethodBody
    	        @Override
    	          public boolean condition() { //The method condition() of type Enchanter must override or implement a supertype method
    	              return !needAmulets();
    	          }
    	      }.sleep(); // Syntax error on token "}", delete this token
    	    }
        } // Syntax error on token "}", { expected
    }

Help appreciated :)

Posted (edited)

I don't want to get too into detail with the problem you're having because there seem to be more than just the override error. But with a quick glance here's what I can tell:

// Syntax error on token "}", { expected

Your script has 10 opening and 12 closing braces which is causing this error, make sure you're closing all your braces properly.

 

//The method condition() of type Enchanter must override or implement a supertype method

If i recall correctly this means that your parameters don't match up with the class you're trying to override:

//the super class/method being overrun
class foo (int x, String s) {
	...
}

//the class/method you're wanting to override with
class foo (int y, int x) {
	...
}

Notice how the parameters are out of order and/or don't match up, since the signatures aren't a match there's *nothing* to be overrun. My best guess as to what's causing it is the time parameters in your conditional sleep declaration. AFAIK conditional sleep only takes one parameter for time instead of a range. You could try using random() to generate a number in that range and use that instead.

Edited by luciuspragg
  • Like 1

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...