Fix lag of IngameListener

This commit is contained in:
2025-05-11 18:50:21 +02:00
parent a4eea298d2
commit ac00245b04
@@ -67,11 +67,15 @@ public class IngameListener extends GameStateBukkitListener {
if (blocks == null) {
return;
}
blocks.forEach(block -> {
if (block.getType() == Material.AIR || block.getType() == Material.LAVA) return;
int maxBlocks = 1_000;
while (maxBlocks > 0 && !blocks.isEmpty()) {
Block block = blocks.removeFirst();
if (block.getType() == Material.AIR || block.getType() == Material.LAVA) continue;
block.setType(Material.AIR);
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 0.1F, 1);
});
maxBlocks--;
}
blocksToMelt.computeIfAbsent(time, __ -> new ArrayList<>()).addAll(0, blocks);
}
};
blocksToMeltRunnable.runTaskTimer(TowerRun.getInstance(), 0, 1);