From 93960b83c2892c98402052a3d9e26085f0a308f7 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 28 Dec 2023 19:15:47 +0100 Subject: [PATCH] New method Tick.toDuration(long) --- .../src/main/java/fr/pandacube/lib/util/Tick.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java index daec951..2c7384a 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java @@ -1,5 +1,7 @@ package fr.pandacube.lib.util; +import java.time.Duration; + /** * Provides methods related to Minecraft Java server ticks. */ @@ -44,4 +46,14 @@ public class Tick { return tick * MS_PER_TICK; } + + /** + * Returns the {@link Duration} for the provided number of ticks. + * @param tick the duration in ticks + * @return the {@link Duration} for the provided number of ticks. + */ + public static Duration toDuration(long tick) { + return Duration.ofMillis(toMs(tick)); + } + }