SteamWar/BauSystem2.0
Archiviert
12
0

Possible optimization of trace recorder
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-10-16 18:12:51 +02:00
Ursprung 9bb4cf548b
Commit 4f2a6a70c4

Datei anzeigen

@ -36,9 +36,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.*;
import java.util.stream.Collectors;
@Linked
@ -135,12 +133,19 @@ public class Recorder implements Listener {
}
}
private Set<TNTPrimed> activeTNTs = new HashSet<>();
{
activeTNTs.addAll(world.getEntitiesByClass(TNTPrimed.class));
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed)) {
return;
}
activeTNTs.add((TNTPrimed) entity);
get((TNTPrimed) entity).spawn((TNTPrimed) entity);
}
@ -157,7 +162,7 @@ public class Recorder implements Listener {
}
private void tick() {
world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> {
activeTNTs.forEach(tntPrimed -> {
get(tntPrimed).tick(tntPrimed);
});
}
@ -172,6 +177,7 @@ public class Recorder implements Listener {
Region region = tntTraceRecorderMap.get((TNTPrimed) entity);
traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
tntTraceRecorderMap.remove(entity);
activeTNTs.remove(entity);
tick();
}
}