From f42f06226ca32e81aeb6c8f38edb2212e034aae6 Mon Sep 17 00:00:00 2001 From: RePixelatedMC Date: Mon, 25 Sep 2023 15:12:45 +0200 Subject: [PATCH] Optimized it thx coco --- .../volmit/iris/core/service/ObjectSVC.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/service/ObjectSVC.java b/src/main/java/com/volmit/iris/core/service/ObjectSVC.java index 0139a1b70..5fadf8b4a 100644 --- a/src/main/java/com/volmit/iris/core/service/ObjectSVC.java +++ b/src/main/java/com/volmit/iris/core/service/ObjectSVC.java @@ -70,23 +70,22 @@ public class ObjectSVC implements IrisService { * @param blocks The blocks to remove */ private void revert(Map blocks) { - int amount = 0; Iterator> it = blocks.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry = it.next(); - BlockData data = entry.getValue(); - Bukkit.getScheduler().runTask(Iris.instance, () -> { + Bukkit.getScheduler().runTask(Iris.instance, () -> { + int amount = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + BlockData data = entry.getValue(); entry.getKey().setBlockData(data, false); - }); - it.remove(); + it.remove(); - amount++; + amount++; - if (amount > 200) { - J.s(() -> revert(blocks), 1); + if (amount > 200) { + J.s(() -> revert(blocks), 1); + } } - } + }); } - } \ No newline at end of file