From 85ba9d3233d1ad874554983a447389ef192949bf Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 18 Apr 2023 19:49:08 +0200 Subject: [PATCH] Fix MW WorldReset --- src/de/steamwar/misslewars/FightWorld.java | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/misslewars/FightWorld.java b/src/de/steamwar/misslewars/FightWorld.java index aacc901..c523cc0 100644 --- a/src/de/steamwar/misslewars/FightWorld.java +++ b/src/de/steamwar/misslewars/FightWorld.java @@ -21,6 +21,7 @@ package de.steamwar.misslewars; +import de.steamwar.core.CraftbukkitWrapper; import net.minecraft.world.level.chunk.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; @@ -28,12 +29,9 @@ import org.bukkit.WorldCreator; import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; 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; import java.util.function.ObjIntConsumer; -import java.util.stream.StreamSupport; public class FightWorld { @@ -71,15 +69,7 @@ public class FightWorld { } public static void resetWorld(){ - List entities = new ArrayList<>(); - StreamSupport.stream(((CraftWorld) world).getHandle().F().a().spliterator(), false) - .filter(Objects::nonNull) - .forEach(entity -> { - if(entity.getBukkitEntity().getType() != EntityType.PLAYER) - entities.add(entity.getBukkitEntity()); - }); - entities.forEach(Entity::remove); - entities.clear(); + world.getEntities().stream().filter(entity -> entity.getType() != EntityType.PLAYER).forEach(Entity::remove); World backup = new WorldCreator(world.getName() + "/backup").createWorld(); assert backup != null; @@ -88,10 +78,12 @@ public class FightWorld { } private static void resetChunk(World world, World backup, int x, int z) { - net.minecraft.world.level.World w = ((CraftWorld) world).getHandle(); - Chunk chunk = w.d(x, z); + Chunk chunk = ((CraftWorld) world).getHandle().d(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z); System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length); + + for(Player p : Bukkit.getOnlinePlayers()) + CraftbukkitWrapper.impl.sendChunk(p, x, z); } }