Jump to content

help on java.util.timer


markdmp

Recommended Posts

I cannot seem to get past this error

first get Error:(38, 5) java: cannot find symbol
  symbol:   class Timer
  location: class Main.GEMaster

 

public class GEMaster extends Script {

    long Timer;
    Area shopArea = new Area(2953, 3205, 2960, 3202);
    Area grandexchangeArea = GRAND_EXCHANGE;
    Area tradingArea = VARROCK_WEST;
    static String Status = "Normal";
    boolean GotTradeOffer;
    Timer logTimer;
    Timer updateTimer;
    int numberofWSB;
    int numberofWLB;
    int numberofMSB;
    int numberofMLB;
    int numberofSA;
    int coinsinbank;

if i use import java.util.Timer;  i get Error:(51, 20) java: no suitable constructor found for Timer(int) 
    constructor java.util.Timer.Timer(boolean) is not applicable
      (argument mismatch; int cannot be converted to boolean)
    constructor java.util.Timer.Timer(java.lang.String) is not applicable
      (argument mismatch; int cannot be converted to java.lang.String)

 

 

so I add 

import java.util.Timer start;

I end up getting  Error:(21, 23) java: ';' expected noob coder buy the way just need a point in the way


 

 

Link to comment
Share on other sites

Yes you need:

import java.util.Timer;

Wherever you are instantiating the Timer, you're doing it wrong.

Check the Java docs for the Timer class.

And follow some basic Java tutorials.

Also use a proper Java IDE, it will highlight where and what your errors are in your code.

Edited by Explv
Link to comment
Share on other sites

7 minutes ago, Explv said:

Yes you need:

import java.util.Timer;

Wherever you are instantiating the Timer, you're doing it wrong.

Check the Java docs for the Timer class.

And follow some basic Java tutorials.

Also use a proper Java IDE, it will highlight where and what your errors are in your code.

thank you and all the error is in this part

 

@Override

public void onStart() throws InterruptedException {

    logTimer = new Timer(0);
    updateTimer = new Timer(0);

    Timer = System.currentTimeMillis();

    try {
        File file = new File(getDirectoryData()+"info.txt");

        if(!file.exists()) {
            file.createNewFile();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}


@Override

public int onLoop() throws InterruptedException {

    if(logTimer.Passed(1)){
        log("Current money stock " + (int) inventory.getAmount("Coins"));
        log("Current money stock in bank " + coinsinbank);
        logTimer.reset();
    }
    if(updateTimer.Passed(30)){
        Update();
        updateTimer.reset();
        sleep(random(2000,3000));
    }

    if(Status == "Normal") {
        if (!GotTradeOffer) {
            if (tabs.open(Tab.INVENTORY) && !trade.isFirstInterfaceOpen()) {
                if (inventory.contains("Willow longbow") && inventory.contains("Willow shortbow") && inventory.contains("Maple shortbow") && inventory.contains("Maple longbow")) {
                    GoToShop();
                }
                if (!inventory.contains("Willow longbow") || !inventory.contains("Willow shortbow") || !inventory.contains("Maple shortbow") || !inventory.contains("Maple longbow")) {
                    GoToGe();
                }
            }
        } else if (GotTradeOffer) {
            Trade();
        }
    }else if (Status == "Muling"){
        WalktoTrade();
    }

    return 100;
}

 

 

Link to comment
Share on other sites

1 minute ago, markdmp said:

thank you and all the error is in this part

 


@Override

public void onStart() throws InterruptedException {

    logTimer = new Timer(0);
    updateTimer = new Timer(0);

    Timer = System.currentTimeMillis();

    try {
        File file = new File(getDirectoryData()+"info.txt");

        if(!file.exists()) {
            file.createNewFile();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}


@Override

public int onLoop() throws InterruptedException {

    if(logTimer.Passed(1)){
        log("Current money stock " + (int) inventory.getAmount("Coins"));
        log("Current money stock in bank " + coinsinbank);
        logTimer.reset();
    }
    if(updateTimer.Passed(30)){
        Update();
        updateTimer.reset();
        sleep(random(2000,3000));
    }

    if(Status == "Normal") {
        if (!GotTradeOffer) {
            if (tabs.open(Tab.INVENTORY) && !trade.isFirstInterfaceOpen()) {
                if (inventory.contains("Willow longbow") && inventory.contains("Willow shortbow") && inventory.contains("Maple shortbow") && inventory.contains("Maple longbow")) {
                    GoToShop();
                }
                if (!inventory.contains("Willow longbow") || !inventory.contains("Willow shortbow") || !inventory.contains("Maple shortbow") || !inventory.contains("Maple longbow")) {
                    GoToGe();
                }
            }
        } else if (GotTradeOffer) {
            Trade();
        }
    }else if (Status == "Muling"){
        WalktoTrade();
    }

    return 100;
}

 

 

 

Ok well apparently I *still* have to do this for you...

If you look at the docs for Timer:

https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html

You will see there is no constructor that takes a number as the parameter.

There is an empty constructor though.

So just change new Timer(0) to new Timer()

..............

  • Like 1
Link to comment
Share on other sites

33 minutes ago, Explv said:

 

Ok well apparently I *still* have to do this for you...

If you look at the docs for Timer:

https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html

You will see there is no constructor that takes a number as the parameter.

There is an empty constructor though.

So just change new Timer(0) to new Timer()

..............

thank you

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