Dieser Commit ist enthalten in:
Ursprung
082637e924
Commit
85ba9d3233
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
|
import de.steamwar.core.CraftbukkitWrapper;
|
||||||
import net.minecraft.world.level.chunk.Chunk;
|
import net.minecraft.world.level.chunk.Chunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -28,12 +29,9 @@ import org.bukkit.WorldCreator;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
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.function.ObjIntConsumer;
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
public class FightWorld {
|
public class FightWorld {
|
||||||
|
|
||||||
@ -71,15 +69,7 @@ public class FightWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void resetWorld(){
|
public static void resetWorld(){
|
||||||
List<Entity> entities = new ArrayList<>();
|
world.getEntities().stream().filter(entity -> entity.getType() != EntityType.PLAYER).forEach(Entity::remove);
|
||||||
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 backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
World backup = new WorldCreator(world.getName() + "/backup").createWorld();
|
||||||
assert backup != null;
|
assert backup != null;
|
||||||
@ -88,10 +78,12 @@ public class FightWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void resetChunk(World world, World backup, int x, int z) {
|
private static void resetChunk(World world, World backup, int x, int z) {
|
||||||
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
|
Chunk chunk = ((CraftWorld) world).getHandle().d(x, z);
|
||||||
Chunk chunk = w.d(x, z);
|
|
||||||
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
|
||||||
|
|
||||||
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
|
||||||
|
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
|
CraftbukkitWrapper.impl.sendChunk(p, x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren