mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix edge cases for time conversion
This commit is contained in:
parent
43d058d3db
commit
932052772c
@ -37,11 +37,11 @@ import javax.annotation.Nonnegative;
|
|||||||
public final class PaperTimeConverter implements TaskTime.TimeConverter {
|
public final class PaperTimeConverter implements TaskTime.TimeConverter {
|
||||||
|
|
||||||
@Override public long msToTicks(@Nonnegative final long ms) {
|
@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) {
|
@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;
|
private static final long MS_PER_TICKS = 50L;
|
||||||
|
|
||||||
@Override public long msToTicks(@Nonnegative final long ms) {
|
@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) {
|
@Override public long ticksToMs(@Nonnegative final long ticks) {
|
||||||
return ticks * MS_PER_TICKS;
|
return Math.max(1L, ticks * MS_PER_TICKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public abstract class TaskManager {
|
|||||||
* @return Task if stored, or {@code null}
|
* @return Task if stored, or {@code null}
|
||||||
*/
|
*/
|
||||||
@Nullable public static PlotSquaredTask removeTask(final int id) {
|
@Nullable public static PlotSquaredTask removeTask(final int id) {
|
||||||
return tasks.get(id);
|
return tasks.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user