Updated EntityFireEvent.java

This commit is contained in:
Németh Noel 2021-06-30 01:20:52 +02:00
parent d522730cd7
commit 6db9ba63f4

View File

@ -3,7 +3,6 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.event.trait.CancellableEvent; import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.event.trait.EntityEvent; import net.minestom.server.event.trait.EntityEvent;
import net.minestom.server.utils.time.Tick;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.time.Duration; import java.time.Duration;
@ -16,10 +15,8 @@ public class EntityFireEvent implements EntityEvent, CancellableEvent {
private boolean cancelled; private boolean cancelled;
@SuppressWarnings("removal") public EntityFireEvent(Entity entity, int duration, TemporalUnit temporalUnit) {
@Deprecated(forRemoval = true) this(entity, Duration.of(duration, temporalUnit));
public EntityFireEvent(Entity entity, int duration, net.minestom.server.utils.time.TimeUnit timeUnit) {
this(entity, Duration.ofMillis(timeUnit.toMilliseconds(duration)));
} }
public EntityFireEvent(Entity entity, Duration duration) { public EntityFireEvent(Entity entity, Duration duration) {
@ -27,34 +24,12 @@ public class EntityFireEvent implements EntityEvent, CancellableEvent {
setFireTime(duration); setFireTime(duration);
} }
/**
* @deprecated Replaced by {@link #getFireTime(TemporalUnit)}
*/
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public long getFireTime(net.minestom.server.utils.time.TimeUnit timeUnit) {
switch (timeUnit) {
case TICK:
return duration.toMillis() / Tick.SERVER_TICKS.getDuration().toMillis();
case MILLISECOND:
return duration.toMillis();
default:
// Unexpected
return -1;
}
}
public long getFireTime(TemporalUnit temporalUnit) { public long getFireTime(TemporalUnit temporalUnit) {
return duration.toNanos() / temporalUnit.getDuration().toNanos(); return duration.toNanos() / temporalUnit.getDuration().toNanos();
} }
/** public void setFireTime(int duration, TemporalUnit temporalUnit) {
* @deprecated Replaced by {@link #setFireTime(Duration)} setFireTime(Duration.of(duration, temporalUnit));
*/
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public void setFireTime(int duration, net.minestom.server.utils.time.TimeUnit timeUnit) {
setFireTime(Duration.ofMillis(timeUnit.toMilliseconds(duration)));
} }
public void setFireTime(Duration duration) { public void setFireTime(Duration duration) {