SteamWar/BauSystem2.0
Archiviert
12
0

Trace now closes on being deleted
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
D4rkr34lm 2024-04-22 20:15:05 +02:00
Ursprung 2ed6008aea
Commit f1b3b27c14
2 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -132,6 +132,11 @@ public class TraceManager implements Listener {
* @param trace the trace to be removed
*/
public boolean remove(Trace trace) {
Optional<Trace> activeTrace = TraceRecorder.instance.getActiveTraceForRegion(trace.getRegion());
if (activeTrace.isPresent() && activeTrace.get() == trace) {
TraceRecorder.instance.stopRecording(trace.getRegion());
}
Map<Integer, Trace> traces = tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap());
Integer traceId = traces.entrySet().stream()
.filter(entry -> entry.getValue() == trace)
@ -148,6 +153,7 @@ public class TraceManager implements Listener {
* Clears all traces
*/
public void clear(Region region) {
TraceRecorder.instance.stopRecording(region);
showDataPerRegionPerPlayer.getOrDefault(region, new HashMap<>())
.keySet()
.forEach(player -> {

Datei anzeigen

@ -185,6 +185,22 @@ public class TraceRecorder implements Listener {
return activeTraces.containsKey(region);
}
/**
* Get the trace that is currently recorded in the given region
*
* @param region the region to get the trace for
* @return the trace recorded in region or empty if no trace is recorded in region
*/
public Optional<Trace> getActiveTraceForRegion(Region region) {
TraceRecordingWrapper traceWrapper = activeTraces.get(region);
if (traceWrapper == null) {
return Optional.empty();
} else {
return Optional.of(traceWrapper.getTrace());
}
}
public long getStartTimeOfTraceInRegion(Region region) {
TraceRecordingWrapper wrapper = activeTraces.get(region);
if (wrapper == null) return 0;