Updated Instance.java

This commit is contained in:
Németh Noel 2021-06-30 01:46:03 +02:00
parent 2c9f0c5e67
commit 25183973dc

View File

@ -39,7 +39,6 @@ import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.entity.EntityUtils;
import net.minestom.server.utils.time.Cooldown;
import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.utils.time.UpdateOption;
import net.minestom.server.utils.validate.Check;
import net.minestom.server.world.DimensionType;
import org.jetbrains.annotations.ApiStatus;
@ -47,6 +46,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -80,7 +80,7 @@ public abstract class Instance implements BlockModifier, Tickable, TagHandler, P
// The time of the instance
private long time;
private int timeRate = 1;
private UpdateOption timeUpdate = new UpdateOption(1, TimeUnit.SECOND);
private Duration timeUpdate = Duration.of(1, TimeUnit.SECOND);
private long lastTimeUpdate;
// Field for tick events
@ -416,7 +416,7 @@ public abstract class Instance implements BlockModifier, Tickable, TagHandler, P
* @return the client update rate for time related packet
*/
@Nullable
public UpdateOption getTimeUpdate() {
public Duration getTimeUpdate() {
return timeUpdate;
}
@ -428,7 +428,21 @@ public abstract class Instance implements BlockModifier, Tickable, TagHandler, P
*
* @param timeUpdate the new update rate concerning time
*/
public void setTimeUpdate(@Nullable UpdateOption timeUpdate) {
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public void setTimeUpdate(@Nullable net.minestom.server.utils.time.UpdateOption timeUpdate) {
setTimeUpdate(timeUpdate.toDuration());
}
/**
* Changes the rate at which the client is updated about the time
* <p>
* Setting it to null means that the client will never know about time change
* (but will still change server-side)
*
* @param timeUpdate the new update rate concerning time
*/
public void setTimeUpdate(@Nullable Duration timeUpdate) {
this.timeUpdate = timeUpdate;
}