forked from SteamWar/SteamWar
Fix lag of IngameListener
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user