Tick Calculator
Convert between seconds and ticks and get scheduler code for delays and repeats.
Minecraft servers do not count time in seconds. They count in ticks, and the scheduler wants ticks. This calculator turns seconds, minutes and hours into ticks and back, writes the exact scheduler code for a delay or a repeat, shows you on a timeline when it will run, and explains the Minecraft day clock.
What is a tick?
The server runs its whole game in small steps. In each step it moves mobs, grows crops, checks redstone and handles players. One step is one tick. A healthy server does exactly 20 ticks per second, so one tick lasts 50 milliseconds.
When you ask the scheduler to run your code "in 3 seconds", you really say "in 60 ticks". The scheduler counts ticks, not clock time, so the rule you need is:
If the server lags and only manages 10 ticks per second, those 60 ticks take 6 real seconds. That is one reason some schedulers count real time instead. The calculator shows both.
The Tick Calculator
The Tick Calculator is loading. If this message stays, JavaScript is turned off in your browser.
Which scheduler method should I use?
Paper has two families of schedulers. Both do the same job; they differ in where the code runs and what unit the numbers use.
- The Bukkit scheduler (
getServer().getScheduler()) is the classic one.runTaskLaterruns your code once after a delay.runTaskTimerruns it again and again, with a first delay and then a period. Everything is in ticks. TheAsynchronouslyversions run on another thread. This family does not work on Folia. - The Folia-style schedulers are the newer family and work on both Paper and Folia. The global region scheduler (
runDelayed,runAtFixedRate) is for work that does not belong to one place. The region scheduler takes aLocation. The entity scheduler follows anEntity. These also take ticks. - The async scheduler (
getAsyncScheduler()) is different: it takes a number and aTimeUnitsuch asTimeUnit.SECONDS. It counts real time, so lag does not move it. Use it for work that must not touch the game: files, databases, web requests.
Most plugins start with the Bukkit scheduler. Timing and tasks: the scheduler explains each method, and Folia and regionized scheduling explains when the second family matters.
How to use the generated code
Pick a preset or fill in the times
Choose "Every 5 minutes", or type your own delay and repeat time with a unit. You can mix units: a delay of 10 seconds and a repeat of 2 minutes is fine.
Copy the code into onEnable (or any method)
The snippet starts with
getServer()and usesthisas the plugin, so it works inside your main class. If it usesTimeUnit, copy the import line too.Replace the log line with your own code
The calculator logs a message so you can see it run. Put your own code inside the braces instead.
Stop repeating tasks when you are done
A repeating task runs until the plugin is disabled. The
taskintask -> { ... }is the task itself, andtask.cancel()stops it.
Common questions
- What is the difference between delay and period? The delay is the wait before the first run. The period is the wait between one run and the next. A task with delay 0 and period 20 runs now and then every second.
- Why does the number end in L? The scheduler wants a
long, a bigger kind of whole number.20Lis just the number 20 written as a long. - Why not use Thread.sleep? Sleeping on the main thread freezes the entire server, so nobody can move. The scheduler waits without blocking anything.
- Can I schedule a delay shorter than one tick? No. A tick is the smallest step. The calculator rounds to the nearest whole tick and tells you when it does.
Mistakes beginners make with time
- Passing seconds where ticks are expected.
runTaskLater(this, task, 5L)waits a quarter of a second, not five seconds. For five seconds write100L. - Using the async scheduler for ticks.
runDelayed(this, task, 100, TimeUnit.SECONDS)waits 100 seconds, not 100 ticks. - A repeat of 0. A task cannot repeat every 0 ticks. The fastest possible is every tick (
1L). - Forgetting that a day is 24000 ticks. Setting the time to 24000 is the same as 0. The day clock below shows where each tick falls.
- Depending on exact timing. If the server lags, tick-based tasks run late. If you need a real-time guarantee, such as a cooldown measured in seconds, store
System.currentTimeMillis()when it starts. Cooldowns, toggles and player state shows how.
Recap
- 20 ticks = 1 second, so ticks = seconds x 20. One tick is 50 milliseconds.
- The Bukkit scheduler and the Folia-style scheduler count ticks. The async scheduler counts real time with a
TimeUnit. - Delay is the wait before the first run; period is the time between runs.
- A Minecraft day is 24000 ticks (20 real minutes), and tick 0 is 6:00 in the morning.
Quick quiz
You want a task to run once, 10 seconds from now, with the Bukkit scheduler. What delay do you pass to
runTaskLater?The scheduler counts ticks and there are 20 per second, so 10 seconds is 200 ticks.10Lwould be half a second, and10000Lis over eight minutes.How long is one Minecraft day in real time on a healthy server?
A day is 24000 ticks. At 20 ticks per second that is 1200 seconds, or 20 minutes.Which call waits 5 real seconds no matter how laggy the server is?
Only the async scheduler counts real time. The tick-based calls take longer when the server lags, and5Lis only a quarter of a second anyway.What does the first number after the task mean in
runTaskTimer(this, task, 40L, 100L)?40L is the delay before the first run (2 seconds). The period, the time between runs, is the last number: 100L, which is 5 seconds.
Announce every 10 minutes
You want your server to log "Remember to vote!" every 10 minutes, starting 1 minute after the plugin starts. Use the calculator to find the two numbers and the code. What are the delay and the period in ticks?
Hint
Show the solution
The delay is 1200 ticks and the period is 12000 ticks, so the code is getServer().getScheduler().runTaskTimer(this, task -> { ... }, 1200L, 12000L);. Check: 1 minute is 60 seconds times 20, which is 1200, and 10 minutes is ten times that.
Next steps
Use your new numbers in Timing and tasks: the scheduler and Patterns: cooldowns, toggles and player state. If you want a text countdown on screen, see titles, action bars and boss bars.