SteamWar/BauSystem2.0
Archiviert
12
0

Added id to filter for records of same tnt
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
D4rkr34lm 2024-03-01 11:46:30 +01:00
Ursprung e71ccc3160
Commit eeb47f1d08
3 geänderte Dateien mit 22 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -100,7 +100,7 @@ public class Recorder implements Listener {
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){ for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
record(tnt, trace); record(tnt, trace);
} }
trace.comitAdd(); trace.commitAdd();
} }
} }
@ -111,11 +111,17 @@ public class Recorder implements Listener {
*/ */
private void record(TNTPrimed tntPrimed, Trace trace){ private void record(TNTPrimed tntPrimed, Trace trace){
List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
UUID tntID;
if(historyMap.size() == 0) if(historyMap.size() == 0){
historyMap.put(tntPrimed, history); historyMap.put(tntPrimed, history);
tntID = UUID.randomUUID();
}
else
tntID = history.get(0).getTntId();
TNTRecord record = new TNTRecord(tntPrimed, tntPrimed.getFuseTicks() == 0, TPSUtils.currentTick.get() - trace.getStartTime(), history);
TNTRecord record = new TNTRecord(tntID, tntPrimed, tntPrimed.getFuseTicks() == 0, TPSUtils.currentTick.get() - trace.getStartTime(), history);
history.add(record); history.add(record);
trace.add(record); trace.add(record);

Datei anzeigen

@ -26,9 +26,16 @@ import org.bukkit.util.Vector;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID;
@Getter @Getter
public class TNTRecord { public class TNTRecord {
/**
* Unique number to identify records being of the same tnt
*/
private final UUID tntId;
/** /**
* Whether this is a record of a tnt explosion or an entity * Whether this is a record of a tnt explosion or an entity
*/ */
@ -59,7 +66,8 @@ public class TNTRecord {
*/ */
private final List<TNTRecord> history; private final List<TNTRecord> history;
public TNTRecord(TNTPrimed tnt, boolean explosion, long ticksSinceStart, List<TNTRecord> history){ public TNTRecord(UUID tntId, TNTPrimed tnt, boolean explosion, long ticksSinceStart, List<TNTRecord> history){
this.tntId = tntId;
this.explosion = explosion; this.explosion = explosion;
this.ticksSinceStart = ticksSinceStart; this.ticksSinceStart = ticksSinceStart;
fuse = tnt.getFuseTicks(); fuse = tnt.getFuseTicks();

Datei anzeigen

@ -81,7 +81,10 @@ public class Trace {
newRecords.add(records); newRecords.add(records);
} }
protected void comitAdd(){ /**
* Commits the additions made to this trace and updates active renders of this trace
*/
protected void commitAdd(){
records.addAll(newRecords); records.addAll(newRecords);
for(Player player: serverMap.keySet()){ for(Player player: serverMap.keySet()){