SteamWar/BauSystem2.0
Archiviert
12
0

Fixed killall-tracer interaction #241

Geschlossen
D4rkr34lm möchte 1 Commits von tracer/fix-kill-command-trace-interaction nach master mergen
2 geänderte Dateien mit 21 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -249,4 +249,21 @@ public class TraceRecorder implements Listener {
activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList())); activeTraces.get(region).addRecord(record((TNTPrimed) event.getEntity(), activeTraces.get(region), event.blockList()));
} }
//TODO Refactor to use EntityRemoveEvent when its not experimental anymore
/**
* Methode to be used if a tnt should be removed for internal or technical reasons
*
* @param tnt tnt to remove
* @return whether the tnt was tracked beforehand or not
*/
public boolean removeFromRecording(TNTPrimed tnt) {
Region region = tntSpawnRegion.getOrDefault(tnt, null);
if (region == null) return false;
trackedTNT.get(region).remove(tnt);
tntSpawnRegion.remove(tnt);
historyMap.remove(tnt);
return true;
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.tracer.TraceRecorder;
import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
@ -32,6 +33,7 @@ import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -60,6 +62,7 @@ public class KillAllCommand extends SWCommand {
.forEach(entity -> { .forEach(entity -> {
entity.remove(); entity.remove();
count.incrementAndGet(); count.incrementAndGet();
if (entity instanceof TNTPrimed) TraceRecorder.instance.removeFromRecording((TNTPrimed) entity);
}); });
SWUtils.actionBar(current -> BauSystem.MESSAGE.parse("OTHER_KILLALL_GLOBAL", current, count.get())); SWUtils.actionBar(current -> BauSystem.MESSAGE.parse("OTHER_KILLALL_GLOBAL", current, count.get()));
} else { } else {
@ -70,6 +73,7 @@ public class KillAllCommand extends SWCommand {
.forEach(entity -> { .forEach(entity -> {
entity.remove(); entity.remove();
count.incrementAndGet(); count.incrementAndGet();
if (entity instanceof TNTPrimed) TraceRecorder.instance.removeFromRecording((TNTPrimed) entity);
}); });
RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get()); RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get());
} }