Hi everybody, I'm thinking of making a countdown with a double, to get the decimals in the scoreboard, but i can't think in a way to do it. I thought reducing the period of the schedule, but i don't really think that would work, any ideas? thanks in advance.
What do mean by „countdown with a double“? In Spigot, there is only one way to realize a countdown; and that is using the scheduler. The minimal period is one tick. One tick is 1/20th of a second, or 0.05 seconds. Here‘s your double . But again, what exactly are you looking for? A better resolution than the 5 ms?
You can also use the system's current time in milliseconds or dates to get a more accurate polling of time left. But then again you would still have to use a scheduler at the lowest rate of 1 tick to poll the amount of time left.
You can use new Thread and make it sleep for a given period. Code (Text): Thread(() -> { while(true){ atomicDouble.remove(0.01); if(atomicDouble.get() == 0.0) break; try{ Thread.sleep(10); }catch(interEx){} } }).start();