mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-27 14:13:24 +02:00
Deprecated net.minestom.server.entity.Entity.scheduleRemove(long, java.time.temporal.TemporalUnit)
This commit is contained in:
parent
fdf7153986
commit
bcc1132ed7
@ -1530,17 +1530,29 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
||||
* @param delay the time before removing the entity,
|
||||
* 0 to cancel the removing
|
||||
* @param temporalUnit the unit of the delay
|
||||
* @deprecated Replaced by {@link #scheduleRemove(Duration)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void scheduleRemove(long delay, @NotNull TemporalUnit temporalUnit) {
|
||||
if (delay == 0) { // Cancel the scheduled remove
|
||||
this.scheduledRemoveTime = 0;
|
||||
return;
|
||||
}
|
||||
this.scheduledRemoveTime = System.currentTimeMillis() + TimeUnit.getMillis(delay, temporalUnit);
|
||||
scheduleRemove(Duration.of(delay, temporalUnit));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the entity removal has been scheduled with {@link #scheduleRemove(long, TemporalUnit)}.
|
||||
* Triggers {@link #remove()} after the specified time.
|
||||
*
|
||||
* @param delay the time before removing the entity,
|
||||
* 0 to cancel the removing
|
||||
*/
|
||||
public void scheduleRemove(Duration delay) {
|
||||
if (delay.isZero()) { // Cancel the scheduled remove
|
||||
this.scheduledRemoveTime = 0;
|
||||
return;
|
||||
}
|
||||
this.scheduledRemoveTime = System.currentTimeMillis() + delay.toMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the entity removal has been scheduled with {@link #scheduleRemove(Duration)}.
|
||||
*
|
||||
* @return true if the entity removal has been scheduled
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@ import net.minestom.server.utils.time.TimeUnit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -80,7 +81,7 @@ public class EntityCreature extends LivingEntity implements NavigableEntity, Ent
|
||||
|
||||
if (removalAnimationDelay > 0) {
|
||||
// Needed for proper death animation (wait for it to finish before destroying the entity)
|
||||
scheduleRemove(removalAnimationDelay, TimeUnit.MILLISECOND);
|
||||
scheduleRemove(Duration.of(removalAnimationDelay, TimeUnit.MILLISECOND));
|
||||
} else {
|
||||
// Instant removal without animation playback
|
||||
remove();
|
||||
|
Loading…
Reference in New Issue
Block a user