Trace Refactor #233
@ -100,7 +100,7 @@ public class Recorder implements Listener {
|
||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
|
||||
record(tnt, trace);
|
||||
}
|
||||
trace.comitAdd();
|
||||
trace.commitAdd();
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,11 +111,17 @@ public class Recorder implements Listener {
|
||||
*/
|
||||
private void record(TNTPrimed tntPrimed, Trace trace){
|
||||
List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||
UUID tntID;
|
||||
|
||||
if(historyMap.size() == 0)
|
||||
if(historyMap.size() == 0){
|
||||
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);
|
||||
|
||||
trace.add(record);
|
||||
|
@ -26,9 +26,16 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
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
|
||||
*/
|
||||
@ -59,7 +66,8 @@ public class TNTRecord {
|
||||
*/
|
||||
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.ticksSinceStart = ticksSinceStart;
|
||||
fuse = tnt.getFuseTicks();
|
||||
|
@ -81,7 +81,10 @@ public class Trace {
|
||||
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);
|
||||
|
||||
for(Player player: serverMap.keySet()){
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren