Simplified millis calculation

This commit is contained in:
Németh Noel 2021-06-30 13:10:22 +02:00
parent 01dfe2f48d
commit c9dd06ba20
4 changed files with 5 additions and 5 deletions

View File

@ -1536,7 +1536,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
this.scheduledRemoveTime = 0;
return;
}
this.scheduledRemoveTime = System.currentTimeMillis() + temporalUnit.getDuration().multipliedBy(delay).toMillis();
this.scheduledRemoveTime = System.currentTimeMillis() + TimeUnit.getMillis(delay, temporalUnit);
}
/**

View File

@ -242,7 +242,7 @@ public class ItemEntity extends Entity {
* @param temporalUnit the unit of the delay
*/
public void setPickupDelay(long delay, @NotNull TemporalUnit temporalUnit) {
this.pickupDelay = temporalUnit.getDuration().multipliedBy(delay).toMillis();
this.pickupDelay = TimeUnit.getMillis(delay, temporalUnit);
}
/**

View File

@ -670,10 +670,10 @@ public class LivingEntity extends Entity implements EquipmentHandler {
* Changes the delay between two fire damage applications.
*
* @param fireDamagePeriod the delay
* @param temporalUnit the time unit
* @param temporalUnit the time unit
*/
public void setFireDamagePeriod(long fireDamagePeriod, @NotNull TemporalUnit temporalUnit) {
fireDamagePeriod = temporalUnit.getDuration().multipliedBy(fireDamagePeriod).toMillis();
fireDamagePeriod = TimeUnit.getMillis(fireDamagePeriod, temporalUnit);
this.fireDamagePeriod = fireDamagePeriod;
}

View File

@ -48,7 +48,7 @@ public class UpdateOption {
* @return the converted milliseconds based on the time value and the unit
*/
public long toMilliseconds() {
return temporalUnit.getDuration().multipliedBy(value).toMillis();
return TimeUnit.getMillis(value, temporalUnit);
}
public Duration toDuration() {