Merge pull request 'tracer/bug-354-Fix-smaller-trace-issues' (#242) from tracer/bug-354-Fix-smaller-trace-issues into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #242 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
929400b4d9
@ -57,17 +57,21 @@ public class TraceCommand extends SWCommand {
|
||||
public void stop(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
TraceRecorder.instance.stopRecording(region);
|
||||
|
||||
|
||||
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(region)) {
|
||||
TraceRecorder.instance.removeAutoTraceRegion(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "auto", description = "TRACE_COMMAND_HELP_AUTO")
|
||||
public void auto(@Validator Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (TraceRecorder.instance.toggleAutoTrace(region)) {
|
||||
TraceRecorder.instance.addAutoTraceRegion(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_START", player);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_STOP", player);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
@ -248,7 +252,7 @@ public class TraceCommand extends SWCommand {
|
||||
@Override
|
||||
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
for (ViewFlag flag : ViewFlag.flags) {
|
||||
if (s.equals("--" + flag.name)) {
|
||||
if (s.equals("-" + flag.name)) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
@ -74,18 +74,12 @@ public class TraceRecorder implements Listener {
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles auto trace for the given region
|
||||
*
|
||||
* @param region
|
||||
*/
|
||||
public boolean toggleAutoTrace(Region region) {
|
||||
if (!autoTraceRegions.remove(region)) {
|
||||
public void addAutoTraceRegion(Region region) {
|
||||
autoTraceRegions.add(region);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeAutoTraceRegion(Region region) {
|
||||
autoTraceRegions.remove(region);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,6 +131,7 @@ public class TraceRecorder implements Listener {
|
||||
TraceRecordingWrapper wrappedTrace = activeTraces.get(region);
|
||||
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||
TNTPoint record = record(tnt, wrappedTrace, Collections.emptyList());
|
||||
if (record == null) continue;
|
||||
wrappedTrace.addRecord(record);
|
||||
}
|
||||
wrappedTrace.commitRecorded();
|
||||
@ -153,6 +148,17 @@ public class TraceRecorder implements Listener {
|
||||
*/
|
||||
private TNTPoint record(TNTPrimed tntPrimed, TraceRecordingWrapper wrappedTrace, List<Block> destroyedBlocks) {
|
||||
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||
// Failsave for tnt entering unloaded chunks
|
||||
if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) {
|
||||
Region region = tntSpawnRegion.get(tntPrimed);
|
||||
if (region == null) return null;
|
||||
trackedTNT.get(region).remove(tntPrimed);
|
||||
tntSpawnRegion.remove(tntPrimed);
|
||||
historyMap.remove(tntPrimed);
|
||||
tntSpawnRegion.remove(tntPrimed);
|
||||
return null;
|
||||
}
|
||||
|
||||
int tntID;
|
||||
|
||||
if (history.size() == 0) {
|
||||
@ -168,7 +174,7 @@ public class TraceRecorder implements Listener {
|
||||
}
|
||||
boolean afterFirstExplosion = wrappedTrace.isExplosionRecorded();
|
||||
|
||||
TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks);
|
||||
TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentRealTick.get() - wrappedTrace.getStartTick(), history, destroyedBlocks);
|
||||
history.add(record);
|
||||
|
||||
return record;
|
||||
@ -248,6 +254,7 @@ public class TraceRecorder implements Listener {
|
||||
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
||||
|
||||
activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList()));
|
||||
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
||||
historyMap.remove((TNTPrimed) event.getEntity());
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren