mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 11:16:46 +08:00
Nothing important
This commit is contained in:
parent
4d22061c6c
commit
ba7d32b0e0
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user