From c24bc49f6ddbbf54990317d0162cecea5cb26722 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 11 Apr 2022 19:06:54 +0200 Subject: [PATCH] Fix 1.18 world reset Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/fight/FightWorld.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java index d2e138b..9e246da 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -29,9 +29,12 @@ import de.steamwar.fightsystem.utils.FlatteningWrapper; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; public class FightWorld extends StateDependent { @@ -65,10 +68,13 @@ public class FightWorld extends StateDependent { } public static void resetWorld(){ + List entities = new ArrayList<>(); Recording.iterateOverEntities(Objects::nonNull, entity -> { if(entity.getType() != EntityType.PLAYER && (!Config.ArenaLeaveable || Config.ArenaRegion.inRegion(entity.getLocation()))) - entity.remove(); + entities.add(entity); }); + entities.forEach(Entity::remove); + entities.clear(); World backup = new WorldCreator(Config.world.getName() + "/backup").createWorld(); assert backup != null;