mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Use a more logical way to convert to milliseconds
This commit is contained in:
parent
075dab79c9
commit
cda5860440
@ -12,7 +12,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
|||||||
import org.jglrxavpok.hephaistos.nbt.NBTList;
|
import org.jglrxavpok.hephaistos.nbt.NBTList;
|
||||||
import org.jglrxavpok.hephaistos.nbt.NBTTypes;
|
import org.jglrxavpok.hephaistos.nbt.NBTTypes;
|
||||||
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -98,7 +98,7 @@ public class PotionMeta extends ItemMeta implements ItemMetaBuilder.Provider<Pot
|
|||||||
for (NBTCompound potionCompound : customEffectList) {
|
for (NBTCompound potionCompound : customEffectList) {
|
||||||
final byte id = potionCompound.getAsByte("Id");
|
final byte id = potionCompound.getAsByte("Id");
|
||||||
final byte amplifier = potionCompound.getAsByte("Amplifier");
|
final byte amplifier = potionCompound.getAsByte("Amplifier");
|
||||||
final int duration = potionCompound.containsKey("Duration") ? potionCompound.getNumber("Duration").intValue() : (int) ChronoUnit.SECONDS.getDuration().multipliedBy(30).toMillis();
|
final int duration = potionCompound.containsKey("Duration") ? potionCompound.getNumber("Duration").intValue() : (int) Duration.ofSeconds(30).toMillis();
|
||||||
final boolean ambient = potionCompound.containsKey("Ambient") ? potionCompound.getAsByte("Ambient") == 1 : false;
|
final boolean ambient = potionCompound.containsKey("Ambient") ? potionCompound.getAsByte("Ambient") == 1 : false;
|
||||||
final boolean showParticles = potionCompound.containsKey("ShowParticles") ? potionCompound.getAsByte("ShowParticles") == 1 : true;
|
final boolean showParticles = potionCompound.containsKey("ShowParticles") ? potionCompound.getAsByte("ShowParticles") == 1 : true;
|
||||||
final boolean showIcon = potionCompound.containsKey("ShowIcon") ? potionCompound.getAsByte("ShowIcon") == 1 : true;
|
final boolean showIcon = potionCompound.containsKey("ShowIcon") ? potionCompound.getAsByte("ShowIcon") == 1 : true;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.minestom.server.utils.time;
|
package net.minestom.server.utils.time;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.time.temporal.TemporalUnit;
|
import java.time.temporal.TemporalUnit;
|
||||||
|
|
||||||
@ -21,6 +22,6 @@ public class TimeUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getMillis(long amount, TemporalUnit unit) {
|
public static long getMillis(long amount, TemporalUnit unit) {
|
||||||
return unit.getDuration().multipliedBy(amount).toMillis();
|
return Duration.of(amount, unit).toMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user