minecraft-src/net/minecraft/gametest/framework/GameTestTicker.java
2025-07-04 01:41:11 +03:00

43 lines
1 KiB
Java

package net.minecraft.gametest.framework;
import com.google.common.collect.Lists;
import java.util.Collection;
import net.minecraft.Util;
import org.jetbrains.annotations.Nullable;
public class GameTestTicker {
public static final GameTestTicker SINGLETON = new GameTestTicker();
private final Collection<GameTestInfo> testInfos = Lists.<GameTestInfo>newCopyOnWriteArrayList();
@Nullable
private GameTestRunner runner;
private GameTestTicker() {
}
public void add(GameTestInfo testInfo) {
this.testInfos.add(testInfo);
}
public void clear() {
this.testInfos.clear();
if (this.runner != null) {
this.runner.stop();
this.runner = null;
}
}
public void setRunner(GameTestRunner runner) {
if (this.runner != null) {
Util.logAndPauseIfInIde("The runner was already set in GameTestTicker");
}
this.runner = runner;
}
public void tick() {
if (this.runner != null) {
this.testInfos.forEach(gameTestInfo -> gameTestInfo.tick(this.runner));
this.testInfos.removeIf(GameTestInfo::isDone);
}
}
}