Trace Refactor #233
@ -67,19 +67,8 @@ public class Recorder implements Listener {
|
||||
*/
|
||||
private final Set<Region> autoTraceRegions = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Counters for how long no tnt was seen in an active auto trace region
|
||||
*/
|
||||
private final Map<Region, Integer> noTntRecordedCounter = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Amount of ticks, after wich an auto-trace is stopped, if no tnt where seen
|
||||
*/
|
||||
private final long AUTO_TRACE_STOP_TRESHHOLD = 120;
|
||||
|
||||
public Recorder(){
|
||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
noTntRecordedCounter.replaceAll((region, counter) -> counter + 1);
|
||||
record();
|
||||
checkForAutoTraceFinish();
|
||||
}, 0, 1);
|
||||
@ -100,11 +89,11 @@ public class Recorder implements Listener {
|
||||
*
|
||||
*/
|
||||
public void checkForAutoTraceFinish(){
|
||||
for(Region region: autoTraceRegions)
|
||||
if(autoTraceRegions.contains(region) && noTntRecordedCounter.get(region) != null && noTntRecordedCounter.get(region) > AUTO_TRACE_STOP_TRESHHOLD){
|
||||
for(Region region: autoTraceRegions) {
|
||||
if (autoTraceRegions.contains(region) && trackedTNT.getOrDefault(region, Collections.emptyList()).size() == 0) {
|
||||
stopRecording(region);
|
||||
autoTraceRegions.remove(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Starts a recording at the given region
|
||||
@ -113,7 +102,6 @@ public class Recorder implements Listener {
|
||||
*/
|
||||
public int startRecording(Region region){
|
||||
if(activeTraces.containsKey(region)) return -1;
|
||||
if(autoTraceRegions.contains(region)) noTntRecordedCounter.put(region, 0);
|
||||
Trace trace = new Trace(region);
|
||||
activeTraces.put(region, trace);
|
||||
return manager.add(trace);
|
||||
@ -141,8 +129,6 @@ public class Recorder implements Listener {
|
||||
private void record(){
|
||||
for(Region region : activeTraces.keySet()){
|
||||
Trace trace = activeTraces.get(region);
|
||||
if(trackedTNT.getOrDefault(region, Collections.emptyList()).size() > 0)
|
||||
noTntRecordedCounter.put(region, 0);
|
||||
|
||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
|
||||
record(tnt, trace);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren