mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Fix edge cases for time conversion
This commit is contained in:

committed by
Alexander Söderberg

parent
43d058d3db
commit
932052772c
@ -37,11 +37,11 @@ import javax.annotation.Nonnegative;
|
||||
public final class PaperTimeConverter implements TaskTime.TimeConverter {
|
||||
|
||||
@Override public long msToTicks(@Nonnegative final long ms) {
|
||||
return (long) (ms / Bukkit.getAverageTickTime());
|
||||
return Math.max(1L, (long) (ms / Bukkit.getAverageTickTime()));
|
||||
}
|
||||
|
||||
@Override public long ticksToMs(@Nonnegative final long ticks) {
|
||||
return (long) (ticks * Bukkit.getAverageTickTime());
|
||||
return Math.max(1L, (long) (ticks * Bukkit.getAverageTickTime()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,11 +37,11 @@ public final class SpigotTimeConverter implements TaskTime.TimeConverter {
|
||||
private static final long MS_PER_TICKS = 50L;
|
||||
|
||||
@Override public long msToTicks(@Nonnegative final long ms) {
|
||||
return ms / MS_PER_TICKS;
|
||||
return Math.max(1L, ms / MS_PER_TICKS);
|
||||
}
|
||||
|
||||
@Override public long ticksToMs(@Nonnegative final long ticks) {
|
||||
return ticks * MS_PER_TICKS;
|
||||
return Math.max(1L, ticks * MS_PER_TICKS);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user