SteamWar/MissileWars
Archiviert
13
0

Fix 1.19 WorldReset #52

Zusammengeführt
Lixfel hat 2 Commits von 1.19 nach master 2023-04-17 22:32:12 +02:00 zusammengeführt
3 geänderte Dateien mit 32 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -94,6 +94,14 @@ sourceSets {
repositories {
mavenCentral()
maven {
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
url = uri('https://steamwar.de/maven/')
credentials {
@ -109,9 +117,11 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
compileOnly swdep("SpigotCore")
compileOnly swdep("Spigot-1.15")
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
compileOnly swdep("Spigot-1.19")
compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore")
}
task buildProject {

Datei anzeigen

@ -21,17 +21,19 @@
package de.steamwar.misslewars;
import de.steamwar.core.CraftbukkitWrapper;
import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.world.level.chunk.Chunk;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
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 {
@ -69,11 +71,15 @@ public class FightWorld {
}
public static void resetWorld(){
for(Entity entity : world.getEntities()){
if(entity.getType() != EntityType.PLAYER){
entity.remove();
}
}
List<Entity> 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 backup = new WorldCreator(world.getName() + "/backup").createWorld();
assert backup != null;
@ -82,21 +88,10 @@ public class FightWorld {
}
private static void resetChunk(World world, World backup, int x, int z) {
net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z);
net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.d(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();
chunk.tileEntities.putAll(backupChunk.tileEntities);
chunk.heightMap.clear();
chunk.heightMap.putAll(backupChunk.heightMap);
for(Player p : Bukkit.getOnlinePlayers()){
CraftbukkitWrapper.impl.sendChunk(p, x, z);
}
System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length);
}
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
Copyright (C) 2023 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by