SteamWar/BauSystem2.0
Archiviert
12
0

Update TNTSimulator
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-11 12:16:19 +01:00
Ursprung 161341da72
Commit d76f499a4e
5 geänderte Dateien mit 151 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -521,13 +521,16 @@ BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht
# Trace # Trace
TRACE_RECORD=§aan TRACE_RECORD=§aan
TRACE_RECORD-AUTO=§aan TRACE_RECORD-AUTO=§aan
TRACE_RECORD-SINGLE=§aan
TRACE_IDLE=§caus TRACE_IDLE=§caus
TRACE_IDLE-AUTO=§eauto TRACE_IDLE-AUTO=§eauto
TRACE_IDLE-SINGLE=§esingle
TRACE_MESSAGE-AUTO_RECORD=§cTNT-Tracer muss gestoppt werden TRACE_MESSAGE-AUTO_RECORD=§cTNT-Tracer muss gestoppt werden
TRACE_MESSAGE-AUTO_RECORD-AUTO=§cTNT-Tracer darf nicht aufnehmen TRACE_MESSAGE-AUTO_RECORD-AUTO=§cTNT-Tracer darf nicht aufnehmen
TRACE_MESSAGE-AUTO_IDLE=§cAuto-Tracer gestoppt TRACE_MESSAGE-AUTO_IDLE=§cAuto-Tracer gestoppt
TRACE_MESSAGE-AUTO_IDLE-AUTO = §aAuto-Tracer gestartet TRACE_MESSAGE-AUTO_IDLE-AUTO = §aAuto-Tracer gestartet
TRACE_MESSAGE_START = §aTNT-Tracer gestartet TRACE_MESSAGE_START = §aTNT-Tracer gestartet
TRACE_MESSAGE_SINGLE = §aSingle-Tracer gestartet
TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt
TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht
TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt

Datei anzeigen

@ -24,7 +24,9 @@ package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.worlddata.SimulatorData; import de.steamwar.bausystem.worlddata.SimulatorData;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
@ -88,12 +90,6 @@ public class TNTSimulator {
simulator.hide(); simulator.hide();
} }
public void saveAndDelete() {
save();
TNT_SIMULATOR_MAP.remove(player);
SimulatorData.removeSimulator(player, "");
}
public void delete() { public void delete() {
TNTSimulator simulator = TNT_SIMULATOR_MAP.remove(player); TNTSimulator simulator = TNT_SIMULATOR_MAP.remove(player);
SimulatorData.removeSimulator(player, ""); SimulatorData.removeSimulator(player, "");
@ -159,7 +155,7 @@ public class TNTSimulator {
return; return;
} }
if (tntSpawns.size() == 1) { if (tntSpawns.size() == 1) {
tntSpawns.get(0).editTNT(); tntSpawns.get(0).editTNT(spawns);
} else { } else {
showGUI(new HashSet<>(tntSpawns)); showGUI(new HashSet<>(tntSpawns));
} }
@ -181,6 +177,12 @@ public class TNTSimulator {
} }
public void start() { public void start() {
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
if (simulatorAutoTrace) {
RecordStateMachine.commandSingle();
player.performCommand("trace show");
}
Map<Integer, List<TNTSpawn>> first = new HashMap<>(); Map<Integer, List<TNTSpawn>> first = new HashMap<>();
Map<Integer, List<TNTSpawn>> second = new HashMap<>(); Map<Integer, List<TNTSpawn>> second = new HashMap<>();
int lastTick = 0; int lastTick = 0;
@ -225,8 +227,7 @@ public class TNTSimulator {
}).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList()); }).sorted(Comparator.comparing(SWListInv.SWListEntry::getObject)).collect(Collectors.toList());
SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, spawn) -> { SWListInv<TNTSpawn> swListInv = new SWListInv<>(player, "Kanonensimulator", false, swListEntryList, (clickType, spawn) -> {
spawn.editTNT(tntSpawns);
spawn.editTNT();
}); });
swListInv.setItem(51, new SWItem(Material.BARRIER, "§cTNT löschen", clickType -> { swListInv.setItem(51, new SWItem(Material.BARRIER, "§cTNT löschen", clickType -> {
delete(); delete();
@ -236,9 +237,72 @@ public class TNTSimulator {
start(); start();
player.closeInventory(); player.closeInventory();
})); }));
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
swListInv.setItem(48, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: §7" + simulatorAutoTrace, clickType -> {
Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace);
showGUI(tntSpawns);
}));
swListInv.setItem(49, new SWItem(Material.MAGENTA_GLAZED_TERRACOTTA, "§eAlle Verschieben", clickType -> {
move(tntSpawns);
}));
swListInv.open(); swListInv.open();
} }
private void move(Set<TNTSpawn> tntSpawns) {
SWInventory swInventory = new SWInventory(player, 54, "TNT Verschieben");
// Position Settings
// X Position
swInventory.setItem(12, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR));
move(tntSpawns);
}));
swInventory.setItem(21, new SWItem(Material.PAPER, "§7x-Position", clickType -> {
}));
swInventory.setItem(30, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR));
move(tntSpawns);
}));
// Y Position
swInventory.setItem(13, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR));
move(tntSpawns);
}));
swInventory.setItem(22, new SWItem(Material.PAPER, "§7y-Position", clickType -> {
}));
swInventory.setItem(31, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR));
move(tntSpawns);
}));
// Z Position
swInventory.setItem(14, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR));
move(tntSpawns);
}));
swInventory.setItem(23, new SWItem(Material.PAPER, "§7z-Position", clickType -> {
}));
swInventory.setItem(32, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
updatePosition(tntSpawns, vector -> vector.subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR));
move(tntSpawns);
}));
swInventory.setItem(53, new SWItem(Material.ARROW, "§eZurück", clickType -> {
showGUI(tntSpawns);
}));
swInventory.open();
}
private void updatePosition(Set<TNTSpawn> tntSpawns, Consumer<Vector> positionChanger) {
Set<Vector> vectors = new HashSet<>();
for (TNTSpawn tntSpawn : tntSpawns) {
if (vectors.add(tntSpawn.position)) {
positionChanger.accept(tntSpawn.position);
}
}
}
private List<TNTSpawn> getEntity(Entity entity) { private List<TNTSpawn> getEntity(Entity entity) {
List<TNTSpawn> tntSpawns = new ArrayList<>(); List<TNTSpawn> tntSpawns = new ArrayList<>();
for (TNTSpawn spawn : spawns) { for (TNTSpawn spawn : spawns) {
@ -331,7 +395,7 @@ public class TNTSimulator {
this.position = position; this.position = position;
this.entity = entity; this.entity = entity;
show(); show();
editTNT(); editTNT(spawns);
} }
private TNTSpawn(YAPIONObject yapionObject) { private TNTSpawn(YAPIONObject yapionObject) {
@ -411,7 +475,7 @@ public class TNTSimulator {
return -Integer.compare(tickOffset, tntSpawn.tickOffset); return -Integer.compare(tickOffset, tntSpawn.tickOffset);
} }
private void editTNT() { private void editTNT(Set<TNTSpawn> tntSpawns) {
hide(); hide();
entity.setPosition(position); entity.setPosition(position);
show(); show();
@ -420,49 +484,49 @@ public class TNTSimulator {
// Change Count of spawned TNT // Change Count of spawned TNT
swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> { swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> {
setCount(count + (clickType.isShiftClick() ? 5 : 1)); setCount(count + (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
SWItem countItem = new SWItem(Material.TNT, "§7TNT-Anzahl §8- §e" + count, LORE, false, clickType -> changeCount(player, "Anzahl TNT", count, c -> { SWItem countItem = new SWItem(Material.TNT, "§7TNT-Anzahl §8- §e" + count, LORE, false, clickType -> changeCount(player, "Anzahl TNT", count, c -> {
setCount(c); setCount(c);
editTNT(); editTNT(tntSpawns);
}, this::editTNT)); }, () -> editTNT(tntSpawns)));
countItem.getItemStack().setAmount(count); countItem.getItemStack().setAmount(count);
swInventory.setItem(10, countItem); swInventory.setItem(10, countItem);
swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> { swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> {
setCount(count - (clickType.isShiftClick() ? 5 : 1)); setCount(count - (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
// Change TickOffset // Change TickOffset
swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> { swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> {
setTickOffset(tickOffset + (clickType.isShiftClick() ? 5 : 1)); setTickOffset(tickOffset + (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), "§7Tick §8- §e" + tickOffset, LORE, false, clickType -> changeCount(player, "Tick Offset", tickOffset, tick -> { SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), "§7Tick §8- §e" + tickOffset, LORE, false, clickType -> changeCount(player, "Tick Offset", tickOffset, tick -> {
setTickOffset(tick); setTickOffset(tick);
editTNT(); editTNT(tntSpawns);
}, this::editTNT)); }, () -> editTNT(tntSpawns)));
tickItem.getItemStack().setAmount(Math.max(tickOffset, 1)); tickItem.getItemStack().setAmount(Math.max(tickOffset, 1));
swInventory.setItem(11, tickItem); swInventory.setItem(11, tickItem);
swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> { swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> {
setTickOffset(tickOffset - (clickType.isShiftClick() ? 5 : 1)); setTickOffset(tickOffset - (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
// Change FuseTicks // Change FuseTicks
swInventory.setItem(3, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> { swInventory.setItem(3, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+5"), false, clickType -> {
setFuseTicks(fuseTicks + (clickType.isShiftClick() ? 5 : 1)); setFuseTicks(fuseTicks + (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
SWItem fuseTickItem = new SWItem(Material.CLOCK, "§7Lebensdauer §8- §e" + fuseTicks, LORE, false, clickType -> changeCount(player, "Fuse-Ticks", fuseTicks, tick -> { SWItem fuseTickItem = new SWItem(Material.CLOCK, "§7Lebensdauer §8- §e" + fuseTicks, LORE, false, clickType -> changeCount(player, "Fuse-Ticks", fuseTicks, tick -> {
setFuseTicks(tick); setFuseTicks(tick);
editTNT(); editTNT(tntSpawns);
}, this::editTNT)); }, () -> editTNT(tntSpawns)));
fuseTickItem.getItemStack().setAmount(Math.max(fuseTicks, 1)); fuseTickItem.getItemStack().setAmount(Math.max(fuseTicks, 1));
swInventory.setItem(12, fuseTickItem); swInventory.setItem(12, fuseTickItem);
swInventory.setItem(21, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> { swInventory.setItem(21, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-5"), false, clickType -> {
setFuseTicks(fuseTicks - (clickType.isShiftClick() ? 5 : 1)); setFuseTicks(fuseTicks - (clickType.isShiftClick() ? 5 : 1));
editTNT(); editTNT(tntSpawns);
})); }));
// Velocity Settings // Velocity Settings
@ -476,74 +540,74 @@ public class TNTSimulator {
yVelocity = true; yVelocity = true;
zVelocity = true; zVelocity = true;
} }
editTNT(); editTNT(tntSpawns);
}); });
swInventory.setItem(46, new SWItem(getWool(xVelocity), getColor(xVelocity), "§7TNT §eSprung X §8- " + active(xVelocity), clickType -> { swInventory.setItem(46, new SWItem(getWool(xVelocity), getColor(xVelocity), "§7TNT §eSprung X §8- " + active(xVelocity), clickType -> {
xVelocity = !xVelocity; xVelocity = !xVelocity;
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(29, new SWItem(getWool(yVelocity), getColor(yVelocity), "§7TNT §eSprung Y §8- " + active(yVelocity), clickType -> { swInventory.setItem(29, new SWItem(getWool(yVelocity), getColor(yVelocity), "§7TNT §eSprung Y §8- " + active(yVelocity), clickType -> {
yVelocity = !yVelocity; yVelocity = !yVelocity;
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(48, new SWItem(getWool(zVelocity), getColor(zVelocity), "§7TNT §eSprung Z §8- " + active(zVelocity), clickType -> { swInventory.setItem(48, new SWItem(getWool(zVelocity), getColor(zVelocity), "§7TNT §eSprung Z §8- " + active(zVelocity), clickType -> {
zVelocity = !zVelocity; zVelocity = !zVelocity;
editTNT(); editTNT(tntSpawns);
})); }));
// Position Settings // Position Settings
// X Position // X Position
swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> { swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
position.add(clickType.isShiftClick() ? FX_VECTOR : X_VECTOR); position.add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(14, new SWItem(Material.PAPER, "§7x-Position §8- §e" + position.getX(), LORE, false, clickType -> { swInventory.setItem(14, new SWItem(Material.PAPER, "§7x-Position §8- §e" + position.getX(), LORE, false, clickType -> {
changePosition(player, position.getX(), x -> { changePosition(player, position.getX(), x -> {
position.setX(clamp(x)); position.setX(clamp(x));
editTNT(); editTNT(tntSpawns);
}, this::editTNT); }, () -> editTNT(tntSpawns));
})); }));
swInventory.setItem(23, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> { swInventory.setItem(23, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
position.subtract(clickType.isShiftClick() ? FX_VECTOR : X_VECTOR); position.subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
// Y Position // Y Position
swInventory.setItem(6, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> { swInventory.setItem(6, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
position.add(clickType.isShiftClick() ? FY_VECTOR : Y_VECTOR); position.add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(15, new SWItem(Material.PAPER, "§7y-Position §8- §e" + position.getY(), LORE, false, clickType -> { swInventory.setItem(15, new SWItem(Material.PAPER, "§7y-Position §8- §e" + position.getY(), LORE, false, clickType -> {
changePosition(player, position.getY(), y -> { changePosition(player, position.getY(), y -> {
position.setY(clamp(y)); position.setY(clamp(y));
editTNT(); editTNT(tntSpawns);
}, this::editTNT); }, () -> editTNT(tntSpawns));
})); }));
swInventory.setItem(24, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> { swInventory.setItem(24, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
position.subtract(clickType.isShiftClick() ? FY_VECTOR : Y_VECTOR); position.subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
// Z Position // Z Position
swInventory.setItem(7, new SWItem(SWItem.getDye(10), "§7+0,0625", Arrays.asList("§eShift §7Click für §e+1"), false, clickType -> { swInventory.setItem(7, new SWItem(SWItem.getDye(10), "§7+1", Arrays.asList("§eShift §7Click für §e+0,0625"), false, clickType -> {
position.add(clickType.isShiftClick() ? FZ_VECTOR : Z_VECTOR); position.add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(16, new SWItem(Material.PAPER, "§7z-Position §8- §e" + position.getZ(), LORE, false, clickType -> { swInventory.setItem(16, new SWItem(Material.PAPER, "§7z-Position §8- §e" + position.getZ(), LORE, false, clickType -> {
changePosition(player, position.getZ(), z -> { changePosition(player, position.getZ(), z -> {
position.setZ(clamp(z)); position.setZ(clamp(z));
editTNT(); editTNT(tntSpawns);
}, this::editTNT); }, () -> editTNT(tntSpawns));
})); }));
swInventory.setItem(25, new SWItem(SWItem.getDye(1), "§7-0,0625", Arrays.asList("§eShift §7Click für §e-1"), false, clickType -> { swInventory.setItem(25, new SWItem(SWItem.getDye(1), "§7-1", Arrays.asList("§eShift §7Click für §e-0,0625"), false, clickType -> {
position.subtract(clickType.isShiftClick() ? FZ_VECTOR : Z_VECTOR); position.subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
editTNT(); editTNT(tntSpawns);
})); }));
// Repeater before Comparator // Repeater before Comparator
swInventory.setItem(42, new SWItem(comparator ? SWItem.getMaterial("REDSTONE_COMPARATOR_OFF") : SWItem.getMaterial("DIODE"), "§7Gezündet durch §8- §e" + (comparator ? "Comparator" : "Repeater"), clickType -> { swInventory.setItem(42, new SWItem(comparator ? SWItem.getMaterial("REDSTONE_COMPARATOR_OFF") : SWItem.getMaterial("DIODE"), "§7Gezündet durch §8- §e" + (comparator ? "Comparator" : "Repeater"), clickType -> {
comparator = !comparator; comparator = !comparator;
editTNT(); editTNT(tntSpawns);
})); }));
swInventory.setItem(33, new SWItem(Material.TNT, "§eZündphase hinzufügen", clickType -> { swInventory.setItem(33, new SWItem(Material.TNT, "§eZündphase hinzufügen", clickType -> {
@ -551,7 +615,7 @@ public class TNTSimulator {
})); }));
swInventory.setItem(53, new SWItem(Material.ARROW, "§eZurück", clickType -> { swInventory.setItem(53, new SWItem(Material.ARROW, "§eZurück", clickType -> {
showGUI(); showGUI(tntSpawns);
})); }));
swInventory.setItem(51, new SWItem(Material.DISPENSER, "§eTNT hinzufügen", clickType -> { swInventory.setItem(51, new SWItem(Material.DISPENSER, "§eTNT hinzufügen", clickType -> {

Datei anzeigen

@ -263,6 +263,13 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p);
} }
@Register({"single"})
public void singleCommand(Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandSingle();
BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p);
}
@Register({"stop"}) @Register({"stop"})
public void stopCommand(Player p) { public void stopCommand(Player p) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
@ -270,12 +277,8 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p);
} }
@Register({"toggleauto"})
public void toggleAutoCommand(Player p) {
autoCommand(p);
}
@Register({"auto"}) @Register({"auto"})
@Register({"toggleauto"})
public void autoCommand(Player p) { public void autoCommand(Player p) {
if (!permissionCheck(p)) return; if (!permissionCheck(p)) return;
RecordStateMachine.commandAuto(); RecordStateMachine.commandAuto();

Datei anzeigen

@ -53,14 +53,32 @@ public class RecordStateMachine {
} }
} }
public static void commandSingle() {
if (recordStatus.isTracing())
return;
if (recordStatus != RecordStatus.IDLE_SINGLE) {
recordStatus = RecordStatus.IDLE_SINGLE;
autoHandler.enable();
}
}
static void autoRecord() { static void autoRecord() {
recordStart(); recordStart();
recordStatus = RecordStatus.RECORD_AUTO; if (recordStatus == RecordStatus.IDLE_AUTO) {
recordStatus = RecordStatus.RECORD_AUTO;
} else {
recordStatus = RecordStatus.RECORD_SINGLE;
}
} }
static void autoIdle() { static void autoIdle() {
recordStop(); recordStop();
recordStatus = RecordStatus.IDLE_AUTO; if (recordStatus == RecordStatus.RECORD_AUTO) {
recordStatus = RecordStatus.IDLE_AUTO;
} else {
recordStatus = RecordStatus.IDLE;
}
} }
private static void recordStart() { private static void recordStart() {

Datei anzeigen

@ -23,8 +23,10 @@ public enum RecordStatus {
RECORD("TRACE_RECORD", true, "TRACE_MESSAGE-AUTO_RECORD"), RECORD("TRACE_RECORD", true, "TRACE_MESSAGE-AUTO_RECORD"),
RECORD_AUTO("TRACE_RECORD-AUTO", true, "TRACE_MESSAGE-AUTO_RECORD-AUTO"), RECORD_AUTO("TRACE_RECORD-AUTO", true, "TRACE_MESSAGE-AUTO_RECORD-AUTO"),
RECORD_SINGLE("TRACE_RECORD-SINGLE", true, ""),
IDLE("TRACE_IDLE", false, "TRACE_MESSAGE-AUTO_IDLE"), IDLE("TRACE_IDLE", false, "TRACE_MESSAGE-AUTO_IDLE"),
IDLE_AUTO("TRACE_IDLE-AUTO", false, "TRACE_MESSAGE-AUTO_IDLE-AUTO"); IDLE_AUTO("TRACE_IDLE-AUTO", false, "TRACE_MESSAGE-AUTO_IDLE-AUTO"),
IDLE_SINGLE("TRACE_IDLE-SINGLE", false, "");
String name; String name;
boolean tracing; boolean tracing;
@ -51,5 +53,4 @@ public enum RecordStatus {
public String getAutoMessage() { public String getAutoMessage() {
return autoMessage; return autoMessage;
} }
} }