forked from SteamWar/SteamWar
Add Simulator.autoTestblock
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@ public class SimulatorCommand extends SWCommand {
|
||||
|
||||
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
||||
public void start(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
||||
SimulatorExecutor.run(simulator, () -> {});
|
||||
SimulatorExecutor.run(p, simulator, () -> {});
|
||||
}
|
||||
|
||||
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")
|
||||
|
||||
+1
-1
@@ -367,7 +367,7 @@ public class SimulatorCursor implements Listener {
|
||||
if (simulator == null) {
|
||||
return;
|
||||
}
|
||||
SimulatorExecutor.run(simulator, () -> {});
|
||||
SimulatorExecutor.run(event.getPlayer(), simulator, () -> {});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -40,9 +40,11 @@ public final class Simulator {
|
||||
private SimulatorStabGenerator stabGenerator = null;
|
||||
private Material material = Material.BARREL;
|
||||
private final String name;
|
||||
private boolean autoTrace = false;
|
||||
private final List<SimulatorGroup> groups = new ArrayList<>();
|
||||
|
||||
private boolean autoTrace = false;
|
||||
private boolean autoTestblock = false;
|
||||
|
||||
public void move(int x, int y, int z) {
|
||||
groups.forEach(simulatorGroup -> {
|
||||
simulatorGroup.move(x, y, z);
|
||||
|
||||
+12
-1
@@ -25,17 +25,25 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||
import de.steamwar.bausystem.utils.TickStartEvent;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
@@ -46,7 +54,7 @@ public class SimulatorExecutor implements Listener {
|
||||
private static Map<Long, Map<Integer, List<SimulatorAction>>> tickStartActions = new HashMap<>();
|
||||
private static Map<Long, List<SimulatorAction>> tickEndActions = new HashMap<>();
|
||||
|
||||
public static boolean run(Simulator simulator, Runnable onEnd) {
|
||||
public static boolean run(Player player, Simulator simulator, Runnable onEnd) {
|
||||
if (currentlyRunning.contains(simulator)) return false;
|
||||
currentlyRunning.add(simulator);
|
||||
|
||||
@@ -87,6 +95,9 @@ public class SimulatorExecutor implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
if (simulator.isAutoTestblock()) {
|
||||
player.performCommand("tb");
|
||||
}
|
||||
if (simulator.isAutoTrace() && onEnd == null) {
|
||||
simulator.getGroups()
|
||||
.stream()
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ public class SimulatorStabGenerator {
|
||||
|
||||
private final StabData stabData;
|
||||
|
||||
public SimulatorStabGenerator(Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
|
||||
stabData = new StabData(region, simulator, tntElement, tntElement.getPhases(), depthLimit);
|
||||
public SimulatorStabGenerator(Player player, Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
|
||||
stabData = new StabData(player, region, simulator, tntElement, tntElement.getPhases(), depthLimit);
|
||||
new StabSetup(stabData);
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -25,6 +25,7 @@ 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;
|
||||
@@ -38,6 +39,7 @@ 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;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public abstract class StabStep {
|
||||
protected abstract void start();
|
||||
|
||||
protected final void runSimulator(Runnable onFinish) {
|
||||
SimulatorExecutor.run(data.simulator, () -> {
|
||||
SimulatorExecutor.run(data.player, data.simulator, () -> {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
if (this instanceof Listener) {
|
||||
HandlerList.unregisterAll((Listener) this);
|
||||
|
||||
+5
-1
@@ -56,10 +56,14 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
}));
|
||||
|
||||
//AutoTrace
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
inventory.setItem(19, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTrace(!simulator.isAutoTrace());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTestblock() ? Material.END_STONE : Material.BARRIER, "§eTestblock§8: " + (simulator.isAutoTestblock() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTestblock(!simulator.isAutoTestblock());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
|
||||
+1
-1
@@ -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(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(player, Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorWatcher.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
|
||||
+1
@@ -68,6 +68,7 @@ public class SimFormatSimulatorLoader implements SimulatorLoader {
|
||||
private void loadSimulator(YAPIONObject simulatorObject, Simulator simulator) {
|
||||
simulator.setMaterial(Material.valueOf(simulatorObject.getPlainValue("material")));
|
||||
simulator.setAutoTrace(simulatorObject.getPlainValue("autoTrace"));
|
||||
simulator.setAutoTestblock(simulatorObject.getPlainValueOrDefault("autoTestblock", false));
|
||||
|
||||
YAPIONArray groups = simulatorObject.getArray("groups");
|
||||
groups.streamObject().forEach(groupObject -> {
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ public class SimulatorSaver {
|
||||
YAPIONObject simulatorObject = new YAPIONObject();
|
||||
simulatorObject.add("material", simulator.getMaterial().name());
|
||||
simulatorObject.add("autoTrace", simulator.isAutoTrace());
|
||||
simulatorObject.add("autoTestblock", simulator.isAutoTestblock());
|
||||
|
||||
YAPIONArray groups = new YAPIONArray();
|
||||
simulator.getGroups().forEach(group -> {
|
||||
|
||||
Reference in New Issue
Block a user