Nothing important

This commit is contained in:
tanyaofei 2024-08-09 13:52:47 +08:00
parent 4d22061c6c
commit ba7d32b0e0
2 changed files with 5 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import dev.jorel.commandapi.executors.CommandArguments;
import io.github.hello09x.devtools.command.exception.CommandException;
import io.github.hello09x.devtools.command.exception.HandleCommandException;
import io.github.hello09x.fakeplayer.core.Main;
import io.github.hello09x.fakeplayer.core.entity.FakeplayerTicker;
import io.github.hello09x.fakeplayer.core.util.Mth;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
@ -68,7 +69,7 @@ public class SpawnCommand extends AbstractCommand {
}
var removedAt = Optional.ofNullable(config.getLifespan()).map(lifespan -> LocalDateTime.now().plus(lifespan)).orElse(null);
manager.spawnAsync(sender, name, spawnpoint, Optional.ofNullable(config.getLifespan()).map(Duration::toMillis).orElse(-1L))
manager.spawnAsync(sender, name, spawnpoint, Optional.ofNullable(config.getLifespan()).map(Duration::toMillis).orElse(FakeplayerTicker.NON_REMOVE_AT))
.thenAcceptAsync(player -> {
if (player == null) {
return;

View File

@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
public class FakeplayerTicker extends BukkitRunnable {
public final static long NO_REMOVE_AT = -1;
public final static long NON_REMOVE_AT = -1;
@NotNull
private final FakePlayer player;
@ -30,7 +30,7 @@ public class FakeplayerTicker extends BukkitRunnable {
long lifespan
) {
this.player = player;
this.removeAt = lifespan > 0 ? System.currentTimeMillis() + lifespan : NO_REMOVE_AT;
this.removeAt = lifespan > 0 ? System.currentTimeMillis() + lifespan : NON_REMOVE_AT;
this.firstTick = true;
}
@ -41,7 +41,7 @@ public class FakeplayerTicker extends BukkitRunnable {
return;
}
if (this.removeAt != NO_REMOVE_AT && this.player.getTickCount() % 20 == 0 && System.currentTimeMillis() > removeAt) {
if (this.removeAt != NON_REMOVE_AT && this.player.getTickCount() % 20 == 0 && System.currentTimeMillis() > removeAt) {
Main.getInjector().getInstance(FakeplayerManager.class).remove(player.getName(), "lifespan ends");
super.cancel();
return;