How to schedule a sync task in a week

Discussion in 'Plugin Development' started by william9518, Jan 4, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    I would like to schedule this task where it does a method. then a week later it does another one. This task also has to be run multiple times simutaneously. Ok so this is what it is: someone buys this thing with credits i already added. He would get it for a week. Ik how to do everything except schedule a task to run that long and to run this simutaneously as multiple peopel might use this at the same time
  2. Offline


    Store a timestamp
  3. Offline


    every hour?!
  4. Offline


    Sure, or every day. Or what ever. This is how you'd do it.
  5. Offline


    yes but the scheduletask thing is in ticks.
  6. Offline


    You don't want to use a timer for this. That's for a much shorter time period. Have some code store the current time and date to a YAML file, then check that date to the current date to see if a week has passed. You can have it run once in your onEnable, or do use a timer to check the date more often.
  7. Offline


    umm, how?
  8. Offline


    You could do something like this.

                  Calendar cal = new GregorianCalendar(TimeZone.getDefault());
            int month = cal.get(Calendar.MONTH);
            int day = cal.get(Calendar.DAY_OF_MONTH);
            if (month == 1 && day == 1) {
      "Oh look.. It's january!");
            } else if (month == 2 && day == 1)
      "Oh look.. It's febuary!");
    You could save the time in the config, and then check to see if the datas match. You can store it like
    getConfig().setString("", "month:day");
    Then when your checking, split the string by :, and use if month == string[0] && day == string[1]
Thread Status:
Not open for further replies.

Share This Page