Merge pull request 'main' (#2) from Mirrors/FastAsyncWorldEdit:main into upstream
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Reviewed-on: #2
Dieser Commit ist enthalten in:
Lixfel 2022-09-06 21:32:29 +02:00
Commit 2553f169aa
14 geänderte Dateien mit 67 neuen und 54 gelöschten Zeilen

Datei anzeigen

@ -26,3 +26,23 @@ jobs:
files: 'worldedit-bukkit/build/libs/FastAsyncWorldEdit-Bukkit-*.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.event.release.tag_name }}
- name: Upload release to CurseForge
uses: Kir-Antipov/mc-publish@v3.2
with:
curseforge-id: 103525
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files-primary: 'worldedit-bukkit/build/libs/FastAsyncWorldEdit-Bukkit-*.jar'
name: FastAsyncWorldEdit ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}
version-type: release
game-versions: |
1.19.1
1.19
1.18.2
1.18.1
1.18
1.17
1.16

Datei anzeigen

@ -12,7 +12,7 @@ griefprevention = "16.18"
griefdefender = "2.1.0-SNAPSHOT"
mcore = "7.0.1"
residence = "4.5._13.1"
towny = "0.98.3.5"
towny = "0.98.3.6"
redprotect = "1.9.6"
# Third party

Datei anzeigen

@ -473,7 +473,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
static List<Entity> getEntities(LevelChunk chunk) {
return chunk.level.entityManager.getEntities(new ChunkPos(chunk.locX, chunk.locZ));
return chunk.level.entityManager.getEntities(chunk.getPos());
}
}

Datei anzeigen

@ -79,6 +79,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
@ -217,10 +218,10 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
BiomeProvider biomeProvider = getBiomeProvider();
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
WorldGenSettings newOpts = levelProperties.worldGenSettings()
.withSeed(originalWorldData.settings.hardcore(), options.getSeed());
WorldGenSettings originalOpts = originalWorldData.worldGenSettings();
WorldGenSettings newOpts = options.getSeed().isPresent()
? originalOpts.withSeed(originalWorldData.isHardcore(), OptionalLong.of(seed))
: originalOpts;
LevelSettings newWorldSettings = new LevelSettings(
"faweregentempworld",
originalWorldData.settings.gameType(),

Datei anzeigen

@ -588,7 +588,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
static List<Entity> getEntities(LevelChunk chunk) {
return chunk.level.entityManager.getEntities(new ChunkPos(chunk.locX, chunk.locZ));
return chunk.level.entityManager.getEntities(chunk.getPos());
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {

Datei anzeigen

@ -213,10 +213,9 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
BiomeProvider biomeProvider = getBiomeProvider();
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
WorldGenSettings originalOpts = levelProperties.worldGenSettings();
WorldGenSettings originalOpts = originalWorldData.worldGenSettings();
WorldGenSettings newOpts = options.getSeed().isPresent()
? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed))
? originalOpts.withSeed(originalWorldData.isHardcore(), OptionalLong.of(seed))
: originalOpts;
LevelSettings newWorldSettings = new LevelSettings(
"faweregentempworld",

Datei anzeigen

@ -585,23 +585,6 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
return true;
}
@Override
public List<org.bukkit.entity.Entity> getEntities(org.bukkit.World world) {
// Quickly add each entity to a list copy.
List<Entity> mcEntities = new ArrayList<>();
((CraftWorld) world).getHandle().entityManager.getEntityGetter().getAll().forEach(mcEntities::add);
List<org.bukkit.entity.Entity> list = new ArrayList<>();
mcEntities.forEach((mcEnt) -> {
org.bukkit.entity.Entity bukkitEntity = mcEnt.getBukkitEntity();
if (bukkitEntity.isValid()) {
list.add(bukkitEntity);
}
});
return list;
}
@Override
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);

Datei anzeigen

@ -676,7 +676,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
}
if (Settings.settings().EXPERIMENTAL.REMOVE_ENTITY_FROM_WORLD_ON_CHUNK_FAIL) {
for (UUID uuid : entityRemoves) {
Entity entity = nmsWorld.entityManager.getEntityGetter().get(uuid);
Entity entity = nmsWorld.getEntities().get(uuid);
if (entity != null) {
removeEntity(entity);
}

Datei anzeigen

@ -278,20 +278,21 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
return;
}
ChunkPos coordIntPair = new ChunkPos(chunkX, chunkZ);
// UNLOADED_CHUNK
Optional<LevelChunk> optional = ((Either) chunkHolder
.getTickingChunkFuture()
.getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
LevelChunk levelChunk;
if (PaperLib.isPaper()) {
// getChunkAtIfLoadedImmediately is paper only
optional = optional.or(() -> Optional.ofNullable(nmsWorld
levelChunk = nmsWorld
.getChunkSource()
.getChunkAtIfLoadedImmediately(chunkX, chunkZ)));
.getChunkAtIfLoadedImmediately(chunkX, chunkZ);
} else {
levelChunk = ((Optional<LevelChunk>) ((Either) chunkHolder
.getTickingChunkFuture() // method is not present with new paper chunk system
.getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left())
.orElse(null);
}
if (optional.isEmpty()) {
if (levelChunk == null) {
return;
}
LevelChunk levelChunk = optional.get();
TaskManager.taskManager().task(() -> {
ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) {
@ -589,7 +590,10 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
}
static List<Entity> getEntities(LevelChunk chunk) {
return chunk.level.entityManager.getEntities(new ChunkPos(chunk.locX, chunk.locZ));
if (PaperLib.isPaper()) {
return Arrays.asList(chunk.entities.getRawData());
}
return chunk.level.entityManager.getEntities(chunk.getPos());
}
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {

Datei anzeigen

@ -214,10 +214,9 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
PrimaryLevelData originalWorldData = originalServerWorld.serverLevelData;
MinecraftServer server = originalServerWorld.getCraftServer().getServer();
PrimaryLevelData levelProperties = (PrimaryLevelData) server.getWorldData();
WorldGenSettings originalOpts = levelProperties.worldGenSettings();
WorldGenSettings originalOpts = originalWorldData.worldGenSettings();
WorldGenSettings newOpts = options.getSeed().isPresent()
? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed))
? originalOpts.withSeed(originalWorldData.isHardcore(), OptionalLong.of(seed))
: originalOpts;
LevelSettings newWorldSettings = new LevelSettings(
"faweregentempworld",

Datei anzeigen

@ -141,10 +141,9 @@ public class BukkitWorld extends AbstractWorld {
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
//FAWE start - allow async entity retrieval
List<Entity> ents = WorldEditPlugin.getInstance().getBukkitImplAdapter().getEntities(getWorld());
//FAWE end
World world = getWorld();
List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) {
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
@ -157,9 +156,7 @@ public class BukkitWorld extends AbstractWorld {
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
//FAWE start - allow async entity retrieval
for (Entity entity : WorldEditPlugin.getInstance().getBukkitImplAdapter().getEntities(getWorld())) {
//FAWE end
for (Entity entity : getWorld().getEntities()) {
list.add(BukkitAdapter.adapt(entity));
}
return list;

Datei anzeigen

@ -455,7 +455,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT), context);
if (type != null) {
state = type.getDefaultState();

Datei anzeigen

@ -484,7 +484,12 @@ public class MCEditSchematicReader extends NBTSchematicReader {
}
private BlockState getBlockState(int id, int data) {
return LegacyMapper.getInstance().getBlockFromLegacy(id, data);
BlockState foundBlock = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
if (foundBlock == null && data != 0) {
// Some schematics contain invalid data values, so try without the data value
return LegacyMapper.getInstance().getBlockFromLegacy(id, 0);
}
return foundBlock;
}
@Override

Datei anzeigen

@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.util.JoinedCharSequence;
import com.fastasyncworldedit.core.util.StringMan;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
@ -1948,6 +1949,9 @@ public final class BlockTypes {
*/
public static BlockType parse(final String type) throws InputParseException {
return parse(type, new ParserContext());
}
public static BlockType parse(final String type, final ParserContext context) throws InputParseException {
final String inputLower = type.toLowerCase(Locale.ROOT);
String input = inputLower;
@ -1958,7 +1962,7 @@ public final class BlockTypes {
if (result != null) {
return result;
}
if (context.isTryingLegacy()) {
try {
BlockStateHolder<BlockState> block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) {
@ -1966,6 +1970,7 @@ public final class BlockTypes {
}
} catch (NumberFormatException | IndexOutOfBoundsException ignored) {
}
}
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(
BlockTypesCache.values)