SteamWar/BauSystem2.0
Archiviert
12
0

Added source, build-destroy, testblock-destroy
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
D4rkr34lm 2024-03-13 23:59:17 +01:00
Ursprung 1282f6066c
Commit 827929382a
3 geänderte Dateien mit 69 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance; import de.steamwar.linkage.LinkedInstance;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -138,7 +139,7 @@ public class Recorder implements Listener {
Trace trace = activeTraces.get(region); Trace trace = activeTraces.get(region);
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){ for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
record(tnt, trace); record(tnt, trace, Collections.emptyList());
} }
trace.commitAdd(); trace.commitAdd();
} }
@ -149,7 +150,7 @@ public class Recorder implements Listener {
* @param tntPrimed tnt exploding * @param tntPrimed tnt exploding
* @param trace trace to record the tnt for * @param trace trace to record the tnt for
*/ */
private void record(TNTPrimed tntPrimed, Trace trace){ private void record(TNTPrimed tntPrimed, Trace trace, List<Block> destroyedBlocks){
List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
UUID tntID; UUID tntID;
@ -165,7 +166,7 @@ public class Recorder implements Listener {
noExplosionRecorded.remove(trace); noExplosionRecorded.remove(trace);
boolean afterFirstExplosion = noExplosionRecorded.contains(trace); boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history); TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks);
history.add(record); history.add(record);
trace.add(record); trace.add(record);
@ -198,7 +199,7 @@ public class Recorder implements Listener {
* Unregisters TNTs from beeing traced on explode * Unregisters TNTs from beeing traced on explode
* @param event * @param event
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTNTExplode(EntityExplodeEvent event){ public void onTNTExplode(EntityExplodeEvent event){
if(!(event.getEntity() instanceof TNTPrimed)) return; if(!(event.getEntity() instanceof TNTPrimed)) return;
@ -207,6 +208,6 @@ public class Recorder implements Listener {
trackedTNT.get(region).remove((TNTPrimed) event.getEntity()); trackedTNT.get(region).remove((TNTPrimed) event.getEntity());
tntSpawnRegion.remove((TNTPrimed) event.getEntity()); tntSpawnRegion.remove((TNTPrimed) event.getEntity());
record((TNTPrimed) event.getEntity(), activeTraces.get(region)); record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList());
} }
} }

Datei anzeigen

@ -19,8 +19,12 @@
package de.steamwar.bausystem.features.tracer; package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -51,6 +55,16 @@ public class TNTRecord {
*/ */
private final boolean afterFirstExplosion; private final boolean afterFirstExplosion;
/**
* Whether this record has destroyed blocks in build area
*/
private final boolean destroyedBuildArea;
/**
* Whether this record has destroyed blocks in testblock area
*/
private final boolean destroyedTestBlock;
/** /**
* Tick offset, from this record being taken to the start of the trace * Tick offset, from this record being taken to the start of the trace
*/ */
@ -76,7 +90,7 @@ public class TNTRecord {
*/ */
private final List<TNTRecord> history; private final List<TNTRecord> history;
public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTRecord> history){ public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTRecord> history, List<Block> destroyedBlocks){
this.tntId = tntId; this.tntId = tntId;
this.explosion = explosion; this.explosion = explosion;
this.inWater = tnt.isInWater(); this.inWater = tnt.isInWater();
@ -86,6 +100,18 @@ public class TNTRecord {
location = tnt.getLocation(); location = tnt.getLocation();
velocity = tnt.getVelocity(); velocity = tnt.getVelocity();
this.history = history; this.history = history;
boolean buildDestroy = false;
boolean testblockDestroy = false;
for(Block destroyedBlock: destroyedBlocks){
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION))
buildDestroy = true;
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
buildDestroy = true;
}
destroyedBuildArea = buildDestroy;
destroyedTestBlock = testblockDestroy;
} }
public Optional<TNTRecord> getNext(){ public Optional<TNTRecord> getNext(){

Datei anzeigen

@ -70,6 +70,42 @@ public abstract class ViewFlag {
public void modify(REntityServer server, List<TraceEntity> entities) {} public void modify(REntityServer server, List<TraceEntity> entities) {}
}; };
public static ViewFlag SOURCE = new ViewFlag(true, false, "source") {
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream()
.filter(record -> record.getFuse() == 80)
.collect(Collectors.toList());
}
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
};
public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") {
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream()
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
.collect(Collectors.toList());
}
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
};
public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") {
@Override
public List<TNTRecord> filter(List<TNTRecord> records) {
return records.stream()
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
.collect(Collectors.toList());
}
@Override
public void modify(REntityServer server, List<TraceEntity> entities) {}
};
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") { public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") {
@Override @Override
public List<TNTRecord> filter(List<TNTRecord> records) {return records;} public List<TNTRecord> filter(List<TNTRecord> records) {return records;}