Fix edge cases for time conversion

This commit is contained in:
Alexander Söderberg 2020-07-17 17:51:03 +02:00 committed by Alexander Söderberg
parent 43d058d3db
commit 932052772c
3 changed files with 5 additions and 5 deletions

View File

@ -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()));
}
}

View File

@ -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);
}
}

View File

@ -96,7 +96,7 @@ public abstract class TaskManager {
* @return Task if stored, or {@code null}
*/
@Nullable public static PlotSquaredTask removeTask(final int id) {
return tasks.get(id);
return tasks.remove(id);
}
/**