mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-31 20:41:29 +01:00
Added more TimeUnit (HOUR/MINUTE/SECOND)
This commit is contained in:
parent
2daccd9d9b
commit
4c889923f1
@ -4,16 +4,23 @@ import net.minestom.server.MinecraftServer;
|
|||||||
|
|
||||||
public enum TimeUnit {
|
public enum TimeUnit {
|
||||||
|
|
||||||
TICK, MILLISECOND;
|
TICK, HOUR, MINUTE, SECOND, MILLISECOND;
|
||||||
|
|
||||||
public long toMilliseconds(long value) {
|
public long toMilliseconds(long value) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case TICK:
|
case TICK:
|
||||||
return MinecraftServer.TICK_MS * value;
|
return MinecraftServer.TICK_MS * value;
|
||||||
|
case HOUR:
|
||||||
|
return value * 3_600_000;
|
||||||
|
case MINUTE:
|
||||||
|
return value * 60_000;
|
||||||
|
case SECOND:
|
||||||
|
return value * 1000;
|
||||||
case MILLISECOND:
|
case MILLISECOND:
|
||||||
return value;
|
return value;
|
||||||
|
default:
|
||||||
|
return -1; // Unexpected
|
||||||
}
|
}
|
||||||
return -1; // Unexpected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user