mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 19:26:51 +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.CommandException;
|
||||||
import io.github.hello09x.devtools.command.exception.HandleCommandException;
|
import io.github.hello09x.devtools.command.exception.HandleCommandException;
|
||||||
import io.github.hello09x.fakeplayer.core.Main;
|
import io.github.hello09x.fakeplayer.core.Main;
|
||||||
|
import io.github.hello09x.fakeplayer.core.entity.FakeplayerTicker;
|
||||||
import io.github.hello09x.fakeplayer.core.util.Mth;
|
import io.github.hello09x.fakeplayer.core.util.Mth;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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);
|
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 -> {
|
.thenAcceptAsync(player -> {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class FakeplayerTicker extends BukkitRunnable {
|
public class FakeplayerTicker extends BukkitRunnable {
|
||||||
|
|
||||||
public final static long NO_REMOVE_AT = -1;
|
public final static long NON_REMOVE_AT = -1;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final FakePlayer player;
|
private final FakePlayer player;
|
||||||
@ -30,7 +30,7 @@ public class FakeplayerTicker extends BukkitRunnable {
|
|||||||
long lifespan
|
long lifespan
|
||||||
) {
|
) {
|
||||||
this.player = player;
|
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;
|
this.firstTick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class FakeplayerTicker extends BukkitRunnable {
|
|||||||
return;
|
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");
|
Main.getInjector().getInstance(FakeplayerManager.class).remove(player.getName(), "lifespan ends");
|
||||||
super.cancel();
|
super.cancel();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user