Merge pull request 'Trace now closes on being deleted' (#238) from trace/trace-clear-not-stopping-trace-fix into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #238 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
18769a6931
@ -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 -> {
|
||||
|
@ -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;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren