Possible optimization of trace recorder
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
9bb4cf548b
Commit
4f2a6a70c4
@ -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();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren