Solved Daily reward or any time specified

Discussion in 'Spigot Plugin Development' started by shoker137, Jul 4, 2018.

  1. How can I compare 2 dates with time?
    So I know how to get current time and date but how can I compare it to date that is saved in the config?
    And what format do I need to use to save date with time?
  2. Well. That's a bigger question that you realize. You're going to need to provide some specifics in order to get a proper answer.

    Most important specific is what type of "date" are we dealing with here? Epoch timestamp? a Date? a Calendar? something custom?
  3. I know only about Date. You can tell me if something else is simpler to use.
  4. It really depends on what you're doing. Each one has pros and cons, and you'll want to use the one that has the pros align with your use-case, not against you.
  5. I just want to compare day, month and hours with seconds. All this can provide Date. And as the name of this question is, I want to make rewards for every X time.
  6. If you want every X amount of time just use Epoch timestamps and BukkitRunnables. Comparing them is as simple as checking if one is greater than the other.
  7. I'll try it. Thank you!
  8. What I do for my plugin, Daily Rewards, is save data to a person when they run a command; that data is the current millis time + the cooldown you want to add. After that, I check if the new current millis time is equal to or greater than the data that was saved, if it is, then the cooldown is expired.
    • Agree Agree x 1
  9. Thank you!
  10. No problem :) Hopefully, that works for you.