Jump to content

Conditional sleep error


bigd123

Recommended Posts

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 :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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