Add Simulator.autoTestblock

This commit is contained in:
2025-07-10 13:40:21 +02:00
parent 30ac947ebb
commit 71238a0167
5 changed files with 5 additions and 7 deletions
@@ -95,7 +95,7 @@ public class SimulatorExecutor implements Listener {
}
});
if (simulator.isAutoTestblock()) {
if (player != null && simulator.isAutoTestblock()) {
player.performCommand("tb");
}
if (simulator.isAutoTrace() && onEnd == null) {
@@ -30,8 +30,8 @@ public class SimulatorStabGenerator {
private final StabData stabData;
public SimulatorStabGenerator(Player player, Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
stabData = new StabData(player, region, simulator, tntElement, tntElement.getPhases(), depthLimit);
public SimulatorStabGenerator(Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
stabData = new StabData(region, simulator, tntElement, tntElement.getPhases(), depthLimit);
new StabSetup(stabData);
}
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.region.Region;
import lombok.RequiredArgsConstructor;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.logging.Level;
@@ -39,7 +38,6 @@ public class StabData {
protected static final int TNT_INCREASE = 10;
protected static final int MIN_BLOCK_TO_COUNT_AS_DEPTH = 20;
protected final Player player;
protected final Region region;
protected final Simulator simulator;
protected final TNTElement tntElement;
@@ -58,7 +58,7 @@ public abstract class StabStep {
protected abstract void start();
protected final void runSimulator(Runnable onFinish) {
SimulatorExecutor.run(data.player, data.simulator, () -> {
SimulatorExecutor.run(null, data.simulator, () -> {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (this instanceof Listener) {
HandlerList.unregisterAll((Listener) this);
@@ -106,7 +106,7 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
if (depthLimit <= 0) return false;
simulator.setStabGenerator(new SimulatorStabGenerator(player, Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
SimulatorWatcher.update(simulator);
return true;
}, null).open();