SteamWar/MissileWars
Archiviert
13
0

Merge pull request 'Fix 1.19 WorldReset' (#52) from 1.19 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #52
Dieser Commit ist enthalten in:
Lixfel 2023-04-17 22:32:11 +02:00
Commit 082637e924
3 geänderte Dateien mit 32 neuen und 27 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -21,17 +21,19 @@
package de.steamwar.misslewars; package de.steamwar.misslewars;
import de.steamwar.core.CraftbukkitWrapper; import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.server.v1_15_R1.Chunk;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; 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.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 {
@ -69,11 +71,15 @@ public class FightWorld {
} }
public static void resetWorld(){ public static void resetWorld(){
for(Entity entity : world.getEntities()){ List<Entity> entities = new ArrayList<>();
if(entity.getType() != EntityType.PLAYER){ StreamSupport.stream(((CraftWorld) world).getHandle().F().a().spliterator(), false)
entity.remove(); .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;
@ -82,21 +88,10 @@ 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.server.v1_15_R1.World w = ((CraftWorld) world).getHandle(); net.minecraft.world.level.World w = ((CraftWorld) world).getHandle();
Chunk chunk = w.getChunkAt(x, z); Chunk chunk = w.d(x, z);
Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z);
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().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);
}
} }
} }

Datei anzeigen

@ -1,7 +1,7 @@
/* /*
This file is a part of the SteamWar software. 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 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 it under the terms of the GNU Affero General Public License as published by