Expiry notification

Discussion in 'Spigot Plugin Development' started by thienbao860, Sep 10, 2019.

  1. Hello. Back with another help of my coding. Apparently I was doing a booster plugin but with the automatic notification whether if my boosting has expired or not. Technically my choice was having a Thread, but I'm sure this is an unsafe way. So is there another approach? Thank you!
  2. drives_a_ford

    Junior Mod

  3. That's the problem. I don't really want to execute like 50 boosting tasks at once
  4. As far as I know the scheduler is still the best solution. You could have one task running iterating trought all boosts
  5. What is the average time of these boosts? If they are less than 5 minutes I would do multiple schedulers as separate classes (not anonymous classes). If they where more then I would do 1 scheduled timer on seconds that checks all boosts like JarFiles mentions.
    • Agree Agree x 1
  6. Depends on the intensity the server can take, always best to code efficiently though.
  7. The avarage time might be at least 10mins. So you guys mean that doing this by looping all boosters in each seconds?
  8. You will have one runnable that loops every second. But that runnable will only exist if at least one booster is active. the runnable itself will check to see if there are any boosters left active and if they are not it will cancel itself. When a booster is created you will check to see if the runnable exists if it doesn't you will create it.
    • Informative Informative x 1
  9. Noted. Thank you :D
    Also, another question: Can it handle 1000 players?
    #9 thienbao860, Sep 11, 2019
    Last edited: Sep 11, 2019
  10. Depends on the specifications on the server. If it is running per player then 1000+ things going on in one plugin could lag the server depending on the memory available.