Add trace ShowModeParameterType.BUILD_DESTROY_ONLY
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5e9b11d140
Commit
31f04ef07b
@ -93,12 +93,14 @@ public abstract class AutoTraceRecorder implements TraceRecorder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void explode(TNTPrimed tntPrimed) {
|
||||
public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion) {
|
||||
if (!recording && shouldStartRecording(StartType.EXPLODE)) {
|
||||
startRecording();
|
||||
}
|
||||
if (recording) {
|
||||
getRecord(tntPrimed).explode(tntPrimed);
|
||||
Record.TNTRecord tntRecord = getRecord(tntPrimed);
|
||||
if (inBuildRegion) tntRecord.setInBuildArea(true);
|
||||
tntRecord.explode(tntPrimed);
|
||||
}
|
||||
lastExplosion = 0;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -62,7 +64,7 @@ public class Recorder implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explode(TNTPrimed tntPrimed) {
|
||||
public void explode(TNTPrimed tntPrimed, boolean b) {
|
||||
}
|
||||
}
|
||||
private static final NoopTraceRecorder NOOP = new NoopTraceRecorder();
|
||||
@ -82,7 +84,7 @@ public class Recorder implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explode(TNTPrimed tntPrimed) {
|
||||
public void explode(TNTPrimed tntPrimed, boolean b) {
|
||||
}
|
||||
}
|
||||
private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder();
|
||||
@ -156,7 +158,9 @@ public class Recorder implements Listener {
|
||||
if (!(entity instanceof TNTPrimed)) {
|
||||
return;
|
||||
}
|
||||
get((TNTPrimed) entity).explode((TNTPrimed) entity);
|
||||
TraceRecorder traceRecorder = get((TNTPrimed) entity);
|
||||
Region region = tntTraceRecorderMap.get((TNTPrimed) entity);
|
||||
traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
||||
tntTraceRecorderMap.remove(entity);
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,10 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explode(TNTPrimed tntPrimed) {
|
||||
getRecord(tntPrimed).explode(tntPrimed);
|
||||
public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) {
|
||||
Record.TNTRecord tntRecord = getRecord(tntPrimed);
|
||||
if (inBuildRegion) tntRecord.setInBuildArea(true);
|
||||
tntRecord.explode(tntPrimed);
|
||||
recordMap.remove(tntPrimed);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public interface TraceRecorder {
|
||||
}
|
||||
void spawn(TNTPrimed tntPrimed);
|
||||
void tick(TNTPrimed tntPrimed);
|
||||
void explode(TNTPrimed tntPrimed);
|
||||
void explode(TNTPrimed tntPrimed, boolean inBuildRegion);
|
||||
default void tick() {
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.shared.ShowMode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -70,6 +71,10 @@ public class Record {
|
||||
@Getter
|
||||
private final List<TNTPosition> positions = new ArrayList<>(82);
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean inBuildArea = false;
|
||||
|
||||
public TNTRecord(long offset, Region region) {
|
||||
this.offset = offset;
|
||||
this.region = region;
|
||||
|
@ -29,6 +29,7 @@ public class ShowModeParameter {
|
||||
private boolean sourceOnly = false;
|
||||
private boolean explodeOnly = false;
|
||||
private boolean ticks = false;
|
||||
private boolean buildDestroyOnly = false;
|
||||
|
||||
public void enableWater() {
|
||||
this.water = true;
|
||||
@ -53,4 +54,8 @@ public class ShowModeParameter {
|
||||
public void enableTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
public void enableBuildDestroyOnly() {
|
||||
this.buildDestroyOnly = true;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public enum ShowModeParameterType {
|
||||
|
||||
WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE"),
|
||||
WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE", "BUILD_DESTROY_ONLY"),
|
||||
INTERPOLATE_Y(ShowModeParameter::enableInterpolateY, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"),
|
||||
INTERPOLATE_XZ(ShowModeParameter::enableInterpolateXZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"),
|
||||
ADVANCED(showModeParameter -> {
|
||||
@ -38,7 +38,8 @@ public enum ShowModeParameterType {
|
||||
}, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"),
|
||||
SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"),
|
||||
EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"),
|
||||
TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE");
|
||||
TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE"),
|
||||
BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER");
|
||||
|
||||
@Getter
|
||||
private final Consumer<ShowModeParameter> showModeParameterConsumer;
|
||||
|
@ -155,18 +155,22 @@ public class StoredRecords {
|
||||
replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop);
|
||||
}
|
||||
|
||||
static void show(Region region, Player player, ShowMode<TNTPosition> traceShowMode) {
|
||||
static Predicate<TNTPosition> replayTimeFilter(Region region, Player player) {
|
||||
Predicate<TNTPosition> replayTimeFilter = tntPosition -> true;
|
||||
if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) {
|
||||
int time = replayTime.get(region).get(player);
|
||||
replayTimeFilter = tntPosition -> (80 - tntPosition.getFuseTicks()) + tntPosition.getRecord().getOffset() == time;
|
||||
}
|
||||
Predicate<TNTPosition> finalReplayTimeFilter = replayTimeFilter;
|
||||
return replayTimeFilter;
|
||||
}
|
||||
|
||||
static void show(Region region, Player player, ShowMode<TNTPosition> traceShowMode) {
|
||||
Predicate<TNTPosition> replayTimeFilter = replayTimeFilter(region, player);
|
||||
if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) {
|
||||
isolatedTNT.get(region).get(player).forEach(record -> {
|
||||
record.getPositions()
|
||||
.stream()
|
||||
.filter(finalReplayTimeFilter)
|
||||
.filter(replayTimeFilter)
|
||||
.forEach(traceShowMode::show);
|
||||
});
|
||||
} else {
|
||||
@ -174,7 +178,7 @@ public class StoredRecords {
|
||||
record.getTnt().forEach(tntRecord -> {
|
||||
tntRecord.getPositions()
|
||||
.stream()
|
||||
.filter(finalReplayTimeFilter)
|
||||
.filter(replayTimeFilter)
|
||||
.forEach(traceShowMode::show);
|
||||
});
|
||||
});
|
||||
|
@ -34,6 +34,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class TraceShowManager implements Listener {
|
||||
private TraceShowManager() {
|
||||
@ -137,8 +138,10 @@ public class TraceShowManager implements Listener {
|
||||
if (regionalShowModes == null) {
|
||||
return;
|
||||
}
|
||||
// TODO: Fix show with replay
|
||||
regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt));
|
||||
regionalShowModes.forEach((player, tntPositionShowMode) -> {
|
||||
Predicate<TNTPosition> replayTimeFilter = StoredRecords.replayTimeFilter(region, player);
|
||||
if (replayTimeFilter.test(tnt)) tntPositionShowMode.show(tnt);
|
||||
});
|
||||
}
|
||||
|
||||
/* Only to be called by StoredRecords */
|
||||
|
@ -55,6 +55,9 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode {
|
||||
|
||||
@Override
|
||||
public void show(TNTPosition position) {
|
||||
if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) {
|
||||
return;
|
||||
}
|
||||
if (showModeParameter.isExplodeOnly()) {
|
||||
if (position.isExploded()) {
|
||||
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren