diff --git a/src/main/java/net/minestom/server/utils/time/UpdateOption.java b/src/main/java/net/minestom/server/utils/time/UpdateOption.java index 603d3de13..91bf9895e 100644 --- a/src/main/java/net/minestom/server/utils/time/UpdateOption.java +++ b/src/main/java/net/minestom/server/utils/time/UpdateOption.java @@ -2,6 +2,7 @@ package net.minestom.server.utils.time; import org.jetbrains.annotations.NotNull; +import java.time.temporal.TemporalUnit; import java.util.Objects; /** @@ -11,11 +12,11 @@ import java.util.Objects; public class UpdateOption { private final long value; - private final TimeUnit timeUnit; + private final TemporalUnit temporalUnit; - public UpdateOption(long value, @NotNull TimeUnit timeUnit) { + public UpdateOption(long value, @NotNull TemporalUnit temporalUnit) { this.value = value; - this.timeUnit = timeUnit; + this.temporalUnit = temporalUnit; } public long getValue() { @@ -23,13 +24,13 @@ public class UpdateOption { } @NotNull - public TimeUnit getTimeUnit() { - return timeUnit; + public TemporalUnit getTemporalUnit() { + return temporalUnit; } @Override public int hashCode() { - return Objects.hash(value, timeUnit); + return Objects.hash(value, temporalUnit); } @Override @@ -37,7 +38,7 @@ public class UpdateOption { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UpdateOption updateOption = (UpdateOption) o; - return Objects.equals(value, updateOption.value) && Objects.equals(timeUnit, updateOption.timeUnit); + return Objects.equals(value, updateOption.value) && Objects.equals(temporalUnit, updateOption.temporalUnit); } /** @@ -46,6 +47,6 @@ public class UpdateOption { * @return the converted milliseconds based on the time value and the unit */ public long toMilliseconds() { - return timeUnit.toMilliseconds(value); + return temporalUnit.getDuration().multipliedBy(value).toMillis(); } }