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
|
@Override
|
||||||
public final void explode(TNTPrimed tntPrimed) {
|
public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion) {
|
||||||
if (!recording && shouldStartRecording(StartType.EXPLODE)) {
|
if (!recording && shouldStartRecording(StartType.EXPLODE)) {
|
||||||
startRecording();
|
startRecording();
|
||||||
}
|
}
|
||||||
if (recording) {
|
if (recording) {
|
||||||
getRecord(tntPrimed).explode(tntPrimed);
|
Record.TNTRecord tntRecord = getRecord(tntPrimed);
|
||||||
|
if (inBuildRegion) tntRecord.setInBuildArea(true);
|
||||||
|
tntRecord.explode(tntPrimed);
|
||||||
}
|
}
|
||||||
lastExplosion = 0;
|
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.Record;
|
||||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||||
import de.steamwar.bausystem.region.Region;
|
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 de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -62,7 +64,7 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void explode(TNTPrimed tntPrimed) {
|
public void explode(TNTPrimed tntPrimed, boolean b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final NoopTraceRecorder NOOP = new NoopTraceRecorder();
|
private static final NoopTraceRecorder NOOP = new NoopTraceRecorder();
|
||||||
@ -82,7 +84,7 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void explode(TNTPrimed tntPrimed) {
|
public void explode(TNTPrimed tntPrimed, boolean b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder();
|
private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder();
|
||||||
@ -156,7 +158,9 @@ public class Recorder implements Listener {
|
|||||||
if (!(entity instanceof TNTPrimed)) {
|
if (!(entity instanceof TNTPrimed)) {
|
||||||
return;
|
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);
|
tntTraceRecorderMap.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,10 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void explode(TNTPrimed tntPrimed) {
|
public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) {
|
||||||
getRecord(tntPrimed).explode(tntPrimed);
|
Record.TNTRecord tntRecord = getRecord(tntPrimed);
|
||||||
|
if (inBuildRegion) tntRecord.setInBuildArea(true);
|
||||||
|
tntRecord.explode(tntPrimed);
|
||||||
recordMap.remove(tntPrimed);
|
recordMap.remove(tntPrimed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public interface TraceRecorder {
|
|||||||
}
|
}
|
||||||
void spawn(TNTPrimed tntPrimed);
|
void spawn(TNTPrimed tntPrimed);
|
||||||
void tick(TNTPrimed tntPrimed);
|
void tick(TNTPrimed tntPrimed);
|
||||||
void explode(TNTPrimed tntPrimed);
|
void explode(TNTPrimed tntPrimed, boolean inBuildRegion);
|
||||||
default void tick() {
|
default void tick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.bausystem.region.Region;
|
|||||||
import de.steamwar.bausystem.shared.ShowMode;
|
import de.steamwar.bausystem.shared.ShowMode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -70,6 +71,10 @@ public class Record {
|
|||||||
@Getter
|
@Getter
|
||||||
private final List<TNTPosition> positions = new ArrayList<>(82);
|
private final List<TNTPosition> positions = new ArrayList<>(82);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean inBuildArea = false;
|
||||||
|
|
||||||
public TNTRecord(long offset, Region region) {
|
public TNTRecord(long offset, Region region) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
@ -29,6 +29,7 @@ public class ShowModeParameter {
|
|||||||
private boolean sourceOnly = false;
|
private boolean sourceOnly = false;
|
||||||
private boolean explodeOnly = false;
|
private boolean explodeOnly = false;
|
||||||
private boolean ticks = false;
|
private boolean ticks = false;
|
||||||
|
private boolean buildDestroyOnly = false;
|
||||||
|
|
||||||
public void enableWater() {
|
public void enableWater() {
|
||||||
this.water = true;
|
this.water = true;
|
||||||
@ -53,4 +54,8 @@ public class ShowModeParameter {
|
|||||||
public void enableTicks() {
|
public void enableTicks() {
|
||||||
this.ticks = true;
|
this.ticks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableBuildDestroyOnly() {
|
||||||
|
this.buildDestroyOnly = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public enum ShowModeParameterType {
|
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_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"),
|
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 -> {
|
ADVANCED(showModeParameter -> {
|
||||||
@ -38,7 +38,8 @@ public enum ShowModeParameterType {
|
|||||||
}, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"),
|
}, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"),
|
||||||
SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"),
|
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"),
|
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
|
@Getter
|
||||||
private final Consumer<ShowModeParameter> showModeParameterConsumer;
|
private final Consumer<ShowModeParameter> showModeParameterConsumer;
|
||||||
|
@ -155,18 +155,22 @@ public class StoredRecords {
|
|||||||
replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop);
|
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;
|
Predicate<TNTPosition> replayTimeFilter = tntPosition -> true;
|
||||||
if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) {
|
if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) {
|
||||||
int time = replayTime.get(region).get(player);
|
int time = replayTime.get(region).get(player);
|
||||||
replayTimeFilter = tntPosition -> (80 - tntPosition.getFuseTicks()) + tntPosition.getRecord().getOffset() == time;
|
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)) {
|
if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) {
|
||||||
isolatedTNT.get(region).get(player).forEach(record -> {
|
isolatedTNT.get(region).get(player).forEach(record -> {
|
||||||
record.getPositions()
|
record.getPositions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(finalReplayTimeFilter)
|
.filter(replayTimeFilter)
|
||||||
.forEach(traceShowMode::show);
|
.forEach(traceShowMode::show);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -174,7 +178,7 @@ public class StoredRecords {
|
|||||||
record.getTnt().forEach(tntRecord -> {
|
record.getTnt().forEach(tntRecord -> {
|
||||||
tntRecord.getPositions()
|
tntRecord.getPositions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(finalReplayTimeFilter)
|
.filter(replayTimeFilter)
|
||||||
.forEach(traceShowMode::show);
|
.forEach(traceShowMode::show);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -34,6 +34,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class TraceShowManager implements Listener {
|
public class TraceShowManager implements Listener {
|
||||||
private TraceShowManager() {
|
private TraceShowManager() {
|
||||||
@ -137,8 +138,10 @@ public class TraceShowManager implements Listener {
|
|||||||
if (regionalShowModes == null) {
|
if (regionalShowModes == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Fix show with replay
|
regionalShowModes.forEach((player, tntPositionShowMode) -> {
|
||||||
regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt));
|
Predicate<TNTPosition> replayTimeFilter = StoredRecords.replayTimeFilter(region, player);
|
||||||
|
if (replayTimeFilter.test(tnt)) tntPositionShowMode.show(tnt);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only to be called by StoredRecords */
|
/* Only to be called by StoredRecords */
|
||||||
|
@ -55,6 +55,9 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show(TNTPosition position) {
|
public void show(TNTPosition position) {
|
||||||
|
if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (showModeParameter.isExplodeOnly()) {
|
if (showModeParameter.isExplodeOnly()) {
|
||||||
if (position.isExploded()) {
|
if (position.isExploded()) {
|
||||||
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
|
RoundedPosition roundedPosition = new RoundedPosition(position, factor);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren