From 1dd3400aabda56cdbcc208dc395feac65fc33cce Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Wed, 17 Apr 2019 20:20:31 -0400 Subject: [PATCH 01/94] Add Mojang repository --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 853a547fe..b0c8b5aef 100644 --- a/build.gradle +++ b/build.gradle @@ -87,6 +87,7 @@ subprojects { maven {url "http://repo.dmulloy2.net/content/groups/public/"} maven {url "https://repo.destroystokyo.com/repository/maven-public//"} maven {url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/"} + maven { url "https://libraries.minecraft.net" } mavenLocal() maven {url "http://empcraft.com/maven2"} maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"} From 72c766a87b415f71c5a2db6343b2a77adae9e453 Mon Sep 17 00:00:00 2001 From: Matt <4009945+MattBDev@users.noreply.github.com> Date: Wed, 17 Apr 2019 20:22:54 -0400 Subject: [PATCH 02/94] Add DataFixerUpper --- worldedit-core/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index eb0f957c3..d87c8a774 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -23,6 +23,7 @@ dependencies { compile ("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { transitive = false } + compile 'com.mojang:datafixerupper:1.0.20' compile 'com.github.luben:zstd-jni:1.1.1' compile 'co.aikar:fastutil-lite:1.0' } From 8808ec89a06fd207456d69ec0c8810217f4a18cc Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 25 Apr 2019 01:32:27 +1000 Subject: [PATCH 03/94] Revert "wip 1.14" This reverts commit 3bf2ccdebcfc5c06770286c0e2d75fc9c5b9c152. --- .../fawe/bukkit/v1_14/BukkitChunk_1_14.java | 618 ------------ .../fawe/bukkit/v1_14/BukkitQueue_1_14.java | 938 ------------------ .../v1_14/adapter/BlockMaterial_1_14.java | 151 --- .../bukkit/v1_14/adapter/Spigot_v1_14_R1.java | 611 ------------ 4 files changed, 2318 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitChunk_1_14.java delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitChunk_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitChunk_1_14.java deleted file mode 100644 index be2ba6723..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitChunk_1_14.java +++ /dev/null @@ -1,618 +0,0 @@ -package com.boydti.fawe.bukkit.v1_14; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.bukkit.v0.BukkitQueue_0; -import com.boydti.fawe.bukkit.v1_14.adapter.BlockMaterial_1_14; -import com.boydti.fawe.bukkit.v1_14.adapter.Spigot_v1_14_R1; -import com.boydti.fawe.config.Settings; -import com.boydti.fawe.example.IntFaweChunk; -import com.boydti.fawe.jnbt.anvil.BitArray4096; -import com.boydti.fawe.object.FaweChunk; -import com.boydti.fawe.object.FaweQueue; -import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.LongTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.internal.Constants; -import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BlockID; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; -import net.minecraft.server.v1_14_R1.BiomeBase; -import net.minecraft.server.v1_14_R1.Block; -import net.minecraft.server.v1_14_R1.BlockPosition; -import net.minecraft.server.v1_14_R1.Blocks; -import net.minecraft.server.v1_14_R1.ChunkSection; -import net.minecraft.server.v1_14_R1.DataBits; -import net.minecraft.server.v1_14_R1.DataPalette; -import net.minecraft.server.v1_14_R1.DataPaletteBlock; -import net.minecraft.server.v1_14_R1.DataPaletteHash; -import net.minecraft.server.v1_14_R1.DataPaletteLinear; -import net.minecraft.server.v1_14_R1.Entity; -import net.minecraft.server.v1_14_R1.EntityPlayer; -import net.minecraft.server.v1_14_R1.EntityTypes; -import net.minecraft.server.v1_14_R1.GameProfileSerializer; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.MinecraftKey; -import net.minecraft.server.v1_14_R1.NBTTagCompound; -import net.minecraft.server.v1_14_R1.NBTTagInt; -import net.minecraft.server.v1_14_R1.NibbleArray; -import net.minecraft.server.v1_14_R1.RegistryID; -import net.minecraft.server.v1_14_R1.TileEntity; -import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock; -import org.bukkit.event.entity.CreatureSpawnEvent; - -import java.lang.reflect.InvocationTargetException; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import static com.boydti.fawe.bukkit.v0.BukkitQueue_0.getAdapter; -import static com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14.fieldRegistryb; -import static com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14.fieldRegistryc; -import static com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14.fieldRegistryd; -import static com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14.fieldRegistrye; -import static com.boydti.fawe.bukkit.v1_14.BukkitQueue_1_14.fieldRegistryf; - -public class BukkitChunk_1_14 extends IntFaweChunk { - - public ChunkSection[] sectionPalettes; - - private static final IBlockData AIR = ((BlockMaterial_1_14) BlockTypes.AIR.getMaterial()).getState(); - - /** - * A FaweSections object represents a chunk and the blocks that you wish to change in it. - * - * @param parent - * @param x - * @param z - */ - public BukkitChunk_1_14(FaweQueue parent, int x, int z) { - super(parent, x, z); - } - - public BukkitChunk_1_14(FaweQueue parent, int x, int z, int[][] ids, short[] count, short[] air) { - super(parent, x, z, ids, count, air); - } - - public void storeBiomes(BiomeBase[] biomes) { - if (biomes != null) { - if (this.biomes == null) { - this.biomes = new BiomeType[256]; - } - for (int i = 0; i < 256; i++) { - this.biomes[i] = BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(biomes[i])); - } - } - } - - @Override - public int[][] getCombinedIdArrays() { - if (this.sectionPalettes != null) { - for (int i = 0; i < setBlocks.length; i++) { - getIdArray(i); - } - } - return this.setBlocks; - } - - @Override - public int[] getIdArray(int layer) { - if (this.setBlocks[layer] == null && this.sectionPalettes != null) { - ChunkSection section = this.sectionPalettes[layer]; - int[] idsArray = this.setBlocks[layer]; - if (section != null && idsArray == null) { - this.setBlocks[layer] = idsArray = new int[4096]; - if (!section.c()) { - try { - DataPaletteBlock blocks = section.getBlocks(); - DataBits bits = (DataBits) BukkitQueue_1_14.fieldBits.get(blocks); - DataPalette palette = (DataPalette) BukkitQueue_1_14.fieldPalette.get(blocks); - - long[] raw = bits.a(); - int bitsPerEntry = bits.c(); - - new BitArray4096(raw, bitsPerEntry).toRaw(idsArray); - IBlockData defaultBlock = (IBlockData) BukkitQueue_1_14.fieldDefaultBlock.get(blocks); - // TODO optimize away palette.a - for (int i = 0; i < 4096; i++) { - IBlockData ibd = palette.a(idsArray[i]); - if (ibd == null) { - ibd = defaultBlock; - } - int ordinal = ((Spigot_v1_14_R1) getAdapter()).adaptToInt(ibd); - idsArray[i] = BlockTypes.states[ordinal].getInternalId(); - } - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - } - } - return this.setBlocks[layer]; - } - - public boolean storeTile(TileEntity tile, BlockPosition pos) { - CompoundTag nativeTag = getParent().getTag(tile); - setTile(pos.getX() & 15, pos.getY(), pos.getZ() & 15, nativeTag); - return true; - } - - public boolean storeEntity(Entity ent) throws InvocationTargetException, IllegalAccessException { - if (ent instanceof EntityPlayer || BukkitQueue_0.getAdapter() == null) { - return false; - } - EntityTypes type = ent.getEntityType(); - MinecraftKey id = EntityTypes.getName(type); - if (id != null) { - NBTTagCompound tag = new NBTTagCompound(); - ent.save(tag); // readEntityIntoTag - CompoundTag nativeTag = (CompoundTag) BukkitQueue_0.toNative(tag); - Map map = ReflectionUtils.getMap(nativeTag.getValue()); - map.put("Id", new StringTag(id.toString())); - setEntity(nativeTag); - return true; - } else { - return false; - } - } - - public boolean storeSection(ChunkSection section, int layer) throws IllegalAccessException { - if (sectionPalettes == null) { - // TODO optimize don't copy light - sectionPalettes = new ChunkSection[16]; - } - sectionPalettes[layer] = section; - return true; - } - - public ChunkSection copy(ChunkSection current) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException { - ChunkSection newSection = new ChunkSection(current.getYPosition()); - - // Copy counters - Object nonEmptyBlockCount = BukkitQueue_1_14.fieldNonEmptyBlockCount.get(current); - BukkitQueue_1_14.fieldNonEmptyBlockCount.set(newSection, nonEmptyBlockCount); - - Object tickingBlockCount = BukkitQueue_1_14.fieldTickingBlockCount.get(current); - BukkitQueue_1_14.fieldTickingBlockCount.set(newSection, tickingBlockCount); - - Object liquidCount = BukkitQueue_1_14.fieldLiquidCount.get(current); - BukkitQueue_1_14.fieldLiquidCount.set(newSection, liquidCount); - - // Copy blocks - DataPaletteBlock blocks = current.getBlocks(); - DataPaletteBlock blocksCopy = copy(blocks); - BukkitQueue_1_14.fieldSection.set(newSection, blocksCopy); - - return newSection; - } - - public DataPaletteBlock copy(DataPaletteBlock current) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException { - // Clone palette - DataPalette currentPalette = (DataPalette) BukkitQueue_1_14.fieldPalette.get(current); - DataPaletteBlock paletteBlock = newDataPaletteBlock(); - int size = BukkitQueue_1_14.fieldSize.getInt(current); - - DataPalette newPalette = currentPalette; - if (currentPalette instanceof DataPaletteHash) { - // TODO optimize resize - newPalette = new DataPaletteHash<>(Block.REGISTRY_ID, size, paletteBlock, GameProfileSerializer::d, GameProfileSerializer::a); - RegistryID currReg = (RegistryID) BukkitQueue_1_14.fieldHashBlocks.get(currentPalette); - RegistryID newReg = (RegistryID) BukkitQueue_1_14.fieldHashBlocks.get(newPalette); - int arrLen = 1 << size; - System.arraycopy(fieldRegistryb.get(currReg), 0, fieldRegistryb.get(newReg), 0, arrLen); - System.arraycopy(fieldRegistryc.get(currReg), 0, fieldRegistryc.get(newReg), 0, arrLen); - System.arraycopy(fieldRegistryd.get(currReg), 0, fieldRegistryd.get(newReg), 0, arrLen); - fieldRegistrye.set(newReg, fieldRegistrye.get(currReg)); - fieldRegistryf.set(newReg, fieldRegistryf.get(currReg)); - } else if (currentPalette instanceof DataPaletteLinear) { - // TODO optimize resize - newPalette = new DataPaletteLinear<>(Block.REGISTRY_ID, size, paletteBlock, GameProfileSerializer::d); - Object[] currArray = ((Object[]) BukkitQueue_1_14.fieldLinearBlocks.get(currentPalette)); - Object[] newArray = ((Object[]) BukkitQueue_1_14.fieldLinearBlocks.get(newPalette)); - BukkitQueue_1_14.fieldLinearIndex.set(newPalette, BukkitQueue_1_14.fieldLinearIndex.get(currentPalette)); - for (int i = 0; i < newArray.length; i++) newArray[i] = currArray[i]; - } - - BukkitQueue_1_14.fieldPalette.set(paletteBlock, newPalette); - // Clone size - BukkitQueue_1_14.fieldSize.set(paletteBlock, size); - // Clone palette - DataBits currentBits = (DataBits) BukkitQueue_1_14.fieldBits.get(current); - DataBits newBits = new DataBits(currentBits.c(), currentBits.b(), currentBits.a().clone()); - BukkitQueue_1_14.fieldBits.set(paletteBlock, newBits); - - // TODO copy only if different - Object defaultBlock = BukkitQueue_1_14.fieldDefaultBlock.get(current); - if (defaultBlock != AIR) { - ReflectionUtils.setFailsafeFieldValue(BukkitQueue_1_14.fieldDefaultBlock, paletteBlock, BukkitQueue_1_14.fieldDefaultBlock.get(current)); - } - - return paletteBlock; - } - - @Override - public IntFaweChunk copy(boolean shallow) { - BukkitChunk_1_14 copy; - if (shallow) { - copy = new BukkitChunk_1_14(getParent(), getX(), getZ(), setBlocks, count, air); - copy.biomes = biomes; - copy.chunk = chunk; - } else { - copy = new BukkitChunk_1_14(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(setBlocks), count.clone(), air.clone()); - copy.biomes = biomes != null ? biomes.clone() : null; - copy.chunk = chunk; - } - if (sectionPalettes != null) { - copy.sectionPalettes = new ChunkSection[16]; - try { - for (int i = 0; i < sectionPalettes.length; i++) { - ChunkSection current = sectionPalettes[i]; - if (current == null) { - continue; - } - copy.sectionPalettes[i] = copy(current); - } - } catch (Throwable e) { - MainUtil.handleError(e); - } - } - return copy; - } - - private DataPaletteBlock newDataPaletteBlock() { - return new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); - } - - @Override - public Chunk getNewChunk() { - return ((BukkitQueue_1_14) getParent()).getWorld().getChunkAt(getX(), getZ()); - } - - public void optimize() { - if (sectionPalettes != null) { - return; - } - int[][] arrays = getCombinedIdArrays(); - for (int layer = 0; layer < 16; layer++) { - if (getCount(layer) > 0) { - if (sectionPalettes == null) { - sectionPalettes = new ChunkSection[16]; - } - int[] array = arrays[layer]; - sectionPalettes[layer] = BukkitQueue_1_14.newChunkSection(layer, getParent().hasSky(), array); - } - } - } - - @Override - public void start() { - getChunk().load(true); - } - - private void removeEntity(Entity entity) { - entity.die(); - entity.valid = false; - } - - @Override - public FaweChunk call() { - Spigot_v1_14_R1 adapter = (Spigot_v1_14_R1) BukkitQueue_0.getAdapter(); - try { - BukkitChunk_1_14 copy = getParent().getChangeTask() != null ? new BukkitChunk_1_14(getParent(), getX(), getZ()) : null; - final Chunk chunk = this.getChunk(); - final World world = chunk.getWorld(); - Settings settings = getParent().getSettings(); - int bx = this.getX() << 4; - int bz = this.getZ() << 4; - final boolean flag = world.getEnvironment() == World.Environment.NORMAL; - net.minecraft.server.v1_14_R1.Chunk nmsChunk = ((CraftChunk) chunk).getHandle(); - nmsChunk.d(true); // Set Modified - nmsChunk.mustNotSave = false; - nmsChunk.markDirty(); - net.minecraft.server.v1_14_R1.World nmsWorld = nmsChunk.world; - ChunkSection[] sections = nmsChunk.getSections(); - List[] entities = nmsChunk.getEntitySlices(); - Map tiles = nmsChunk.getTileEntities(); - // Remove entities - HashSet entsToRemove = this.getEntityRemoves(); - if (!entsToRemove.isEmpty()) { - for (int i = 0; i < entities.length; i++) { - Collection ents = entities[i]; - if (!ents.isEmpty()) { - Iterator iter = ents.iterator(); - while (iter.hasNext()) { - Entity entity = iter.next(); - if (entsToRemove.contains(entity.getUniqueID())) { - if (copy != null) { - copy.storeEntity(entity); - } - iter.remove(); - synchronized (BukkitQueue_0.class) { - removeEntity(entity); - } - } - } - } - } - } - for (int i = 0; i < entities.length; i++) { - int count = this.getCount(i); - if (count == 0 || settings.EXPERIMENTAL.KEEP_ENTITIES_IN_BLOCKS) { - continue; - } else if (count >= 4096) { - Collection ents = entities[i]; - if (!ents.isEmpty()) { - synchronized (BukkitQueue_0.class) { - Iterator iter = ents.iterator(); - while (iter.hasNext()) { - Entity entity = iter.next(); - if (entity instanceof EntityPlayer) { - continue; - } - iter.remove(); - if (copy != null) { - copy.storeEntity(entity); - } - removeEntity(entity); - } - } - } - } else { - Collection ents = entities[i]; - if (!ents.isEmpty()) { - int layerYStart = i << 4; - int layerYEnd = layerYStart + 15; - int[] array = this.getIdArray(i); - if (array == null) continue; - Iterator iter = ents.iterator(); - while (iter.hasNext()) { - Entity entity = iter.next(); - if (entity instanceof EntityPlayer) { - continue; - } - int y = MathMan.roundInt(entity.locY); - if (y > layerYEnd || y < layerYStart) continue; - int x = (MathMan.roundInt(entity.locX) & 15); - int z = (MathMan.roundInt(entity.locZ) & 15); - - int index = (((y & 0xF) << 8) | (z << 4) | x); - if (array[index] != 0) { - if (copy != null) { - copy.storeEntity(entity); - } - iter.remove(); - synchronized (BukkitQueue_0.class) { - removeEntity(entity); - } - } - } - } - } - } - // Set entities - Set entitiesToSpawn = this.getEntities(); - if (!entitiesToSpawn.isEmpty()) { - synchronized (BukkitQueue_0.class) { - for (CompoundTag nativeTag : entitiesToSpawn) { - Map entityTagMap = ReflectionUtils.getMap(nativeTag.getValue()); - StringTag idTag = (StringTag) entityTagMap.get("Id"); - ListTag posTag = (ListTag) entityTagMap.get("Pos"); - ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); - if (idTag == null || posTag == null || rotTag == null) { - Fawe.debug("Unknown entity tag: " + nativeTag); - continue; - } - double x = posTag.getDouble(0); - double y = posTag.getDouble(1); - double z = posTag.getDouble(2); - float yaw = rotTag.getFloat(0); - float pitch = rotTag.getFloat(1); - String id = idTag.getValue(); - EntityTypes type = EntityTypes.a(id).orElse(null); - if (type != null) { - Entity entity = type.a(nmsWorld); - if (entity != null) { - UUID uuid = entity.getUniqueID(); - entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); - entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); - if (nativeTag != null) { - NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_14.fromNative(nativeTag); - for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { - tag.remove(name); - } - entity.f(tag); - } - entity.setLocation(x, y, z, yaw, pitch); - synchronized (BukkitQueue_0.class) { - nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); - } - } - } - } - } - } - // Set blocks - for (int j = 0; j < sections.length; j++) { - int count = this.getCount(j); - if (count == 0) { - continue; - } - int countAir = this.getAir(j); - final int[] array = this.getIdArray(j); - if (array == null) { - continue; - } - ChunkSection section = sections[j]; - if (copy != null) { - if (section != null) { - copy.storeSection(copy(section), j); - } - } - if (section == null) { - if (count == countAir) { - continue; - } - if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { - section = sections[j] = this.sectionPalettes[j]; - continue; - } else { - section = sections[j] = getParent().newChunkSection(j, flag, array); - continue; - } - } else if (count >= 4096 && false) { - if (countAir >= 4096) { - sections[j] = null; - continue; - } - if (this.sectionPalettes != null && this.sectionPalettes[j] != null) { - section = sections[j] = this.sectionPalettes[j]; - continue; - } else { - section = sections[j] = getParent().newChunkSection(j, flag, array); - continue; - } - } - int by = j << 4; - DataPaletteBlock nibble = section.getBlocks(); - int nonEmptyBlockCount = 0; - IBlockData existing; - - for (int y = 0, i = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - for (int x= 0; x < 16; x++, i++) { - int combinedId = array[i]; - switch (combinedId) { - case 0: - continue; - case BlockID.AIR: - case BlockID.CAVE_AIR: - case BlockID.VOID_AIR: - existing = nibble.a(x, y, z); - if (!existing.isAir()) { -// if (existing.e() > 0) { -// getParent().getRelighter().addLightUpdate(bx + x, by + y, bz + z); -// } - nonEmptyBlockCount--; - nibble.setBlock(x, y, z, AIR); - } - continue; - default: - existing = nibble.a(x, y, z); - if (!existing.isAir()) { -// if (existing.e() > 0) { -// getParent().getRelighter().addLightUpdate(bx + x, by + y, bz + z); -// } - } else { - nonEmptyBlockCount++; - } - BlockState state = BlockState.getFromInternalId(combinedId); - IBlockData ibd = ((BlockMaterial_1_14) state.getMaterial()).getState(); - nibble.setBlock(x, y, z, ibd); - } - } - } - } - getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); - } - - // Trim tiles - HashMap toRemove = null; - if (!tiles.isEmpty()) { - Iterator> iterator = tiles.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPosition pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int layer = ly >> 4; - int[] array = this.getIdArray(layer); - if (array == null) { - continue; - } - int index = (((ly & 0xF) << 8) | (lz << 4) | lx); - if (array[index] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - if (copy != null) { - copy.storeTile(tile.getValue(), tile.getKey()); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - synchronized (BukkitQueue_0.class) { - for (Map.Entry entry : toRemove.entrySet()) { - BlockPosition bp = entry.getKey(); - TileEntity tile = entry.getValue(); - nmsWorld.removeTileEntity(bp); - tiles.remove(bp); - tile.n(); - tile.invalidateBlockCache(); - } - } - } - } - - // Set biomes - if (this.biomes != null) { - BiomeBase[] currentBiomes = nmsChunk.getBiomeIndex(); - if (copy != null) { - copy.storeBiomes(currentBiomes); - } - for (int i = 0 ; i < this.biomes.length; i++) { - BiomeType biome = this.biomes[i]; - if (biome != null) { - Biome craftBiome = adapter.adapt(biome); - currentBiomes[i] = CraftBlock.biomeToBiomeBase(craftBiome); - } - } - } - // Set tiles - Map tilesToSpawn = this.getTiles(); - if (!tilesToSpawn.isEmpty()) { - for (Map.Entry entry : tilesToSpawn.entrySet()) { - CompoundTag nativeTag = entry.getValue(); - short blockHash = entry.getKey(); - int x = (blockHash >> 12 & 0xF) + bx; - int y = (blockHash & 0xFF); - int z = (blockHash >> 8 & 0xF) + bz; - BlockPosition pos = new BlockPosition(x, y, z); // Set pos - synchronized (BukkitQueue_0.class) { - TileEntity tileEntity = nmsWorld.getTileEntity(pos); - if (tileEntity != null) { - NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_14.fromNative(nativeTag); - tag.set("x", new NBTTagInt(x)); - tag.set("y", new NBTTagInt(y)); - tag.set("z", new NBTTagInt(z)); - tileEntity.load(tag); - } - } - } - } - // Change task - if (copy != null) { - getParent().getChangeTask().run(copy, this); - } - } catch (Throwable e) { - MainUtil.handleError(e); - } - return this; - } -} \ No newline at end of file diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java deleted file mode 100644 index 21d098f72..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/BukkitQueue_1_14.java +++ /dev/null @@ -1,938 +0,0 @@ -package com.boydti.fawe.bukkit.v1_14; - -import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweCache; -import com.boydti.fawe.bukkit.BukkitPlayer; -import com.boydti.fawe.bukkit.v0.BukkitQueue_0; -import com.boydti.fawe.bukkit.v1_14.adapter.BlockMaterial_1_14; -import com.boydti.fawe.bukkit.v1_14.adapter.Spigot_v1_14_R1; -import com.boydti.fawe.config.Settings; -import com.boydti.fawe.example.IntFaweChunk; -import com.boydti.fawe.jnbt.anvil.BitArray4096; -import com.boydti.fawe.object.FaweChunk; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RegionWrapper; -import com.boydti.fawe.object.brush.visualization.VisualChunk; -import com.boydti.fawe.object.visitor.FaweChunkVisitor; -import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.ReflectionUtils; -import com.boydti.fawe.util.TaskManager; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BlockID; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockTypes; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; -import net.minecraft.server.v1_14_R1.BiomeBase; -import net.minecraft.server.v1_14_R1.Block; -import net.minecraft.server.v1_14_R1.BlockPosition; -import net.minecraft.server.v1_14_R1.ChunkProviderServer; -import net.minecraft.server.v1_14_R1.ChunkSection; -import net.minecraft.server.v1_14_R1.ChunkStatus; -import net.minecraft.server.v1_14_R1.DataBits; -import net.minecraft.server.v1_14_R1.DataPalette; -import net.minecraft.server.v1_14_R1.DataPaletteBlock; -import net.minecraft.server.v1_14_R1.DataPaletteHash; -import net.minecraft.server.v1_14_R1.DataPaletteLinear; -import net.minecraft.server.v1_14_R1.Entity; -import net.minecraft.server.v1_14_R1.EntityPlayer; -import net.minecraft.server.v1_14_R1.EnumSkyBlock; -import net.minecraft.server.v1_14_R1.GameProfileSerializer; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.IChunkAccess; -import net.minecraft.server.v1_14_R1.NBTTagCompound; -import net.minecraft.server.v1_14_R1.Packet; -import net.minecraft.server.v1_14_R1.PacketDataSerializer; -import net.minecraft.server.v1_14_R1.PacketPlayOutMultiBlockChange; -import net.minecraft.server.v1_14_R1.PlayerChunk; -import net.minecraft.server.v1_14_R1.PlayerChunkMap; -import net.minecraft.server.v1_14_R1.RegistryID; -import net.minecraft.server.v1_14_R1.TileEntity; -import net.minecraft.server.v1_14_R1.WorldChunkManager; -import net.minecraft.server.v1_14_R1.WorldData; -import net.minecraft.server.v1_14_R1.WorldServer; -import org.bukkit.Chunk; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.atomic.LongAdder; -import java.util.function.Supplier; - -public class BukkitQueue_1_14 extends BukkitQueue_0 { - - protected final static Field fieldBits; - protected final static Field fieldPalette; - protected final static Field fieldSize; - - protected final static Field fieldHashBlocks; - protected final static Field fieldLinearBlocks; - protected final static Field fieldHashIndex; - protected final static Field fieldRegistryb; - protected final static Field fieldRegistryc; - protected final static Field fieldRegistryd; - protected final static Field fieldRegistrye; - protected final static Field fieldRegistryf; - - protected final static Field fieldLinearIndex; - protected final static Field fieldDefaultBlock; - - protected final static Field fieldFluidCount; - protected final static Field fieldTickingBlockCount; - protected final static Field fieldNonEmptyBlockCount; - protected final static Field fieldSection; - protected final static Field fieldLiquidCount; - protected final static Field fieldEmittedLight; - protected final static Field fieldSkyLight; - - -// protected final static Field fieldBiomes; - - protected final static Field fieldChunkGenerator; - protected final static Field fieldSeed; -// protected final static Field fieldBiomeCache; -// protected final static Field fieldBiomes2; - protected final static Field fieldGenLayer1; - protected final static Field fieldGenLayer2; - protected final static Field fieldSave; -// protected final static MutableGenLayer genLayer; - protected final static ChunkSection emptySection; - -// protected static final Method methodResize; - - protected final static Field fieldDirtyCount; - protected final static Field fieldDirtyBits; - - static { - try { - emptySection = new ChunkSection(0); - fieldSection = ChunkSection.class.getDeclaredField("blockIds"); - fieldLiquidCount = ChunkSection.class.getDeclaredField("e"); - fieldEmittedLight = ChunkSection.class.getDeclaredField("emittedLight"); - fieldSkyLight = ChunkSection.class.getDeclaredField("skyLight"); - fieldSection.setAccessible(true); - fieldLiquidCount.setAccessible(true); - fieldEmittedLight.setAccessible(true); - fieldSkyLight.setAccessible(true); - - fieldFluidCount = ChunkSection.class.getDeclaredField("e"); - fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount"); - fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount"); - fieldFluidCount.setAccessible(true); - fieldTickingBlockCount.setAccessible(true); - fieldNonEmptyBlockCount.setAccessible(true); - - - -// fieldBiomes = ChunkProviderGenerate.class.getDeclaredField("D"); // * -// fieldBiomes.setAccessible(true); - - fieldChunkGenerator = ChunkProviderServer.class.getDeclaredField("chunkGenerator"); - fieldChunkGenerator.setAccessible(true); - fieldSeed = WorldData.class.getDeclaredField("e"); - fieldSeed.setAccessible(true); - -// fieldBiomeCache = WorldChunkManager.class.getDeclaredField("d"); // * -// fieldBiomeCache.setAccessible(true); -// fieldBiomes2 = WorldChunkManager.class.getDeclaredField("e"); // * -// fieldBiomes2.setAccessible(true); - fieldGenLayer1 = WorldChunkManager.class.getDeclaredField("b") ; - fieldGenLayer2 = WorldChunkManager.class.getDeclaredField("c") ; - fieldGenLayer1.setAccessible(true); - fieldGenLayer2.setAccessible(true); - - fieldSave = ReflectionUtils.setAccessible(net.minecraft.server.v1_14_R1.Chunk.class.getDeclaredField("s")); //* - - fieldHashBlocks = DataPaletteHash.class.getDeclaredField("b"); - fieldHashBlocks.setAccessible(true); - fieldLinearBlocks = DataPaletteLinear.class.getDeclaredField("b"); - fieldLinearBlocks.setAccessible(true); - - fieldHashIndex = DataPaletteHash.class.getDeclaredField("f"); - fieldHashIndex.setAccessible(true); - - fieldRegistryb = RegistryID.class.getDeclaredField("b"); - fieldRegistryc = RegistryID.class.getDeclaredField("c"); - fieldRegistryd = RegistryID.class.getDeclaredField("d"); - fieldRegistrye = RegistryID.class.getDeclaredField("e"); - fieldRegistryf = RegistryID.class.getDeclaredField("f"); - fieldRegistryb.setAccessible(true); - fieldRegistryc.setAccessible(true); - fieldRegistryd.setAccessible(true); - fieldRegistrye.setAccessible(true); - fieldRegistryf.setAccessible(true); - - fieldLinearIndex = DataPaletteLinear.class.getDeclaredField("f"); - fieldLinearIndex.setAccessible(true); - - fieldDefaultBlock = DataPaletteBlock.class.getDeclaredField("g"); - fieldDefaultBlock.setAccessible(true); - - fieldSize = DataPaletteBlock.class.getDeclaredField("i"); - fieldSize.setAccessible(true); - - fieldBits = DataPaletteBlock.class.getDeclaredField("a"); - fieldBits.setAccessible(true); - - fieldPalette = DataPaletteBlock.class.getDeclaredField("h"); - fieldPalette.setAccessible(true); - -// methodResize = DataPaletteBlock.class.getDeclaredMethod("b", int.class); -// methodResize.setAccessible(true); - - fieldDirtyCount = PlayerChunk.class.getDeclaredField("dirtyCount"); - fieldDirtyBits = PlayerChunk.class.getDeclaredField("h"); - fieldDirtyCount.setAccessible(true); - fieldDirtyBits.setAccessible(true); - - Fawe.debug("Using adapter: " + getAdapter()); - Fawe.debug("========================================="); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - - public BukkitQueue_1_14(final com.sk89q.worldedit.world.World world) { - super(world); - getImpWorld(); - } - - public BukkitQueue_1_14(final String world) { - super(world); - getImpWorld(); - } - - @Override - public ChunkSection[] getSections(net.minecraft.server.v1_14_R1.Chunk chunk) { - return chunk.getSections(); - } - - @Override - public net.minecraft.server.v1_14_R1.Chunk loadChunk(World world, int x, int z, boolean generate) { - ChunkProviderServer provider = ((CraftWorld) world).getHandle().getChunkProvider(); - IChunkAccess chunk; - if (generate) { - chunk = provider.getChunkAt(x, z, ChunkStatus.FEATURES, true); - } else { - chunk = provider.getChunkAt(x, z, ChunkStatus.FEATURES, false); - } - return (net.minecraft.server.v1_14_R1.Chunk) chunk; - } - - @Override - public ChunkSection[] getCachedSections(World world, int cx, int cz) { - net.minecraft.server.v1_14_R1.Chunk chunk = (net.minecraft.server.v1_14_R1.Chunk) ((CraftWorld) world).getHandle().getChunkProvider().getChunkAt(cx, cz, ChunkStatus.FEATURES, false); - if (chunk != null) { - return chunk.getSections(); - } - return null; - } - - @Override - public net.minecraft.server.v1_14_R1.Chunk getCachedChunk(World world, int cx, int cz) { - return (net.minecraft.server.v1_14_R1.Chunk) ((CraftWorld) world).getHandle().getChunkProvider().getChunkAt(cx, cz, ChunkStatus.FEATURES, false); - } - - @Override - public ChunkSection getCachedSection(ChunkSection[] chunkSections, int cy) { - return chunkSections[cy]; - } - - @Override - public void saveChunk(net.minecraft.server.v1_14_R1.Chunk nmsChunk) { - nmsChunk.d(true); // Set Modified - nmsChunk.mustNotSave = false; - nmsChunk.markDirty(); - } - - @Override - public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) { -// if (biome != null) { -// try { -// if (seed == null) { -// seed = world.getSeed(); -// } -// nmsWorld.worldData.getSeed(); -// boolean result; -// ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, ""); -// Biome bukkitBiome = getAdapter().getBiome(biome.getId()); -// BiomeBase base = BiomeBase.getBiome(biome.getId()); -// fieldBiomes.set(generator, new BiomeBase[]{base}); -// boolean cold = base.getTemperature() <= 1; -// net.minecraft.server.v1_14_R1.ChunkGenerator existingGenerator = nmsWorld.getChunkProvider().chunkGenerator; -// long existingSeed = world.getSeed(); -// { -// if (genLayer == null) genLayer = new MutableGenLayer(seed); -// genLayer.set(biome.getId()); -// Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager()); -// Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager()); -// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer); -// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer); -// -// fieldSeed.set(nmsWorld.worldData, seed); -// -// ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager())); -// -// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), generator); -// -// keepLoaded.remove(MathMan.pairInt(x, z)); -// result = getWorld().regenerateChunk(x, z); -// net.minecraft.server.v1_14_R1.Chunk nmsChunk = getCachedChunk(world, x, z); -// if (nmsChunk != null) { -// nmsChunk.f(true); // Set Modified -// nmsChunk.mustSave = true; -// } -// -// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), existingGenerator); -// -// fieldSeed.set(nmsWorld.worldData, existingSeed); -// -// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1); -// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2); -// } -// return result; -// } catch (Throwable e) { -// e.printStackTrace(); -// } -// } - return super.regenerateChunk(world, x, z, biome, seed); - } - - @Override - public boolean setMCA(final int mcaX, final int mcaZ, final RegionWrapper allowed, final Runnable whileLocked, final boolean saveChunks, final boolean load) { - throw new UnsupportedOperationException("Anvil not implemented yet"); -// TaskManager.IMP.sync(new RunnableVal() { -// @Override -// public void run(Boolean value) { -// long start = System.currentTimeMillis(); -// long last = start; -// synchronized (RegionFileCache.class) { -// World world = getWorld(); -// if (world.getKeepSpawnInMemory()) world.setKeepSpawnInMemory(false); -// ChunkProviderServer provider = nmsWorld.getChunkProvider(); -// -// boolean mustSave = false; -// boolean[][] chunksUnloaded = null; -// { // Unload chunks -// Iterator iter = provider.a().iterator(); -// while (iter.hasNext()) { -// net.minecraft.server.v1_14_R1.Chunk chunk = iter.next(); -// if (chunk.locX >> 5 == mcaX && chunk.locZ >> 5 == mcaZ) { -// boolean isIn = allowed.isInChunk(chunk.locX, chunk.locZ); -// if (isIn) { -// if (!load) { -// mustSave |= saveChunks && save(chunk, provider); -// continue; -// } -// iter.remove(); -// boolean save = saveChunks && chunk.a(false); -// mustSave |= save; -// provider.unloadChunk(chunk, save); -// if (chunksUnloaded == null) { -// chunksUnloaded = new boolean[32][]; -// } -// int relX = chunk.locX & 31; -// boolean[] arr = chunksUnloaded[relX]; -// if (arr == null) { -// arr = chunksUnloaded[relX] = new boolean[32]; -// } -// arr[chunk.locZ & 31] = true; -// } -// } -// } -// } -// if (mustSave) { -// provider.c(); // TODO only the necessary chunks -// } -// -// File unloadedRegion = null; -// if (load && !RegionFileCache.a.isEmpty()) { -// Map map = RegionFileCache.a; -// Iterator> iter = map.entrySet().iterator(); -// String requiredPath = world.getName() + File.separator + "region"; -// while (iter.hasNext()) { -// Map.Entry entry = iter.next(); -// File file = entry.getKey(); -// int[] regPos = MainUtil.regionNameToCoords(file.getPath()); -// if (regPos[0] == mcaX && regPos[1] == mcaZ && file.getPath().contains(requiredPath)) { -// if (file.exists()) { -// unloadedRegion = file; -// RegionFile regionFile = entry.getValue(); -// iter.remove(); -// try { -// regionFile.c(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// break; -// } -// } -// } -// -// long now = System.currentTimeMillis(); -// if (whileLocked != null) whileLocked.run(); -// if (!load) return; -// -// { // Load the region again -// if (unloadedRegion != null && chunksUnloaded != null && unloadedRegion.exists()) { -// final boolean[][] finalChunksUnloaded = chunksUnloaded; -// TaskManager.IMP.async(() -> { -// int bx = mcaX << 5; -// int bz = mcaZ << 5; -// for (int x = 0; x < finalChunksUnloaded.length; x++) { -// boolean[] arr = finalChunksUnloaded[x]; -// if (arr != null) { -// for (int z = 0; z < arr.length; z++) { -// if (arr[z]) { -// int cx = bx + x; -// int cz = bz + z; -// SetQueue.IMP.addTask(new Runnable() { -// @Override -// public void run() { -// net.minecraft.server.v1_14_R1.Chunk chunk = provider.getChunkAt(cx, cz, null, false); -// if (chunk != null) { -// PlayerChunk pc = getPlayerChunk(nmsWorld, cx, cz); -// if (pc != null) { -// sendChunk(pc, chunk, 0); -// } -// } -// } -// }); -// } -// } -// } -// } -// }); -// } -// } -// } -// } -// }); -// return true; - } - - @Override - public boolean next(int amount, long time) { - return super.next(amount, time); - } - - @Override - public void setSkyLight(ChunkSection section, int x, int y, int z, int value) { -// section.getSkyLightArray().a(x & 15, y & 15, z & 15, value); - } - - @Override - public void setBlockLight(ChunkSection section, int x, int y, int z, int value) { -// section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value); - } - -// @Override -// public World createWorld(final WorldCreator creator) { -// final String name = creator.name(); -// ChunkGenerator generator = creator.generator(); -// final CraftServer server = (CraftServer) Bukkit.getServer(); -// final MinecraftServer console = server.getServer(); -// final File folder = new File(server.getWorldContainer(), name); -// final World world = server.getWorld(name); -// final WorldType type = WorldType.getType(creator.type().getName()); -// final boolean generateStructures = creator.generateStructures(); -// if (world != null) { -// return world; -// } -// if (folder.exists() && !folder.isDirectory()) { -// throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder"); -// } -// TaskManager.IMP.sync(new RunnableVal() { -// @Override -// public void run(Object value) { -// try { -// Field field = CraftServer.class.getDeclaredField("worlds"); -// field.setAccessible(true); -// Map existing = (Map) field.get(server); -// if (!existing.getClass().getName().contains("SynchronizedMap")) { -// field.set(server, Collections.synchronizedMap(existing)); -// } -// } catch (Throwable e) { -// e.printStackTrace(); -// } -// } -// }); -// if (generator == null) { -// generator = server.getGenerator(name); -// } -// int dimension = 10 + console.worlds.size(); -// boolean used = false; -// do { -// for (final WorldServer ws : console.worlds) { -// used = (ws.dimension == dimension); -// if (used) { -// ++dimension; -// break; -// } -// } -// } while (used); -// final boolean hardcore = false; -// final IDataManager sdm = new ServerNBTManager(server.getWorldContainer(), name, true, server.getHandle().getServer().dataConverterManager); -// WorldData worlddata = sdm.getWorldData(); -// final WorldSettings worldSettings; -// if (worlddata == null) { -// worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type); -// worldSettings.setGeneratorSettings(creator.generatorSettings()); -// worlddata = new WorldData(worldSettings, name); -// } else { -// worldSettings = null; -// } -// worlddata.checkName(name); -// final WorldServer internal = (WorldServer)new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b(); -// startSet(true); // Temporarily allow async chunk load since the world isn't added yet -// if (worldSettings != null) { -// internal.a(worldSettings); -// } -// endSet(true); -// internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle(); -// internal.tracker = new EntityTracker(internal); -// internal.addIWorldAccess(new WorldManager(console, internal)); -// internal.worldData.setDifficulty(EnumDifficulty.EASY); -// internal.setSpawnFlags(true, true); -// if (generator != null) { -// internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld())); -// } -// // Add the world -// return TaskManager.IMP.sync(new RunnableVal() { -// @Override -// public void run(World value) { -// console.worlds.add(internal); -// server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld())); -// server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld())); -// this.value = internal.getWorld(); -// } -// }); -// } - - @Override - public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) { - DataPaletteBlock dataPalette = lastSection.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - int ordinal = ((Spigot_v1_14_R1) getAdapter()).adaptToInt(ibd); - return BlockTypes.states[ordinal].getInternalId(); - } - - @Override - public BiomeType getBiome(net.minecraft.server.v1_14_R1.Chunk chunk, int x, int z) { - BiomeBase base = chunk.getBiomeIndex()[((z & 15) << 4) + (x & 15)]; - return getAdapter().adapt(CraftBlock.biomeBaseToBiome(base)); - } - - @Override - public int getOpacity(ChunkSection section, int x, int y, int z) { - DataPaletteBlock dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - pos.a(x, y, z); - return ibd.b(nmsWorld, pos); - } - - @Override - public int getBrightness(ChunkSection section, int x, int y, int z) { - DataPaletteBlock dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - return ibd.e(); - } - - @Override - public int getOpacityBrightnessPair(ChunkSection section, int x, int y, int z) { - DataPaletteBlock dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - pos.a(x, y, z); - int opacity = ibd.b(nmsWorld, pos); - int brightness = ibd.e(); - return MathMan.pair16(brightness, opacity); - } - - @Override - public void sendChunk(int x, int z, int bitMask) { - net.minecraft.server.v1_14_R1.Chunk chunk = getCachedChunk(getWorld(), x, z); - if (chunk != null) { - sendChunk(getPlayerChunk((WorldServer) chunk.getWorld(), x, z), chunk, bitMask); - } - } - - @Override - public void sendChunkUpdatePLIB(FaweChunk chunk, FawePlayer... players) { -// PlayerChunkMap playerManager = ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap(); -// ProtocolManager manager = ProtocolLibrary.getProtocolManager(); -// WirePacket packet = null; -// try { -// for (int i = 0; i < players.length; i++) { -// CraftPlayer bukkitPlayer = ((CraftPlayer) ((BukkitPlayer) players[i]).parent); -// EntityPlayer player = bukkitPlayer.getHandle(); -// -// if (playerManager.a(player, chunk.getX(), chunk.getZ())) { -// if (packet == null) { -// byte[] data; -// byte[] buffer = new byte[8192]; -// if (chunk instanceof LazyFaweChunk) { -// chunk = (FaweChunk) chunk.getChunk(); -// } -// if (chunk instanceof MCAChunk) { -// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer); -// } else { -// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer); -// } -// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data); -// } -// manager.sendWirePacket(bukkitPlayer, packet); -// } -// } -// } catch (InvocationTargetException e) { -// throw new RuntimeException(e); -// } - super.sendChunkUpdatePLIB(chunk, players); // TODO remove - } - - @Override - public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) { - try { - PlayerChunkMap playerManager = ((CraftWorld) getWorld()).getHandle().getChunkProvider().playerChunkMap; - boolean watching = false; - boolean[] watchingArr = new boolean[players.length]; - for (int i = 0; i < players.length; i++) { - EntityPlayer player = ((CraftPlayer) ((BukkitPlayer) players[i]).parent).getHandle(); - if (playerManager.visibleChunks.get(player, chunk.getX(), chunk.getZ())) { - watchingArr[i] = true; - watching = true; - } - } - if (!watching) return; - final LongAdder size = new LongAdder(); - if (chunk instanceof VisualChunk) { - size.add(((VisualChunk) chunk).size()); - } else if (chunk instanceof IntFaweChunk) { - size.add(((IntFaweChunk) chunk).getTotalCount()); - } else { - chunk.forEachQueuedBlock(new FaweChunkVisitor() { - @Override - public void run(int localX, int y, int localZ, int combined) { - size.add(1); - } - }); - } - if (size.intValue() == 0) return; - PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(); - ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(); - final PacketDataSerializer buffer = new PacketDataSerializer(byteBuf); - buffer.writeInt(chunk.getX()); - buffer.writeInt(chunk.getZ()); - buffer.d(size.intValue()); - chunk.forEachQueuedBlock(new FaweChunkVisitor() { - @Override - public void run(int localX, int y, int localZ, int combined) { - short index = (short) (localX << 12 | localZ << 8 | y); - if (combined < 16) combined = 0; - buffer.writeShort(index); - buffer.d(combined); - } - }); - packet.a(buffer); - for (int i = 0; i < players.length; i++) { - if (watchingArr[i]) ((CraftPlayer) ((BukkitPlayer) players[i]).parent).getHandle().playerConnection.sendPacket(packet); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void refreshChunk(FaweChunk fc) { - sendChunk(fc.getX(), fc.getZ(), fc.getBitMask()); - } - - public void sendPacket(int cx, int cz, Packet packet) { - PlayerChunk chunk = getPlayerChunk(nmsWorld, cx, cz); - if (chunk != null) { - for (EntityPlayer player : chunk.players) { - player.playerConnection.sendPacket(packet); - } - } - } - - private PlayerChunk getPlayerChunk(WorldServer w, int cx, int cz) { - PlayerChunkMap chunkMap = w.getChunkProvider().playerChunkMap; - PlayerChunk playerChunk = chunkMap.getChunk(cx, cz); - if (playerChunk == null) { - return null; - } - if (playerChunk.players.isEmpty()) { - return null; - } - return playerChunk; - } - - public boolean sendChunk(PlayerChunk playerChunk, net.minecraft.server.v1_14_R1.Chunk nmsChunk, int mask) { - if (playerChunk == null) { - return false; - } - if (playerChunk.e()) { - ChunkSection[] sections = nmsChunk.getSections(); - for (int layer = 0; layer < 16; layer++) { - if (sections[layer] == null && (mask & (1 << layer)) != 0) { - sections[layer] = new ChunkSection(layer << 4, nmsWorld.worldProvider.g()); - } - } - TaskManager.IMP.sync(new Supplier() { - @Override - public Object get() { - try { - int dirtyBits = fieldDirtyBits.getInt(playerChunk); - if (dirtyBits == 0) { - ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); - } - if (mask == 0) { - dirtyBits = 65535; - } else { - dirtyBits |= mask; - } - - fieldDirtyBits.set(playerChunk, dirtyBits); - fieldDirtyCount.set(playerChunk, 64); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return null; - } - }); - } -// if (mask == 0) { -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// return true; -// } -// // Send chunks -// boolean empty = false; -// ChunkSection[] sections = nmsChunk.getSections(); -// for (int i = 0; i < sections.length; i++) { -// if (sections[i] == null) { -// sections[i] = emptySection; -// empty = true; -// } -// } -// if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) { -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// mask = 255; -// } -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, mask); -// for (EntityPlayer player : playerChunk.players) { -// player.playerConnection.sendPacket(packet); -// } -// if (empty) { -// for (int i = 0; i < sections.length; i++) { -// if (sections[i] == emptySection) { -// sections[i] = null; -// } -// } -// } - return true; - } - - public boolean hasEntities(net.minecraft.server.v1_14_R1.Chunk nmsChunk) { - try { - final Collection[] entities = nmsChunk.entitySlices; - for (int i = 0; i < entities.length; i++) { - Collection slice = entities[i]; - if (slice != null && !slice.isEmpty()) { - return true; - } - } - } catch (Throwable ignore) {} - return false; - } - - @Override - public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) { - } - - @Override - public void setFullbright(ChunkSection[] sections) { - } - - @Override - public int getSkyLight(ChunkSection section, int x, int y, int z) { - - } - - @Override - public int getEmmittedLight(ChunkSection section, int x, int y, int z) { - } - - @Override - public void relightBlock(int x, int y, int z) { - } - - @Override - public void relightSky(int x, int y, int z) { - } - - @Override - public void relight(int x, int y, int z) { - } - - protected WorldServer nmsWorld; - - @Override - public World getImpWorld() { - World world = super.getImpWorld(); - if (world != null) { - this.nmsWorld = ((CraftWorld) world).getHandle(); - return super.getImpWorld(); - } else { - return null; - } - } - - public static void setCount(int tickingBlockCount, int nonEmptyBlockCount, ChunkSection section) throws NoSuchFieldException, IllegalAccessException { - fieldFluidCount.set(section, 0); // TODO FIXME - fieldTickingBlockCount.set(section, tickingBlockCount); - fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount); - } - - public int getNonEmptyBlockCount(ChunkSection section) throws IllegalAccessException { - return (int) fieldNonEmptyBlockCount.get(section); - } - - public void setPalette(ChunkSection section, DataPaletteBlock palette) throws NoSuchFieldException, IllegalAccessException { - fieldSection.set(section, palette); - } - - public static ChunkSection newChunkSection(int y2, boolean flag, int[] blocks) { - if (blocks == null) { - return new ChunkSection(y2 << 4); - } else { - ChunkSection section = new ChunkSection(y2 << 4); - int[] blockToPalette = FaweCache.BLOCK_TO_PALETTE.get(); - int[] paletteToBlock = FaweCache.PALETTE_TO_BLOCK.get(); - long[] blockstates = FaweCache.BLOCK_STATES.get(); - int[] blocksCopy = FaweCache.SECTION_BLOCKS.get(); - try { - int num_palette = 0; - int air = 0; - for (int i = 0; i < 4096; i++) { - int stateId = blocks[i]; - switch (stateId) { - case 0: - case BlockID.AIR: - case BlockID.CAVE_AIR: - case BlockID.VOID_AIR: - stateId = BlockID.AIR; - air++; - } - int ordinal = BlockState.getFromInternalId(stateId).getOrdinal(); // TODO fixme Remove all use of BlockTypes.BIT_OFFSET so that this conversion isn't necessary - int palette = blockToPalette[ordinal]; - if (palette == Integer.MAX_VALUE) { - blockToPalette[ordinal] = palette = num_palette; - paletteToBlock[num_palette] = ordinal; - num_palette++; - } - blocksCopy[i] = palette; - } - - // BlockStates - int bitsPerEntry = MathMan.log2nlz(num_palette - 1); - if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) { - bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry - } else { - bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries - } - - int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6; - if (num_palette == 1) { - for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0; - } else { - BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry); - bitArray.fromRaw(blocksCopy); - } - - // set palette & data bits - DataPaletteBlock dataPaletteBlocks = section.getBlocks(); - // private DataPalette h; - // protected DataBits a; - long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd); - DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); - DataPalette palette; -// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); - palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); - - // set palette - for (int i = 0; i < num_palette; i++) { - int ordinal = paletteToBlock[i]; - blockToPalette[ordinal] = Integer.MAX_VALUE; - BlockState state = BlockTypes.states[ordinal]; - IBlockData ibd = ((BlockMaterial_1_14) state.getMaterial()).getState(); - palette.a(ibd); - } - try { - fieldBits.set(dataPaletteBlocks, nmsBits); - fieldPalette.set(dataPaletteBlocks, palette); - fieldSize.set(dataPaletteBlocks, bitsPerEntry); - setCount(0, 4096 - air, section); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - - return section; - } catch (Throwable e){ - Arrays.fill(blockToPalette, Integer.MAX_VALUE); - throw e; - } - } - } - - protected BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0); - - @Override - public CompoundTag getTileEntity(net.minecraft.server.v1_14_R1.Chunk chunk, int x, int y, int z) { - Map tiles = chunk.getTileEntities(); - pos.c(x, y, z); - TileEntity tile = tiles.get(pos); - return tile != null ? getTag(tile) : null; - } - - public CompoundTag getTag(TileEntity tile) { - try { - NBTTagCompound tag = new NBTTagCompound(); - tile.save(tag); // readTagIntoEntity - return (CompoundTag) toNative(tag); - } catch (Exception e) { - MainUtil.handleError(e); - return null; - } - } - - @Deprecated - public boolean unloadChunk(final String world, final Chunk chunk) { - net.minecraft.server.v1_14_R1.Chunk c = ((CraftChunk) chunk).getHandle(); - c.mustNotSave = true; - if (chunk.isLoaded()) { - chunk.unload(false); - } - return true; - } - - @Override - public BukkitChunk_1_14 getFaweChunk(int x, int z) { - return new BukkitChunk_1_14(this, x, z); - } -} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java deleted file mode 100644 index 38ea785ef..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/BlockMaterial_1_14.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.boydti.fawe.bukkit.v1_14.adapter; - -import com.sk89q.util.ReflectionUtil; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import net.minecraft.server.v1_14_R1.Block; -import net.minecraft.server.v1_14_R1.EnumPistonReaction; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.ITileEntity; -import net.minecraft.server.v1_14_R1.Material; -import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData; - -public class BlockMaterial_1_14 implements BlockMaterial { - private final Block block; - private final IBlockData defaultState; - private final Material material; - private final boolean isTranslucent; - private final CraftBlockData craftBlockData; - - public BlockMaterial_1_14(Block block) { - this(block, block.getBlockData()); - } - - public BlockMaterial_1_14(Block block, IBlockData defaultState) { - this.block = block; - this.defaultState = defaultState; - this.material = defaultState.getMaterial(); - this.craftBlockData = CraftBlockData.fromData(defaultState); - this.isTranslucent = ReflectionUtil.getField(Block.class, block, "n"); - } - - public Block getBlock() { - return block; - } - - public IBlockData getState() { - return defaultState; - } - - public CraftBlockData getCraftBlockData() { - return craftBlockData; - } - - public Material getMaterial() { - return material; - } - - @Override - public boolean isAir() { - return defaultState.isAir(); - } - - @Override - public boolean isFullCube() { - return defaultState.g(); - } - - @Override - public boolean isOpaque() { - return material.f(); - } - - @Override - public boolean isPowerSource() { - return defaultState.isPowerSource(); - } - - @Override - public boolean isLiquid() { - return material.isLiquid(); - } - - @Override - public boolean isSolid() { - return material.isBuildable(); - } - - @Override - public float getHardness() { - return block.strength; - } - - @Override - public float getResistance() { - return block.getDurability(); - } - - @Override - public float getSlipperiness() { - return block.m(); - } - - @Override - public int getLightValue() { - return defaultState.e(); - } - - @Override - public int getLightOpacity() { - return isTranslucent() ? 15 : 0; - } - - @Override - public boolean isFragileWhenPushed() { - return material.getPushReaction() == EnumPistonReaction.DESTROY; - } - - @Override - public boolean isUnpushable() { - return material.getPushReaction() == EnumPistonReaction.BLOCK; - } - - @Override - public boolean isTicksRandomly() { - return block.isTicking(defaultState); - } - - @Override - public boolean isMovementBlocker() { - return material.isSolid(); - } - - @Override - public boolean isBurnable() { - return material.isBurnable(); - } - - @Override - public boolean isToolRequired() { - return !material.isAlwaysDestroyable(); - } - - @Override - public boolean isReplacedDuringPlacement() { - return material.isReplaceable(); - } - - @Override - public boolean isTranslucent() { - return isTranslucent; - } - - @Override - public boolean hasContainer() { - return block instanceof ITileEntity; - } - - @Override - public int getMapColor() { - return material.i().rgb; - } -} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java deleted file mode 100644 index a713d0965..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_14/adapter/Spigot_v1_14_R1.java +++ /dev/null @@ -1,611 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.boydti.fawe.bukkit.v1_14.adapter; - -import com.boydti.fawe.Fawe; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; -import com.sk89q.jnbt.ByteArrayTag; -import com.sk89q.jnbt.ByteTag; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.DoubleTag; -import com.sk89q.jnbt.EndTag; -import com.sk89q.jnbt.FloatTag; -import com.sk89q.jnbt.IntArrayTag; -import com.sk89q.jnbt.IntTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.LongArrayTag; -import com.sk89q.jnbt.LongTag; -import com.sk89q.jnbt.NBTConstants; -import com.sk89q.jnbt.ShortTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.blocks.TileEntityBlock; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.CachedBukkitAdapter; -import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.LazyBaseEntity; -import com.sk89q.worldedit.internal.Constants; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.registry.state.BooleanProperty; -import com.sk89q.worldedit.registry.state.DirectionalProperty; -import com.sk89q.worldedit.registry.state.EnumProperty; -import com.sk89q.worldedit.registry.state.IntegerProperty; -import com.sk89q.worldedit.registry.state.Property; -import com.sk89q.worldedit.util.Direction; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.entity.EntityType; -import com.sk89q.worldedit.world.registry.BlockMaterial; -import net.minecraft.server.v1_14_R1.Block; -import net.minecraft.server.v1_14_R1.BlockPosition; -import net.minecraft.server.v1_14_R1.BlockStateBoolean; -import net.minecraft.server.v1_14_R1.BlockStateDirection; -import net.minecraft.server.v1_14_R1.BlockStateEnum; -import net.minecraft.server.v1_14_R1.BlockStateInteger; -import net.minecraft.server.v1_14_R1.BlockStateList; -import net.minecraft.server.v1_14_R1.Chunk; -import net.minecraft.server.v1_14_R1.ChunkSection; -import net.minecraft.server.v1_14_R1.Entity; -import net.minecraft.server.v1_14_R1.EntityTypes; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.IBlockState; -import net.minecraft.server.v1_14_R1.INamable; -import net.minecraft.server.v1_14_R1.IRegistry; -import net.minecraft.server.v1_14_R1.MinecraftKey; -import net.minecraft.server.v1_14_R1.NBTBase; -import net.minecraft.server.v1_14_R1.NBTTagByte; -import net.minecraft.server.v1_14_R1.NBTTagByteArray; -import net.minecraft.server.v1_14_R1.NBTTagCompound; -import net.minecraft.server.v1_14_R1.NBTTagDouble; -import net.minecraft.server.v1_14_R1.NBTTagEnd; -import net.minecraft.server.v1_14_R1.NBTTagFloat; -import net.minecraft.server.v1_14_R1.NBTTagInt; -import net.minecraft.server.v1_14_R1.NBTTagIntArray; -import net.minecraft.server.v1_14_R1.NBTTagList; -import net.minecraft.server.v1_14_R1.NBTTagLong; -import net.minecraft.server.v1_14_R1.NBTTagLongArray; -import net.minecraft.server.v1_14_R1.NBTTagShort; -import net.minecraft.server.v1_14_R1.NBTTagString; -import net.minecraft.server.v1_14_R1.PlayerChunkMap; -import net.minecraft.server.v1_14_R1.TileEntity; -import net.minecraft.server.v1_14_R1.World; -import net.minecraft.server.v1_14_R1.WorldServer; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_14_R1.CraftServer; -import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkNotNull; - -public final class Spigot_v1_14_R1 extends CachedBukkitAdapter implements BukkitImplAdapter{ - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private final Field nbtListTagListField; - private final Method nbtCreateTagMethod; - - static { - // A simple test - if (!Bukkit.getServer().getClass().getName().endsWith("DummyServer")) CraftServer.class.cast(Bukkit.getServer()); - } - - // ------------------------------------------------------------------------ - // Code that may break between versions of Minecraft - // ------------------------------------------------------------------------ - - public Spigot_v1_14_R1() throws NoSuchFieldException, NoSuchMethodException { - // The list of tags on an NBTTagList - nbtListTagListField = NBTTagList.class.getDeclaredField("list"); - nbtListTagListField.setAccessible(true); - - // The method to create an NBTBase tag given its type ID - nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class); - nbtCreateTagMethod.setAccessible(true); - } - - public int[] idbToStateOrdinal; - - private boolean init() { - if (idbToStateOrdinal != null) return false; - idbToStateOrdinal = new int[Block.REGISTRY_ID.a()]; // size - for (int i = 0; i < idbToStateOrdinal.length; i++) { - BlockState state = BlockTypes.states[i]; - BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial(); - int id = Block.REGISTRY_ID.getId(material.getState()); - idbToStateOrdinal[id] = state.getOrdinal(); - } - return true; - } - - /** - * Read the given NBT data into the given tile entity. - * - * @param tileEntity the tile entity - * @param tag the tag - */ - private static void readTagIntoTileEntity(NBTTagCompound tag, TileEntity tileEntity) { - try { - tileEntity.load(tag); - } catch (Throwable e) { - Fawe.debug("Invalid tag " + tag + " | " + tileEntity); - } - } - - /** - * Write the tile entity's NBT data to the given tag. - * - * @param tileEntity the tile entity - * @param tag the tag - */ - private static void readTileEntityIntoTag(TileEntity tileEntity, NBTTagCompound tag) { - tileEntity.save(tag); - } - - /** - * Get the ID string of the given entity. - * - * @param entity the entity - * @return the entity ID or null if one is not known - */ - @Nullable - private static String getEntityId(Entity entity) { - MinecraftKey minecraftkey = EntityTypes.getName(entity.getBukkitEntity().getHandle().getEntityType()); - return minecraftkey == null ? null : minecraftkey.toString(); - } - - /** - * Create an entity using the given entity ID. - * - * @param id the entity ID - * @param world the world - * @return an entity or null - */ - @Nullable - private static Entity createEntityFromId(String id, World world) { - return EntityTypes.a(id).get().a(world); - } - - /** - * Write the given NBT data into the given entity. - * - * @param entity the entity - * @param tag the tag - */ - private static void readTagIntoEntity(NBTTagCompound tag, Entity entity) { - entity.f(tag); - } - - /** - * Write the entity's NBT data to the given tag. - * - * @param entity the entity - * @param tag the tag - */ - private static void readEntityIntoTag(Entity entity, NBTTagCompound tag) { - entity.save(tag); - } - - @Override - public BlockMaterial getMaterial(BlockType blockType) { - return new BlockMaterial_1_14(getBlock(blockType)); - } - - @Override - public BlockMaterial getMaterial(BlockState state) { - IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState(); - return new BlockMaterial_1_14(bs.getBlock(), bs); - } - - public Block getBlock(BlockType blockType) { - return IRegistry.BLOCK.get(new MinecraftKey(blockType.getNamespace(), blockType.getResource())); - } - - // ------------------------------------------------------------------------ - // Code that is less likely to break - // ------------------------------------------------------------------------ - - @SuppressWarnings("deprecation") - @Override - public BaseBlock getBlock(Location location) { - checkNotNull(location); - - CraftWorld craftWorld = ((CraftWorld) location.getWorld()); - int x = location.getBlockX(); - int y = location.getBlockY(); - int z = location.getBlockZ(); - - org.bukkit.block.Block bukkitBlock = location.getBlock(); - BlockState state = BukkitAdapter.adapt(bukkitBlock.getBlockData()); - if (state.getBlockType().getMaterial().hasContainer()) { - //Read the NBT data - TileEntity te = craftWorld.getHandle().getTileEntity(new BlockPosition(x, y, z)); - if (te != null) { - NBTTagCompound tag = new NBTTagCompound(); - readTileEntityIntoTag(te, tag); // Load data - return state.toBaseBlock((CompoundTag) toNative(tag)); - } - } - - return state.toBaseBlock(); - } - - @Override - public boolean isChunkInUse(org.bukkit.Chunk chunk) { - CraftChunk craftChunk = (CraftChunk) chunk; - PlayerChunkMap chunkMap = ((WorldServer) craftChunk.getHandle().getWorld()).getPlayerChunkMap(); - return chunkMap.isChunkInUse(chunk.getX(), chunk.getZ()); - } - - @Override - public boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update) { - CraftChunk craftChunk = (CraftChunk) chunk; - Chunk nmsChunk = craftChunk.getHandle(); - World nmsWorld = nmsChunk.getWorld(); - - IBlockData blockData = ((BlockMaterial_1_14) state.getMaterial()).getState(); - ChunkSection[] sections = nmsChunk.getSections(); - int y4 = y >> 4; - ChunkSection section = sections[y4]; - - IBlockData existing; - if (section == null) { - existing = ((BlockMaterial_1_14) BlockTypes.AIR.getDefaultState().getMaterial()).getState(); - } else { - existing = section.getType(x & 15, y & 15, z & 15); - } - - BlockPosition pos = new BlockPosition(x, y, z); - - nmsChunk.removeTileEntity(pos); // Force delete the old tile entity - - CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null; - if (nativeTag != null || existing instanceof TileEntityBlock) { - nmsWorld.setTypeAndData(pos, blockData, 0); - // remove tile - if (nativeTag != null) { - // We will assume that the tile entity was created for us, - // though we do not do this on the Forge version - TileEntity tileEntity = nmsWorld.getTileEntity(pos); - if (tileEntity != null) { - NBTTagCompound tag = (NBTTagCompound) fromNative(nativeTag); - tag.set("x", new NBTTagInt(x)); - tag.set("y", new NBTTagInt(y)); - tag.set("z", new NBTTagInt(z)); - readTagIntoTileEntity(tag, tileEntity); // Load data - } - } - } else { - if (existing == blockData) return true; - if (section == null) { - if (blockData.isAir()) return true; - sections[y4] = section = new ChunkSection(y4 << 4); - } - nmsChunk.setType(pos = new BlockPosition(x, y, z), blockData, false); - } - if (update) { - nmsWorld.getMinecraftWorld().notify(pos, existing, blockData, 0); - } - return true; - } - - @Override - public BaseEntity getEntity(org.bukkit.entity.Entity entity) { - checkNotNull(entity); - - CraftEntity craftEntity = ((CraftEntity) entity); - Entity mcEntity = craftEntity.getHandle(); - - String id = getEntityId(mcEntity); - - if (id != null) { - EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id); - Supplier saveTag = new Supplier() { - @Override - public CompoundTag get() { - NBTTagCompound tag = new NBTTagCompound(); - readEntityIntoTag(mcEntity, tag); - return (CompoundTag) toNative(tag); - } - }; - return new LazyBaseEntity(type, saveTag); - } else { - return null; - } - } - - @Nullable - @Override - public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) { - checkNotNull(location); - checkNotNull(state); - if (state.getType() == com.sk89q.worldedit.world.entity.EntityTypes.PLAYER) return null; - CraftWorld craftWorld = ((CraftWorld) location.getWorld()); - WorldServer worldServer = craftWorld.getHandle(); - - Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); - - if (createdEntity != null) { - CompoundTag nativeTag = state.getNbtData(); - if (nativeTag != null) { - NBTTagCompound tag = (NBTTagCompound) fromNative(nativeTag); - for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { - tag.remove(name); - } - readTagIntoEntity(tag, createdEntity); - } - - createdEntity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - - worldServer.addEntity(createdEntity, SpawnReason.CUSTOM); - return createdEntity.getBukkitEntity(); - } else { - Fawe.debug("Invalid entity " + state.getType().getId()); - return null; - } - } - - @SuppressWarnings("unchecked") - @Override - public Map> getProperties(BlockType blockType) { - Block block; - try { - block = IRegistry.BLOCK.get(new MinecraftKey(blockType.getNamespace(), blockType.getResource())); - } catch (Throwable e) { - e.printStackTrace(); - return Collections.emptyMap(); - } - if (block == null) { - logger.warn("Failed to find properties for " + blockType.getId()); - return Collections.emptyMap(); - } - Map> properties = Maps.newLinkedHashMap(); - BlockStateList blockStateList = block.getStates(); - for (IBlockState state : blockStateList.d()) { - Property property; - if (state instanceof BlockStateBoolean) { - property = new BooleanProperty(state.a(), ImmutableList.copyOf(state.d())); - } else if (state instanceof BlockStateDirection) { - property = new DirectionalProperty(state.a(), - (List) state.d().stream().map(e -> Direction.valueOf(((INamable) e).getName().toUpperCase())).collect(Collectors.toList())); - } else if (state instanceof BlockStateEnum) { - property = new EnumProperty(state.a(), - (List) state.d().stream().map(e -> ((INamable) e).getName()).collect(Collectors.toList())); - } else if (state instanceof BlockStateInteger) { - property = new IntegerProperty(state.a(), ImmutableList.copyOf(state.d())); - } else { - throw new IllegalArgumentException("WorldEdit needs an update to support " + state.getClass().getSimpleName()); - } - - properties.put(property.getName(), property); - } - return properties; - } - - /** - * Converts from a non-native NMS NBT structure to a native WorldEdit NBT - * structure. - * - * @param foreign non-native NMS NBT structure - * @return native WorldEdit NBT structure - */ - @SuppressWarnings("unchecked") - @Override - public Tag toNative(NBTBase foreign) { - if (foreign == null) { - return null; - } - if (foreign instanceof NBTTagCompound) { - Map values = new HashMap<>(); - Set foreignKeys = ((NBTTagCompound) foreign).getKeys(); // map.keySet - - for (String str : foreignKeys) { - NBTBase base = ((NBTTagCompound) foreign).get(str); - values.put(str, toNative(base)); - } - return new CompoundTag(values); - } else if (foreign instanceof NBTTagByte) { - return new ByteTag(((NBTTagByte) foreign).asByte()); - } else if (foreign instanceof NBTTagByteArray) { - return new ByteArrayTag(((NBTTagByteArray) foreign).getBytes()); // data - } else if (foreign instanceof NBTTagDouble) { - return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble - } else if (foreign instanceof NBTTagFloat) { - return new FloatTag(((NBTTagFloat) foreign).asFloat()); - } else if (foreign instanceof NBTTagInt) { - return new IntTag(((NBTTagInt) foreign).asInt()); - } else if (foreign instanceof NBTTagIntArray) { - return new IntArrayTag(((NBTTagIntArray) foreign).getInts()); // data - } else if (foreign instanceof NBTTagLongArray) { - return new LongArrayTag(((NBTTagLongArray) foreign).getLongs()); // data - } else if (foreign instanceof NBTTagList) { - try { - return toNativeList((NBTTagList) foreign); - } catch (Throwable e) { - logger.warn("Failed to convert NBTTagList", e); - return new ListTag(ByteTag.class, new ArrayList()); - } - } else if (foreign instanceof NBTTagLong) { - return new LongTag(((NBTTagLong) foreign).asLong()); - } else if (foreign instanceof NBTTagShort) { - return new ShortTag(((NBTTagShort) foreign).asShort()); - } else if (foreign instanceof NBTTagString) { - return new StringTag(foreign.asString()); - } else if (foreign instanceof NBTTagEnd) { - return new EndTag(); - } else { - throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName()); - } - } - - /** - * Convert a foreign NBT list tag into a native WorldEdit one. - * - * @param foreign the foreign tag - * @return the converted tag - * @throws NoSuchFieldException on error - * @throws SecurityException on error - * @throws IllegalArgumentException on error - * @throws IllegalAccessException on error - */ - public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - List values = new ArrayList<>(); - int type = foreign.getTypeId(); - - List foreignList; - foreignList = (List) nbtListTagListField.get(foreign); - for (int i = 0; i < foreign.size(); i++) { - NBTBase element = (NBTBase) foreignList.get(i); - values.add(toNative(element)); // List elements shouldn't have names - } - - Class cls = NBTConstants.getClassFromType(type); - return new ListTag(cls, values); - } - - /** - * Converts a WorldEdit-native NBT structure to a NMS structure. - * - * @param foreign structure to convert - * @return non-native structure - */ - @Override - public NBTBase fromNative(Tag foreign) { - if (foreign == null) { - return null; - } - if (foreign instanceof CompoundTag) { - NBTTagCompound tag = new NBTTagCompound(); - for (Map.Entry entry : ((CompoundTag) foreign) - .getValue().entrySet()) { - tag.set(entry.getKey(), fromNative(entry.getValue())); - } - return tag; - } else if (foreign instanceof ByteTag) { - return new NBTTagByte(((ByteTag) foreign).getValue()); - } else if (foreign instanceof ByteArrayTag) { - return new NBTTagByteArray(((ByteArrayTag) foreign).getValue()); - } else if (foreign instanceof DoubleTag) { - return new NBTTagDouble(((DoubleTag) foreign).getValue()); - } else if (foreign instanceof FloatTag) { - return new NBTTagFloat(((FloatTag) foreign).getValue()); - } else if (foreign instanceof IntTag) { - return new NBTTagInt(((IntTag) foreign).getValue()); - } else if (foreign instanceof IntArrayTag) { - return new NBTTagIntArray(((IntArrayTag) foreign).getValue()); - } else if (foreign instanceof LongArrayTag) { - return new NBTTagLongArray(((LongArrayTag) foreign).getValue()); - } else if (foreign instanceof ListTag) { - NBTTagList tag = new NBTTagList(); - ListTag foreignList = (ListTag) foreign; - for (Tag t : foreignList.getValue()) { - tag.add(fromNative(t)); - } - return tag; - } else if (foreign instanceof LongTag) { - return new NBTTagLong(((LongTag) foreign).getValue()); - } else if (foreign instanceof ShortTag) { - return new NBTTagShort(((ShortTag) foreign).getValue()); - } else if (foreign instanceof StringTag) { - return new NBTTagString(((StringTag) foreign).getValue()); - } else if (foreign instanceof EndTag) { - try { - return (NBTBase) nbtCreateTagMethod.invoke(null, (byte) 0); - } catch (Exception e) { - return null; - } - } else { - throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName()); - } - } - - @Override - public BlockState adapt(BlockData blockData) { - CraftBlockData cbd = ((CraftBlockData) blockData); - IBlockData ibd = cbd.getState(); - return adapt(ibd); - } - - public BlockState adapt(IBlockData ibd) { - return BlockTypes.states[adaptToInt(ibd)]; - } - - public int adaptToInt(IBlockData ibd) { - try { - int id = Block.REGISTRY_ID.getId(ibd); - return idbToStateOrdinal[id]; - } catch (NullPointerException e) { - if (init()) return adaptToInt(ibd); - throw e; - } - } - - @Override - public BlockData adapt(BlockStateHolder state) { - BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial(); - return material.getCraftBlockData(); - } - - @Override - public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) { - // TODO Auto-generated method stub - - } - - @Override - public void notifyAndLightBlock(Location position, BlockState previousType) { - this.setBlock(position.getChunk(), position.getBlockX(), position.getBlockY(), position.getBlockZ(), previousType, true); - } - - @Override - public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) { - return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight); - } - - @Override - public void sendFakeOP(Player player) { - // TODO Auto-generated method stub - - } -} From bd91c2a7487dbeab885d2f16b9c2b7093b6aab42 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 25 Apr 2019 20:09:43 +0200 Subject: [PATCH 04/94] Revert "Add pre5" This reverts commit c4f72983fcd32cebdf2127109a20ff704eb32673. --- worldedit-bukkit/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 42df6e565..3d5e99d23 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -10,7 +10,7 @@ repositories { dependencies { compile project(':worldedit-core') - compile 'org.bukkit:craftbukkit-1.14:pre5' + compile 'net.milkbowl.vault:VaultAPI:1.7' compile 'com.sk89q:dummypermscompat:1.10' compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT' From 7a1cc5845ce29c58fa45e2290f6b643880b90dbf Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 27 Apr 2019 16:16:04 +0200 Subject: [PATCH 05/94] Update ISSUE_TEMPLATE.md --- ISSUE_TEMPLATE.md | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index ff84251a8..c0b09d09b 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,19 +1,29 @@ -# Bug report for FastAsyncWorldEdit 1.13.x - +# Bug report for FastAsyncWorldEdit 1.13.2 + + - -**Debug paste link**: - + +**[REQUIRED] FastAsyncWorldEdit Version Number:** + -**Description of the problem:** - +**[REQUIRED] Spigot/Paper Version Number:** + + +**Links to config.yml and config-legacy.yml file:** + + +**[REQUIRED] Description of the problem:** + + +**Plugins being used on the server:** + **How to replicate**: **Checklist**: -- [] I included a `/fawe debugpaste` link -- [] I made sure there aren't duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [] I made sure I am using an up-to-date version of [FAWE for 1.13.x](https://ci.athion.net/job/FAWE-1.13/) +- [] I included all information required in the sections above +- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) +- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) - [] I made sure the bug/error is not caused by any other plugin From 686c71d965f9f507aca9bf9f662f8560ff0996ef Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 27 Apr 2019 20:34:56 +0200 Subject: [PATCH 06/94] Move around some debugs --- .../java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java | 5 +++-- .../src/main/java/com/sk89q/worldedit/EditSession.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java index 3cc50d56e..7b9d2bb23 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java @@ -6,6 +6,7 @@ import com.boydti.fawe.bukkit.BukkitPlayer; import com.boydti.fawe.bukkit.adapter.v1_13_1.BlockMaterial_1_13; import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2; import com.boydti.fawe.bukkit.v0.BukkitQueue_0; +import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.example.IntFaweChunk; import com.boydti.fawe.jnbt.anvil.BitArray4096; @@ -193,8 +194,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0 Date: Sat, 27 Apr 2019 21:28:46 +0200 Subject: [PATCH 07/94] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c8494060a..e0087776d 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,11 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons ## Downloads ### 1.13+ -* [Download](https://incendo.org/download/) -* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/) +* [Download](https://empcraft.com/fawe/download/) +* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) ### < 1.12.2 -* [Download](https://incendo.org/download/) +* [Download](https://empcraft.com/fawe/download/?bukkit) * [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit/) * [Repository](https://github.com/boy0001/FastAsyncWorldedit) From c64b59da2f82843540230b8638781e7ed78d017f Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 28 Apr 2019 11:34:07 +0200 Subject: [PATCH 08/94] Fix build number in version --- worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java | 2 +- .../java/com/sk89q/worldedit/command/WorldEditCommands.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java index cea5c6ac5..6216f7cc5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java @@ -13,7 +13,7 @@ public class FaweVersion { public FaweVersion(String version, String commit, String date) { String[] split = version.substring(version.indexOf('=') + 1).split("\\."); - this.build = Integer.parseInt(split[1]); + this.build = Integer.parseInt(split[2]); this.hash = Integer.parseInt(commit.substring(commit.indexOf('=') + 1), 16); String[] split1 = date.substring(date.indexOf('=') + 1).split("\\."); this.year = Integer.parseInt(split1[0]); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 6ec63bea9..c1de1d5e0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -64,7 +64,7 @@ public class WorldEditCommands { public void version(Actor actor) throws WorldEditException { FaweVersion fVer = Fawe.get().getVersion(); String fVerStr = fVer == null ? "unknown" : fVer.year + "." + fVer.month + "." + fVer.day + "-" + Integer.toHexString(fVer.hash) + "-" + fVer.build; - actor.print(BBC.getPrefix() + "FAWE " + fVerStr + " by Empire92"); + actor.print(BBC.getPrefix() + "FastAsyncWorldEdit 1.13-" + fVerStr + " by Empire92"); if (fVer != null) { actor.printDebug("------------------------------------"); FaweVersion version = Fawe.get().getVersion(); From 1b03d14f919d69223b5db1614253ab28d4f611f9 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 28 Apr 2019 11:38:30 +0200 Subject: [PATCH 09/94] Update ISSUE_TEMPLATE.md --- ISSUE_TEMPLATE.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index c0b09d09b..070ba585a 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -4,15 +4,16 @@ **[REQUIRED] FastAsyncWorldEdit Version Number:** - + **[REQUIRED] Spigot/Paper Version Number:** - + **Links to config.yml and config-legacy.yml file:** **[REQUIRED] Description of the problem:** + **Plugins being used on the server:** From bf684d478e0f782ce11dfd68c6c2ab9ff8b18e2d Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 28 Apr 2019 20:11:05 +0200 Subject: [PATCH 10/94] Remove hashtag preventing wrong issue references --- .../java/com/sk89q/worldedit/command/WorldEditCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index c1de1d5e0..79dce0dc1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -71,7 +71,7 @@ public class WorldEditCommands { Date date = new GregorianCalendar(2000 + version.year, version.month - 1, version.day).getTime(); actor.printDebug(" - DATE: " + date.toLocaleString()); actor.printDebug(" - COMMIT: " + Integer.toHexString(version.hash)); - actor.printDebug(" - BUILD: #" + version.build); + actor.printDebug(" - BUILD: " + version.build); actor.printDebug(" - PLATFORM: " + Settings.IMP.PLATFORM); actor.printDebug("------------------------------------"); } From 3ffa54af84f0ee68135a35736f6e51ff2631f1b8 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 6 Apr 2019 13:22:20 -0400 Subject: [PATCH 11/94] Fix TrueZip region stores. I think. Someone tell me if this breaks their setup with truezip, but it works for me now and didn't before. I'm assuming people using .zip just used the normal zip store anyway. (cherry picked from commit dcfb769d96bc4524e098e7da11811d404d41c93c) --- .../worldedit/world/storage/TrueZipMcRegionChunkStore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java index a22818c77..8d7c03e93 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java @@ -93,11 +93,11 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { } else { Pattern pattern = Pattern.compile(".*\\.mc[ra]$"); // World pattern - Pattern worldPattern = Pattern.compile(worldName + "\\$"); + Pattern worldPattern = Pattern.compile(worldName + "[\\\\/].*"); for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { ZipEntry testEntry = e.nextElement(); // Check for world - if (worldPattern.matcher(worldName).matches()) { + if (worldPattern.matcher(testEntry.getName()).matches()) { // Check for file if (pattern.matcher(testEntry.getName()).matches()) { folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); From ea07b540b1785aee60f4a9816a587cb538fe3060 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 29 Apr 2019 18:13:58 +0200 Subject: [PATCH 12/94] Minor amendments --- .../java/com/sk89q/worldedit/command/WorldEditCommands.java | 2 +- .../main/java/com/sk89q/worldedit/regions/CuboidRegion.java | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 79dce0dc1..d640b01e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -102,7 +102,7 @@ public class WorldEditCommands { we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration())); Fawe.get().setupConfigs(); CommandManager.getInstance().register(we.getPlatformManager().queryCapability(Capability.USER_COMMANDS)); - actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")"); + actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and " + Fawe.get().getVersion() + ""); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 5d6da1301..54e08aa7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -39,9 +39,6 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Set; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - /** * An axis-aligned cuboid. It can be defined using two corners of the cuboid. */ From e2c94543993c9b8ca10ae33d0e7667609d7cb0f1 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 30 Apr 2019 11:56:30 +0100 Subject: [PATCH 13/94] Don't print stack trace, print another few lines of debug for using paper Closes #133 bye bye --- .../src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 793f2ef1e..4566813b9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -138,7 +138,12 @@ public class FaweBukkit implements IFawe, Listener { Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent"); Bukkit.getPluginManager().registerEvents(new AsyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin); } catch (Throwable ignore) { - ignore.printStackTrace(); + debug("====== USE PAPER ======"); + debug("DOWNLOAD: https://papermc.io/ci/job/Paper-1.13/"); + debug("GUIDE: https://www.spigotmc.org/threads/21726/"); + debug(" - This is only a recommendation"); + debug(" - Allows the use of Async Tab Completetion as provided by Paper"); + debug("=============================="); Bukkit.getPluginManager().registerEvents(new SyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin); } }); From d9914d7f0abc1148b79fd757a895eae3b4559aaa Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 1 May 2019 21:42:18 +0200 Subject: [PATCH 14/94] Re-add paste service And move issue template --- ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md | 0 .../src/main/java/com/boydti/fawe/util/IncendoPaster.java | 4 ++-- .../java/com/sk89q/worldedit/command/WorldEditCommands.java | 2 +- .../java/com/sk89q/worldedit/util/paste/IncendoPaste.java | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) rename ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md (100%) diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 100% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java index 58fb8fa6b..86a415298 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java @@ -23,7 +23,7 @@ public final class IncendoPaster { /** * Upload service URL */ - public static final String UPLOAD_PATH = "https://incendo.org/paste/upload"; + public static final String UPLOAD_PATH = "https://athion.net/ISPaster/paste/upload"; /** * Valid paste applications */ @@ -238,7 +238,7 @@ public final class IncendoPaster { if (jsonObject.has("created")) { final String pasteId = jsonObject.get("paste_id").getAsString(); - return String.format("https://incendo.org/paste/view/%s", pasteId); + return String.format("https://athion.net/ISPaster/paste/view/%s", pasteId); } else { throw new IOException(String.format("Failed to upload files: %s", jsonObject.get("response").getAsString())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index d640b01e2..05a856f43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -108,7 +108,7 @@ public class WorldEditCommands { @Command( aliases = {"debugpaste"}, usage = "", - desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://incendo.org", + desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste", min = 0, max = 0 ) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java index 634f77eb5..38c460764 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java @@ -25,7 +25,7 @@ public final class IncendoPaste implements Paster{ /** * Upload service URL */ - public static final String UPLOAD_PATH = "https://incendo.org/paste/upload"; + public static final String UPLOAD_PATH = "https://athion.net/ISPaster/paste/upload"; /** * Valid paste applications */ @@ -242,6 +242,7 @@ public final class IncendoPaste implements Paster{ } incendoPaster.addFile(new PasteFile("config.yml", readFile(new File(Fawe.imp().getDirectory(), "config.yml")))); + incendoPaster.addFile(new PasteFile("config-legacy.yml", readFile(new File(Fawe.imp().getDirectory(), "config-legacy.yml")))); incendoPaster.addFile(new PasteFile("message.yml", readFile(new File(Fawe.imp().getDirectory(), "message.yml")))); incendoPaster.addFile(new PasteFile("commands.yml", readFile(new File(Fawe.imp().getDirectory(), "commands.yml")))); @@ -255,7 +256,7 @@ public final class IncendoPaste implements Paster{ if (jsonObject.has("created")) { final String pasteId = jsonObject.get("paste_id").getAsString(); - return String.format("https://incendo.org/paste/view/%s", pasteId); + return String.format("https://athion.net/ISPaster/paste/view/%s", pasteId); } else { throw new IOException(String.format("Failed to upload files: %s", jsonObject.get("response").getAsString())); From 0911202260a9c12898078eea21692f00b85ba92d Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 2 May 2019 19:28:09 +0200 Subject: [PATCH 15/94] Generate javadocs --- .gitignore | 3 ++- build.gradle | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index f632b0d1f..18c977f27 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ lib/ *.bat worldedit-bukkit/src/main/java/ignore/* todo.txt -mvn/* \ No newline at end of file +mvn/* +docs/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index adbe1f09e..2d42f2d6a 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,6 @@ plugins { } apply plugin: 'java' -clean { delete "target" } - def splashFile = new File('splash.txt') if (splashFile.exists()) { @@ -58,23 +56,24 @@ ext { } } -if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion - version = "unknown" -} else { - version = String.format("%s.%s", rootVersion, buildNumber) -} +version = String.format("%s.%s", rootVersion, buildNumber) + description = rootProject.name subprojects { apply plugin: 'java' apply plugin: 'maven' apply plugin: 'com.github.johnrengelman.shadow' - // Enable this requires putting license header files in many, many FAWE files + //Enable this requires putting license header files in many, many FAWE files //apply plugin: 'net.minecrell.licenser' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + clean.doFirst { + delete "../target" + } + compileJava { options.compilerArgs += ["-parameters"] } repositories { @@ -97,23 +96,6 @@ subprojects { maven {url "http://ci.emc.gs/nexus/content/groups/aikar/" } } - if (JavaVersion.current().isJava8Compatible()) { - // Java 8 turns on doclint which we fail - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - artifacts { - archives jar - archives javadocJar - } - if (!(name.equals('worldedit-forge') || name.equals('worldedit-sponge'))) { task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' @@ -146,3 +128,21 @@ subprojects { // include '**/*.java' //} } +task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { + destinationDir = file("./docs/javadoc") + title = "$project.name $version API" + options.author true + options.links 'http://docs.spring.io/spring/docs/4.3.x/javadoc-api/', 'http://docs.oracle.com/javase/8/docs/api/', 'http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/', 'http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/' + options.addStringOption('Xdoclint:none', '-quiet') + + delete "./docs" + + subprojects.each { proj -> + proj.tasks.withType(Javadoc).each { javadocTask -> + source += javadocTask.source + classpath += javadocTask.classpath + excludes += javadocTask.excludes + includes += javadocTask.includes + } + } +} From 317742e3f0125466bd8137567a4ff0acec0c9976 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 2 May 2019 19:52:07 +0200 Subject: [PATCH 16/94] Update links --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e0087776d..08da15539 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,13 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons ### 1.13+ * [Download](https://empcraft.com/fawe/download/) * [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) +* [JavaDoc](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/javadoc/) ### < 1.12.2 * [Download](https://empcraft.com/fawe/download/?bukkit) * [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit/) * [Repository](https://github.com/boy0001/FastAsyncWorldedit) +* [JavaDoc](https://ci.athion.net/job/FastAsyncWorldEdit/javadoc/) ## Building From 2be8d87d5aa088b2222c0b50f9487fd82c48911d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 5 May 2019 03:59:25 +1000 Subject: [PATCH 17/94] Fix mask parsing not using factory --- .../extension/factory/parser/mask/DefaultMaskParser.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java index 09963a826..93127b01a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java @@ -171,8 +171,6 @@ public class DefaultMaskParser extends FaweParser { { try { builder.addRegex(full); - } catch (SuggestInputParseException rethrow) { - throw rethrow; } catch (InputParseException ignore) {} } if (mask == null) { From e2513e2c08213dfedbd52792c317d020bc139432 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 5 May 2019 20:43:56 +0200 Subject: [PATCH 18/94] Fix paste service --- .../src/main/java/com/boydti/fawe/util/IncendoPaster.java | 4 ++-- .../java/com/sk89q/worldedit/command/WorldEditCommands.java | 2 +- .../java/com/sk89q/worldedit/util/paste/IncendoPaste.java | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java index 58fb8fa6b..86a415298 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java @@ -23,7 +23,7 @@ public final class IncendoPaster { /** * Upload service URL */ - public static final String UPLOAD_PATH = "https://incendo.org/paste/upload"; + public static final String UPLOAD_PATH = "https://athion.net/ISPaster/paste/upload"; /** * Valid paste applications */ @@ -238,7 +238,7 @@ public final class IncendoPaster { if (jsonObject.has("created")) { final String pasteId = jsonObject.get("paste_id").getAsString(); - return String.format("https://incendo.org/paste/view/%s", pasteId); + return String.format("https://athion.net/ISPaster/paste/view/%s", pasteId); } else { throw new IOException(String.format("Failed to upload files: %s", jsonObject.get("response").getAsString())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index d640b01e2..05a856f43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -108,7 +108,7 @@ public class WorldEditCommands { @Command( aliases = {"debugpaste"}, usage = "", - desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://incendo.org", + desc = "Upload latest.log, config.yml, message.yml and your commands.yml to https://athion.net/ISPaster/paste", min = 0, max = 0 ) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java index 634f77eb5..38c460764 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java @@ -25,7 +25,7 @@ public final class IncendoPaste implements Paster{ /** * Upload service URL */ - public static final String UPLOAD_PATH = "https://incendo.org/paste/upload"; + public static final String UPLOAD_PATH = "https://athion.net/ISPaster/paste/upload"; /** * Valid paste applications */ @@ -242,6 +242,7 @@ public final class IncendoPaste implements Paster{ } incendoPaster.addFile(new PasteFile("config.yml", readFile(new File(Fawe.imp().getDirectory(), "config.yml")))); + incendoPaster.addFile(new PasteFile("config-legacy.yml", readFile(new File(Fawe.imp().getDirectory(), "config-legacy.yml")))); incendoPaster.addFile(new PasteFile("message.yml", readFile(new File(Fawe.imp().getDirectory(), "message.yml")))); incendoPaster.addFile(new PasteFile("commands.yml", readFile(new File(Fawe.imp().getDirectory(), "commands.yml")))); @@ -255,7 +256,7 @@ public final class IncendoPaste implements Paster{ if (jsonObject.has("created")) { final String pasteId = jsonObject.get("paste_id").getAsString(); - return String.format("https://incendo.org/paste/view/%s", pasteId); + return String.format("https://athion.net/ISPaster/paste/view/%s", pasteId); } else { throw new IOException(String.format("Failed to upload files: %s", jsonObject.get("response").getAsString())); From 55b02e1b1f1184f61b2b00e506e007c06d0a935f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 6 May 2019 15:58:55 +1000 Subject: [PATCH 19/94] Implement FuzzyBlockState --- .../worldedit/world/block/BlockState.java | 5 +- .../worldedit/world/block/BlockType.java | 10 +- .../world/block/FuzzyBlockState.java | 175 ++++++++++++++++++ 3 files changed, 182 insertions(+), 8 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 71c6b7ad0..2307d19c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -304,7 +304,10 @@ public class BlockState implements BlockStateHolder, FawePattern { @Override public boolean equalsFuzzy(BlockStateHolder o) { - return o.getOrdinal() == this.getOrdinal(); + if (o.getClass() == BlockState.class) { + return o.getOrdinal() == this.getOrdinal(); + } + return o.equalsFuzzy(this); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index 7a5f89f73..2f2c7c50b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -183,13 +183,9 @@ public class BlockType implements FawePattern { return this.settings.defaultState; } -// public FuzzyBlockState getFuzzyMatcher() { // -// return new FuzzyBlockState(this); -// } -// -// public FuzzyBlockState getFuzzyMatcher() { // -// return updateField(emptyFuzzy, () -> new FuzzyBlockState(this)); -// } + public FuzzyBlockState getFuzzyMatcher() { // + return new FuzzyBlockState(this); + } /** * Slow diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java new file mode 100644 index 000000000..28a8b7bb6 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java @@ -0,0 +1,175 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.world.block; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.collect.Maps; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.registry.state.PropertyKey; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * A Fuzzy BlockState. Used for partial matching. + * + * Immutable, construct with {@link FuzzyBlockState.Builder}. + */ +public class FuzzyBlockState extends BlockState { + + private final Map state; + + FuzzyBlockState(BlockType blockType) { + this(blockType, null); + } + + private FuzzyBlockState(BlockType blockType, Map, Object> values) { + super(blockType, blockType.getDefaultState().getInternalId(), blockType.getDefaultState().getOrdinal()); + if (values == null || values.isEmpty()) { + state = Collections.emptyMap(); + } else { + state = new HashMap<>(values.size()); + for (Map.Entry, Object> entry : values.entrySet()) { + state.put(entry.getKey().getKey(), entry.getValue()); + } + } + } + + /** + * Gets a full BlockState from this fuzzy one, filling in + * properties with default values where necessary. + * + * @return The full BlockState + */ + public BlockState getFullState() { + BlockState state = getBlockType().getDefaultState(); + for (Map.Entry, Object> entry : getStates().entrySet()) { + @SuppressWarnings("unchecked") + Property objKey = (Property) entry.getKey(); + state = state.with(objKey, entry.getValue()); + } + return state; + } + + @Override + public boolean equalsFuzzy(BlockStateHolder o) { + if (!getBlockType().equals(o.getBlockType())) { + return false; + } + if (!state.isEmpty()) { + for (Map.Entry entry : state.entrySet()) { + if (!Objects.equals(o.getState(entry.getKey()), entry.getValue())) { + return false; + } + } + } + return true; + } + + @Override + public BlockState toImmutableState() { + return getFullState(); + } + + /** + * Gets an instance of a builder. + * + * @return The builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Builder for FuzzyBlockState + */ + public static class Builder { + private BlockType type; + private Map, Object> values = new HashMap<>(); + + /** + * The type of the Fuzzy BlockState + * + * @param type The type + * @return The builder, for chaining + */ + public Builder type(BlockType type) { + checkNotNull(type); + this.type = type; + return this; + } + + /** + * The type of the Fuzzy BlockState + * + * @param state The state + * @return The builder, for chaining + */ + public Builder type(BlockState state) { + checkNotNull(state); + this.type = state.getBlockType(); + return this; + } + + /** + * Adds a property to the fuzzy BlockState + * + * @param property The property + * @param value The value + * @param The property type + * @return The builder, for chaining + */ + public Builder withProperty(Property property, V value) { + checkNotNull(property); + checkNotNull(value); + checkNotNull(type, "The type must be set before the properties!"); + type.getProperty(property.getName()); // Verify the property is valid for this type + values.put(property, value); + return this; + } + + /** + * Builds a FuzzyBlockState from this builder. + * + * @return The fuzzy BlockState + */ + public FuzzyBlockState build() { + checkNotNull(type); + if (values.isEmpty()) { + return type.getFuzzyMatcher(); + } + return new FuzzyBlockState(type, values); + } + + /** + * Resets the builder. + * + * @return The builder, for chaining + */ + public Builder reset() { + this.type = null; + this.values.clear(); + return this; + } + } +} \ No newline at end of file From 113aeb1689d954e59d44de1bf142cb1b5b448f2e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 7 May 2019 16:40:37 +1000 Subject: [PATCH 20/94] Use fuzzy blocks in default block parser --- .../factory/parser/DefaultBlockParser.java | 23 +++++++++++++- .../parser/mask/DefaultMaskParser.java | 2 +- .../world/block/FuzzyBlockState.java | 31 ++++++++++++------- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 82f9792c6..09d4ce435 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -47,6 +47,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.SlottableBlockBag; import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; @@ -54,9 +55,11 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.registry.LegacyMapper; import java.util.Arrays; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -249,10 +252,28 @@ public class DefaultBlockParser extends InputParser { throw new NoMatchException(BBC.getPrefix() + "Does not match a valid block type: '" + input + "'"); } } -// if (nbt == null) nbt = state.getNbtData(); + if (nbt == null) nbt = state.getNbtData(); if (stateString != null) { state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state); + if (context.isPreferringWildcard()) { + if (stateString.isEmpty()) { + state = new FuzzyBlockState(state); + } else { + BlockType type = state.getBlockType(); + FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder(); + fuzzyBuilder.type(type); + String[] entries = stateString.split(","); + for (String entry : entries) { + String[] split = entry.split("="); + String key = split[0]; + String val = split[1]; + Property prop = type.getProperty(key); + fuzzyBuilder.withProperty(prop, prop.getValueFor(val)); + } + state = fuzzyBuilder.build(); + } + } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java index 93127b01a..e24602ee9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/DefaultMaskParser.java @@ -174,7 +174,7 @@ public class DefaultMaskParser extends FaweParser { } catch (InputParseException ignore) {} } if (mask == null) { - context.setPreferringWildcard(true); + context.setPreferringWildcard(false); context.setRestricted(false); BlockStateHolder block = worldEdit.getBlockFactory().parseFromInput(full, context); builder.add(block); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java index 28a8b7bb6..230b479ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java @@ -37,20 +37,24 @@ import java.util.Objects; */ public class FuzzyBlockState extends BlockState { - private final Map state; + private final Map props; - FuzzyBlockState(BlockType blockType) { - this(blockType, null); + public FuzzyBlockState(BlockType blockType) { + this(blockType.getDefaultState(), null); } - private FuzzyBlockState(BlockType blockType, Map, Object> values) { - super(blockType, blockType.getDefaultState().getInternalId(), blockType.getDefaultState().getOrdinal()); + public FuzzyBlockState(BlockState state) { + this(state, null); + } + + private FuzzyBlockState(BlockState state, Map, Object> values) { + super(state.getBlockType(), state.getInternalId(), state.getOrdinal()); if (values == null || values.isEmpty()) { - state = Collections.emptyMap(); + props = Collections.emptyMap(); } else { - state = new HashMap<>(values.size()); + props = new HashMap<>(values.size()); for (Map.Entry, Object> entry : values.entrySet()) { - state.put(entry.getKey().getKey(), entry.getValue()); + props.put(entry.getKey().getKey(), entry.getValue()); } } } @@ -76,8 +80,8 @@ public class FuzzyBlockState extends BlockState { if (!getBlockType().equals(o.getBlockType())) { return false; } - if (!state.isEmpty()) { - for (Map.Entry entry : state.entrySet()) { + if (!props.isEmpty()) { + for (Map.Entry entry : props.entrySet()) { if (!Objects.equals(o.getState(entry.getKey()), entry.getValue())) { return false; } @@ -86,6 +90,11 @@ public class FuzzyBlockState extends BlockState { return true; } + @Override + public BaseBlock toBaseBlock() { + return new BaseBlock(); + } + @Override public BlockState toImmutableState() { return getFullState(); @@ -158,7 +167,7 @@ public class FuzzyBlockState extends BlockState { if (values.isEmpty()) { return type.getFuzzyMatcher(); } - return new FuzzyBlockState(type, values); + return new FuzzyBlockState(type.getDefaultState(), values); } /** From 8d68da09a3a99377aebc61c4e7d27ce7c284463e Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Sun, 5 May 2019 01:37:11 -0700 Subject: [PATCH 21/94] Minor versioning changes --- build.gradle | 34 +++++-------------- .../java/com/boydti/fawe/FaweVersion.java | 9 +++-- .../worldedit/command/WorldEditCommands.java | 10 +++--- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/build.gradle b/build.gradle index fae84bd06..43b53a31e 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,6 @@ plugins { } apply plugin: 'java' -clean { delete "target" } - def splashFile = new File('splash.txt') if (splashFile.exists()) { @@ -58,23 +56,24 @@ ext { } } -if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion - version = "unknown" -} else { - version = String.format("%s.%s", rootVersion, buildNumber) -} +version = String.format("%s.%s", rootVersion, buildNumber) + description = rootProject.name subprojects { apply plugin: 'java' apply plugin: 'maven' apply plugin: 'com.github.johnrengelman.shadow' - // Enable this requires putting license header files in many, many FAWE files + //Enable this requires putting license header files in many, many FAWE files //apply plugin: 'net.minecrell.licenser' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + clean.doFirst { + delete "../target" + } + compileJava { options.compilerArgs += ["-parameters"] } repositories { @@ -96,23 +95,6 @@ subprojects { maven {url "http://ci.emc.gs/nexus/content/groups/aikar/" } } - if (JavaVersion.current().isJava8Compatible()) { - // Java 8 turns on doclint which we fail - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - artifacts { - archives jar - archives javadocJar - } - if (!(name.equals('worldedit-forge') || name.equals('worldedit-sponge'))) { task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' @@ -144,4 +126,4 @@ subprojects { // header = rootProject.file("HEADER.txt") // include '**/*.java' //} -} +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java index 6216f7cc5..ae9c913f3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweVersion.java @@ -30,9 +30,12 @@ public class FaweVersion { } } - @Override - public String toString() { - return "FastAsyncWorldEdit-" + year + "." + month + "." + day + "-" + Integer.toHexString(hash) + "-" + build; + @Override public String toString() { + if (hash == 0 && build == 0) { + return "FastAsyncWorldEdit-1.13-NoVer-SNAPSHOT"; + } else { + return "FastAsyncWorldEdit-1.13" + build; + } } public boolean isNewer(FaweVersion other) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 05a856f43..64026f536 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -63,8 +63,8 @@ public class WorldEditCommands { ) public void version(Actor actor) throws WorldEditException { FaweVersion fVer = Fawe.get().getVersion(); - String fVerStr = fVer == null ? "unknown" : fVer.year + "." + fVer.month + "." + fVer.day + "-" + Integer.toHexString(fVer.hash) + "-" + fVer.build; - actor.print(BBC.getPrefix() + "FastAsyncWorldEdit 1.13-" + fVerStr + " by Empire92"); + String fVerStr = fVer == null ? "unknown" : "-" + fVer.build; + actor.print(BBC.getPrefix() + "FastAsyncWorldEdit-1.13" + fVerStr + " by Empire92"); if (fVer != null) { actor.printDebug("------------------------------------"); FaweVersion version = Fawe.get().getVersion(); @@ -78,7 +78,7 @@ public class WorldEditCommands { PlatformManager pm = we.getPlatformManager(); actor.printDebug("Platforms:"); for (Platform platform : pm.getPlatforms()) { - actor.printDebug(String.format(" - %s (%s)", platform.getPlatformName(), platform.getVersion())); + actor.printDebug(String.format(" - %s", platform.getPlatformName())); } actor.printDebug("Capabilities:"); for (Capability capability : Capability.values()) { @@ -92,7 +92,7 @@ public class WorldEditCommands { @Command( aliases = {"reload"}, usage = "", - desc = "Reload configuration", + desc = "Reload configuration and translations", min = 0, max = 0 ) @@ -102,7 +102,7 @@ public class WorldEditCommands { we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration())); Fawe.get().setupConfigs(); CommandManager.getInstance().register(we.getPlatformManager().queryCapability(Capability.USER_COMMANDS)); - actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and " + Fawe.get().getVersion() + ""); + actor.print(BBC.getPrefix() + "Reloaded FastAsyncWorldEdit configuration and translation files"); } @Command( From dd0bec89135fede4966d53180256bc346d677b54 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 13 May 2019 00:37:18 +1000 Subject: [PATCH 22/94] Fix //none removing arbitrary nbt --- .../src/main/java/com/boydti/fawe/util/BrushCache.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java index 4adbcdc35..7c885af07 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java @@ -77,8 +77,11 @@ public final class BrushCache { Map map; if (nbt == null) { if (tool == null) { - item.setNbtData(null); - return tool; + Map raw = nbt.getRaw(); + if (raw.remove("weBrushJson") != null && raw.isEmpty()) { + item.setNbtData(null); + } + return null; } nbt = new CompoundTag(map = new HashMap<>()); } else { From e4c1ba3edf98a6ee19d8c36159b814808961c77d Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 19 May 2019 20:55:45 +0200 Subject: [PATCH 23/94] Revert "Fix //none removing arbitrary nbt" This reverts dd0bec89135fede4966d53180256bc346d677b54. --- .../src/main/java/com/boydti/fawe/util/BrushCache.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java index 7c885af07..4adbcdc35 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java @@ -77,11 +77,8 @@ public final class BrushCache { Map map; if (nbt == null) { if (tool == null) { - Map raw = nbt.getRaw(); - if (raw.remove("weBrushJson") != null && raw.isEmpty()) { - item.setNbtData(null); - } - return null; + item.setNbtData(null); + return tool; } nbt = new CompoundTag(map = new HashMap<>()); } else { From 6b0fcc87127f5c1ad4659b8ebc7eb688a1bfd98c Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 22 May 2019 14:40:56 -0400 Subject: [PATCH 24/94] Removed some null checks and fixed some variable names --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 25 ++++++++----------- .../boydti/fawe/bukkit/chat/Reflection.java | 4 --- .../bukkit/listener/BukkitImageListener.java | 4 +-- .../bukkit/listener/CFIPacketListener.java | 5 ++-- .../fawe/bukkit/regions/FactionsFeature.java | 5 ++-- .../fawe/bukkit/v0/BukkitQueue_All.java | 4 +-- .../boydti/fawe/bukkit/v0/ChunkListener.java | 18 ++++++------- .../fawe/bukkit/wrapper/AsyncBlock.java | 1 - .../main/java/com/boydti/fawe/config/BBC.java | 10 ++------ 9 files changed, 27 insertions(+), 49 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 4566813b9..adc5c9b29 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -110,8 +110,8 @@ public class FaweBukkit implements IFawe, Listener { } try { Fawe.get().setChatManager(new BukkitChatManager()); - } catch (Throwable ignore) { - ignore.printStackTrace(); + } catch (Throwable throwable) { + throwable.printStackTrace(); } } catch (final Throwable e) { MainUtil.handleError(e); @@ -226,11 +226,7 @@ public class FaweBukkit implements IFawe, Listener { @Override public void debug(final String s) { ConsoleCommandSender console = Bukkit.getConsoleSender(); - if (console != null) { - console.sendMessage(BBC.color(s)); - } else { - Bukkit.getLogger().info(BBC.color(s)); - } + console.sendMessage(BBC.color(s)); } @Override @@ -266,7 +262,7 @@ public class FaweBukkit implements IFawe, Listener { Player player = (Player) obj; FawePlayer existing = Fawe.get().getCachedPlayer(player.getName()); return existing != null ? existing : new BukkitPlayer(player); - } else if (obj != null && obj.getClass().getName().contains("EntityPlayer")) { + } else if (obj.getClass().getName().contains("EntityPlayer")) { try { Method method = obj.getClass().getDeclaredMethod("getBukkitEntity"); return wrap(method.invoke(obj)); @@ -314,7 +310,6 @@ public class FaweBukkit implements IFawe, Listener { @Override public String getDebugInfo() { StringBuilder msg = new StringBuilder(); - List pl = new ArrayList<>(); msg.append("server.version: " + Bukkit.getVersion() + "\n"); msg.append("Plugins: \n"); for (Plugin p : Bukkit.getPluginManager().getPlugins()) { @@ -350,7 +345,7 @@ public class FaweBukkit implements IFawe, Listener { } try { return getQueue(world); - } catch (Throwable ignore) { + } catch (Throwable throwable) { // Disable incompatible settings Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI @@ -365,7 +360,7 @@ public class FaweBukkit implements IFawe, Listener { debug("Download the version of FAWE for your platform"); debug(" - http://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target"); debug("======================================="); - ignore.printStackTrace(); + throwable.printStackTrace(); debug("======================================="); TaskManager.IMP.laterAsync( () -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1); @@ -398,11 +393,11 @@ public class FaweBukkit implements IFawe, Listener { } catch (Throwable ignore) { } } - Throwable error = null; + Throwable error; try { return getQueue(world); - } catch (Throwable ignore) { - error = ignore; + } catch (Throwable throwable) { + error = throwable; } // Disable incompatible settings Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level @@ -598,7 +593,7 @@ public class FaweBukkit implements IFawe, Listener { BukkitQueue_0.checkVersion(v.name()); this.version = tmp = v; break; - } catch (IllegalStateException e) {} + } catch (IllegalStateException ignored) {} } } return tmp; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java index 17e5e4280..a60d4cdda 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/Reflection.java @@ -40,10 +40,6 @@ public final class Reflection { */ public synchronized static String getVersion() { if (_versionString == null) { - if (Bukkit.getServer() == null) { - // The server hasn't started, static initializer call? - return null; - } String name = Bukkit.getServer().getClass().getPackage().getName(); _versionString = name.substring(name.lastIndexOf('.') + 1) + "."; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java index e175ff1d5..a0d3d80ec 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java @@ -153,8 +153,7 @@ public class BukkitImageListener implements Listener { ImageViewer viewer = generator.getImageViewer(); if (!(viewer instanceof BukkitImageViewer)) return null; - BukkitImageViewer biv = (BukkitImageViewer) viewer; - return biv; + return (BukkitImageViewer) viewer; } private void handleInteract(PlayerEvent event, Entity entity, boolean primary) { @@ -189,7 +188,6 @@ public class BukkitImageListener implements Listener { return; } - if (tool == null) return; BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary(); Brush brush = context.getBrush(); if (brush == null) return; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index 2053d8f9c..246f4bae2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -89,7 +89,7 @@ public class CFIPacketListener implements Listener { EnumWrappers.Hand enumHand = hands.isEmpty() ? EnumWrappers.Hand.MAIN_HAND : hands.get(0); PlayerInventory inv = plr.getInventory(); ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); - if (hand != null && hand.getType().isBlock()) { + if (hand.getType().isBlock()) { Material type = hand.getType(); if (!type.isEmpty()) { BlockStateHolder block = BukkitAdapter.asBlockState(hand); @@ -281,8 +281,7 @@ public class CFIPacketListener implements Listener { BlockPosition loc = position.readSafely(0); if (loc == null) return null; BlockVector3 origin = generator.getOrigin().toBlockPoint(); - BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); - return pt; + return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); } private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3 task) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java index f460862f7..0fd1e943f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java @@ -14,13 +14,12 @@ import org.bukkit.plugin.Plugin; public class FactionsFeature extends BukkitMaskManager implements Listener { FaweBukkit plugin; - Plugin factions; + private Plugin factions; public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) { super(factionsPlugin.getName()); this.factions = factionsPlugin; this.plugin = p3; - BoardColl.get(); } @Override @@ -45,7 +44,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { } } else if (fac.getOnlinePlayers().contains(player)) { - if (fac.getComparisonName().equals("wilderness") == false) { + if (!fac.getComparisonName().equals("wilderness")) { final Chunk chunk = loc.getChunk(); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java index 015b3b8fc..5a56af496 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java @@ -120,8 +120,8 @@ public class BukkitQueue_All extends BukkitQueue_0 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { - for (Entity ent : world.getEntities()) { - if (ent.getType() == EntityType.FIREWORK) { - Vector velocity = ent.getVelocity(); - double vertical = Math.abs(velocity.getY()); - if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); - ent.remove(); - } + if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { + for (Entity ent : world.getEntities()) { + if (ent.getType() == EntityType.FIREWORK) { + Vector velocity = ent.getVelocity(); + double vertical = Math.abs(velocity.getY()); + if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { + Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); + ent.remove(); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java index 8a90b76f8..c2e547800 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.wrapper; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.bukkit.wrapper.state.AsyncSign; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.util.TaskManager; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java index 0e3b06423..b47350b6c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/BBC.java @@ -410,9 +410,7 @@ public enum BBC { */ BBC(final String d, final boolean prefix, final String cat) { this.d = d; - if (this.s == null) { - this.s = d; - } + this.s = d; this.prefix = prefix; this.cat = cat.toLowerCase(); } @@ -559,11 +557,7 @@ public enum BBC { Method method = actor.getClass().getMethod("print", String.class); method.setAccessible(true); method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } } From d32777a53ef93ecb136c368ed73ffe1f2c57f137 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 24 May 2019 11:22:11 +0200 Subject: [PATCH 25/94] Revert "Fix //none removing arbitrary nbt" This reverts commit dd0bec89135fede4966d53180256bc346d677b54. --- .../src/main/java/com/boydti/fawe/util/BrushCache.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java index 7c885af07..4adbcdc35 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/BrushCache.java @@ -77,11 +77,8 @@ public final class BrushCache { Map map; if (nbt == null) { if (tool == null) { - Map raw = nbt.getRaw(); - if (raw.remove("weBrushJson") != null && raw.isEmpty()) { - item.setNbtData(null); - } - return null; + item.setNbtData(null); + return tool; } nbt = new CompoundTag(map = new HashMap<>()); } else { From 09e3ea48b8a94ed181829704e9f9aa6332046a6e Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 24 May 2019 11:50:45 +0200 Subject: [PATCH 26/94] Use "new" template formats --- ...ue-report-for-fastasyncworldedit-1-13-2.md | 39 +++++++++++++++++++ ...ue-report-for-fastasyncworldedit-1-13-2.md | 39 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md create mode 100644 .github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md new file mode 100644 index 000000000..07b0f7b25 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug---issue-report-for-fastasyncworldedit-1-13-2.md @@ -0,0 +1,39 @@ +--- +name: Bug / Issue report for FastAsyncWorldEdit 1.13.2 +about: Bug / Issue report about this plugin +title: '' +labels: Requires Testing +assignees: '' + +--- + +# Bug report for FastAsyncWorldEdit 1.13.2 + + + + +**[REQUIRED] FastAsyncWorldEdit Version Number:** + + +**[REQUIRED] Spigot/Paper Version Number:** + + +**Links to config.yml and config-legacy.yml file:** + + +**[REQUIRED] Description of the problem:** + + + +**Plugins being used on the server:** + + +**How to replicate**: + + +**Checklist**: + +- [] I included all information required in the sections above +- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) +- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) +- [] I made sure the bug/error is not caused by any other plugin diff --git a/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md b/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md new file mode 100644 index 000000000..168aee604 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md @@ -0,0 +1,39 @@ +--- +name: Bug/Issue report for FastAsyncWorldEdit 1.13.2 +about: Bug/Issue report about this plugin +title: '' +labels: Requires Testing +assignees: '' + +--- + +# Bug report for FastAsyncWorldEdit 1.13.2 + + + + +**[REQUIRED] FastAsyncWorldEdit Version Number:** + + +**[REQUIRED] Spigot/Paper Version Number:** + + +**Links to config.yml and config-legacy.yml file:** + + +**[REQUIRED] Description of the problem:** + + + +**Plugins being used on the server:** + + +**How to replicate**: + + +**Checklist**: + +- [] I included all information required in the sections above +- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) +- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) +- [] I made sure the bug/error is not caused by any other plugin diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..0695e00a9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: "[+] Enhancement" +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From a0b5662d4ae8c087da818cbe85fbc29b51a88c06 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 24 May 2019 11:57:32 +0200 Subject: [PATCH 27/94] Update issue templates --- ...ue-report-for-fastasyncworldedit-1-13-2.md | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md diff --git a/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md b/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md deleted file mode 100644 index 168aee604..000000000 --- a/.github/ISSUE_TEMPLATE/bug-issue-report-for-fastasyncworldedit-1-13-2.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: Bug/Issue report for FastAsyncWorldEdit 1.13.2 -about: Bug/Issue report about this plugin -title: '' -labels: Requires Testing -assignees: '' - ---- - -# Bug report for FastAsyncWorldEdit 1.13.2 - - - - -**[REQUIRED] FastAsyncWorldEdit Version Number:** - - -**[REQUIRED] Spigot/Paper Version Number:** - - -**Links to config.yml and config-legacy.yml file:** - - -**[REQUIRED] Description of the problem:** - - - -**Plugins being used on the server:** - - -**How to replicate**: - - -**Checklist**: - -- [] I included all information required in the sections above -- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) -- [] I made sure the bug/error is not caused by any other plugin From 8959fe07f7c63b02fc6a7a9b3b70813a8157dbc6 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 24 May 2019 12:04:14 +0200 Subject: [PATCH 28/94] Finalize new templates --- .github/ISSUE_TEMPLATE.md | 30 ------------------------------ README.md | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 070ba585a..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,30 +0,0 @@ -# Bug report for FastAsyncWorldEdit 1.13.2 - - - - -**[REQUIRED] FastAsyncWorldEdit Version Number:** - - -**[REQUIRED] Spigot/Paper Version Number:** - - -**Links to config.yml and config-legacy.yml file:** - - -**[REQUIRED] Description of the problem:** - - - -**Plugins being used on the server:** - - -**How to replicate**: - - -**Checklist**: - -- [] I included all information required in the sections above -- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues?utf8=%E2%9C%93&q=is%3Aissue) -- [] I made sure I am using an up-to-date version of [FastAsyncWorldEdit for 1.13.2](https://ci.athion.net/job/FastAsyncWorldEdit-Breaking/) -- [] I made sure the bug/error is not caused by any other plugin diff --git a/README.md b/README.md index 08da15539..60ee346f6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons * [Spigot Page](https://www.spigotmc.org/threads/fast-async-worldedit.100104/) * [Discord](https://discord.gg/ngZCzbU) * [Wiki](https://github.com/boy0001/FastAsyncWorldedit/wiki) -* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues/new) +* [Report Issue](https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues) ## Downloads ### 1.13+ From a0eb7ce59ecd873035600518485bbebca2790a10 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 28 May 2019 23:23:51 -0400 Subject: [PATCH 29/94] Typo Fixes and Added Annotations --- build.gradle | 5 ++ .../fawe/bukkit/util/BukkitTaskMan.java | 34 ++++----- .../java/com/boydti/fawe/config/Config.java | 2 +- .../fawe/example/DefaultFaweQueueMap.java | 2 +- .../boydti/fawe/example/IFaweQueueMap.java | 2 +- .../boydti/fawe/example/MappedFaweQueue.java | 2 +- .../boydti/fawe/example/WeakFaweQueueMap.java | 2 +- .../boydti/fawe/jnbt/anvil/MCAQueueMap.java | 4 +- .../boydti/fawe/object/brush/TargetMode.java | 2 +- .../fawe/object/collection/SparseBitSet.java | 4 +- .../com/boydti/fawe/util/ReflectionUtils.java | 16 ++--- .../com/boydti/fawe/util/TaskManager.java | 69 +++++++++---------- .../worldedit/command/tool/BrushTool.java | 2 +- 13 files changed, 71 insertions(+), 75 deletions(-) diff --git a/build.gradle b/build.gradle index 2d42f2d6a..a86e153a6 100644 --- a/build.gradle +++ b/build.gradle @@ -108,6 +108,10 @@ subprojects { build.dependsOn(sourcesJar) } + dependencies { + compileOnly 'org.jetbrains:annotations:17.0.0' + } + shadowJar { classifier 'dist' dependencies { @@ -116,6 +120,7 @@ subprojects { include(dependency('com.sk89q.lib:jlibnoise:1.0.0')) include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('co.aikar:fastutil-lite:1.0')) + include(dependency('org.jetbrains:annotations:17.0.0')) } exclude 'GradleStart**' exclude '.cache' diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java index 12de1f9ec..37d8722ba 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/BukkitTaskMan.java @@ -4,6 +4,7 @@ import com.boydti.fawe.util.TaskManager; import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public class BukkitTaskMan extends TaskManager { @@ -14,44 +15,35 @@ public class BukkitTaskMan extends TaskManager { } @Override - public int repeat(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval); + public int repeat(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, runnable, interval, interval); } @Override - public int repeatAsync(final Runnable r, final int interval) { - return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval); + public int repeatAsync(@NotNull final Runnable runnable, final int interval) { + return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, runnable, interval, interval); } public MutableInt index = new MutableInt(0); @Override - public void async(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId(); + public void async(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, runnable).getTaskId(); } @Override - public void task(final Runnable r) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId(); + public void task(@NotNull final Runnable runnable) { + this.plugin.getServer().getScheduler().runTask(this.plugin, runnable).getTaskId(); } @Override - public void later(final Runnable r, final int delay) { - if (r == null) { - return; - } - this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId(); + public void later(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay).getTaskId(); } @Override - public void laterAsync(final Runnable r, final int delay) { - this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay); + public void laterAsync(@NotNull final Runnable runnable, final int delay) { + this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, runnable, delay); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java index c16ebc848..49b68709b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Config.java @@ -441,7 +441,7 @@ public class Config { } /** - * Set some field to be accesible + * Set some field to be accessible * * @param field * @throws NoSuchFieldException diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java index 5e1536ec7..08cb86e52 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/DefaultFaweQueueMap.java @@ -45,7 +45,7 @@ public class DefaultFaweQueueMap implements IFaweQueueMap { }; @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { synchronized (blocks) { return new HashSet<>(blocks.values()); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java index 6633b075c..2f2bbaa38 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/IFaweQueueMap.java @@ -6,7 +6,7 @@ import java.util.Collection; public interface IFaweQueueMap { - Collection getFaweCunks(); + Collection getFaweChunks(); void forEachChunk(RunnableVal onEach); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java index 2c88f5900..85d2ba46b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java @@ -102,7 +102,7 @@ public abstract class MappedFaweQueue impl @Override public Collection getFaweChunks() { - return map.getFaweCunks(); + return map.getFaweChunks(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java index 681745ec4..0f2b4f808 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/WeakFaweQueueMap.java @@ -48,7 +48,7 @@ public class WeakFaweQueueMap implements IFaweQueueMap { }; @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { HashSet set = new HashSet<>(); synchronized (blocks) { Iterator>> iter = blocks.entrySet().iterator(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java index e2dab560e..15449f8be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueueMap.java @@ -80,7 +80,7 @@ public class MCAQueueMap implements IFaweQueueMap { } @Override - public Collection getFaweCunks() { + public Collection getFaweChunks() { final List chunks = new ArrayList<>(); for (Map.Entry entry : mcaFileMap.entrySet()) { MCAFile file = entry.getValue(); @@ -93,7 +93,7 @@ public class MCAQueueMap implements IFaweQueueMap { @Override public void forEachChunk(RunnableVal onEach) { - for (FaweChunk chunk : getFaweCunks()) { + for (FaweChunk chunk : getFaweChunks()) { onEach.run(chunk); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java index 84a3547e2..98b04a3c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/TargetMode.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.brush; public enum TargetMode { TARGET_BLOCK_RANGE, - FOWARD_POINT_PITCH, + FORWARD_POINT_PITCH, TARGET_POINT_HEIGHT, TARGET_FACE_RANGE, } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java index a2ccec249..91935f821 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/collection/SparseBitSet.java @@ -94,7 +94,7 @@ public final class SparseBitSet implements Cloneable, Serializable { bits (setting, flipping, clearing, etc.) do not attempt to normalize the set, in the interests of speed. However, when a set is scanned as the resultant set of some operation, then, in most cases, the set will be - normalized--the exception being level2 areas that are not completly scanned + normalized--the exception being level2 areas that are not completely scanned in a particular pass. The sizes of the blocks and areas has been the result of some investigation @@ -2797,4 +2797,4 @@ public final class SparseBitSet implements Cloneable, Serializable { * Word and block xor strategy. */ protected transient XorStrategy xorStrategy; -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java index 32f09ba84..05f51b8fc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/ReflectionUtils.java @@ -63,8 +63,8 @@ public class ReflectionUtils { T newValue = (T) makeEnum(enumType, // The target enum class enumName, // THE NEW ENUM INSTANCE TO BE DYNAMICALLY ADDED values.size(), - additionalTypes, // can be used to pass values to the enum constuctor - additionalValues); // can be used to pass values to the enum constuctor + additionalTypes, // can be used to pass values to the enum constructor + additionalValues); // can be used to pass values to the enum constructor // 4. add new value values.add(newValue); @@ -219,9 +219,9 @@ public class ReflectionUtils { } //Utils - public static Method makeMethod(final Class clazz, final String methodName, final Class... paramaters) { + public static Method makeMethod(final Class clazz, final String methodName, final Class... parameters) { try { - return clazz.getDeclaredMethod(methodName, paramaters); + return clazz.getDeclaredMethod(methodName, parameters); } catch (final NoSuchMethodException ex) { return null; } catch (final Exception ex) { @@ -230,13 +230,13 @@ public class ReflectionUtils { } @SuppressWarnings("unchecked") - public static T callMethod(final Method method, final Object instance, final Object... paramaters) { + public static T callMethod(final Method method, final Object instance, final Object... parameters) { if (method == null) { throw new RuntimeException("No such method"); } method.setAccessible(true); try { - return (T) method.invoke(instance, paramaters); + return (T) method.invoke(instance, parameters); } catch (final InvocationTargetException ex) { throw new RuntimeException(ex.getCause()); } catch (final Exception ex) { @@ -245,9 +245,9 @@ public class ReflectionUtils { } @SuppressWarnings("unchecked") - public static Constructor makeConstructor(final Class clazz, final Class... paramaterTypes) { + public static Constructor makeConstructor(final Class clazz, final Class... parameterTypes) { try { - return (Constructor) clazz.getConstructor(paramaterTypes); + return (Constructor) clazz.getConstructor(parameterTypes); } catch (final NoSuchMethodException ex) { return null; } catch (final Exception ex) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index 793f18b51..368853e91 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -4,6 +4,8 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.RunnableVal; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Iterator; import java.util.concurrent.ForkJoinPool; @@ -21,34 +23,34 @@ public abstract class TaskManager { /** * Run a repeating task on the main thread * - * @param r + * @param runnable * @param interval in ticks * @return */ - public abstract int repeat(final Runnable r, final int interval); + public abstract int repeat(@NotNull final Runnable runnable, final int interval); /** * Run a repeating task asynchronously * - * @param r + * @param runnable * @param interval in ticks * @return */ - public abstract int repeatAsync(final Runnable r, final int interval); + public abstract int repeatAsync(@NotNull final Runnable runnable, final int interval); /** * Run a task asynchronously * - * @param r + * @param runnable */ - public abstract void async(final Runnable r); + public abstract void async(@NotNull final Runnable runnable); /** * Run a task on the main thread * - * @param r + * @param runnable */ - public abstract void task(final Runnable r); + public abstract void task(@NotNull final Runnable runnable); /** * Get the public ForkJoinPool
@@ -149,14 +151,14 @@ public abstract class TaskManager { * Run a task on the current thread or asynchronously * - If it's already the main thread, it will jst call run() * - * @param r + * @param runnable * @param async */ - public void taskNow(final Runnable r, boolean async) { + public void taskNow(@NotNull final Runnable runnable, boolean async) { if (async) { - async(r); - } else if (r != null) { - r.run(); + async(runnable); + } else { + runnable.run(); } } @@ -164,40 +166,37 @@ public abstract class TaskManager { * Run a task as soon as possible on the main thread * - Non blocking if not calling from the main thread * - * @param r + * @param runnable */ - public void taskNowMain(final Runnable r) { - if (r == null) { - return; - } + public void taskNowMain(@NotNull final Runnable runnable) { if (Fawe.isMainThread()) { - r.run(); + runnable.run(); } else { - task(r); + task(runnable); } } /** * Run a task as soon as possible not on the main thread * - * @param r + * @param runnable * @see com.boydti.fawe.Fawe#isMainThread() */ - public void taskNowAsync(final Runnable r) { - taskNow(r, Fawe.isMainThread()); + public void taskNowAsync(@NotNull final Runnable runnable) { + taskNow(runnable, Fawe.isMainThread()); } /** * Run a task on the main thread at the next tick or now async * - * @param r + * @param runnable * @param async */ - public void taskSoonMain(final Runnable r, boolean async) { + public void taskSoonMain(@NotNull final Runnable runnable, boolean async) { if (async) { - async(r); + async(runnable); } else { - task(r); + task(runnable); } } @@ -205,18 +204,18 @@ public abstract class TaskManager { /** * Run a task later on the main thread * - * @param r + * @param runnable * @param delay in ticks */ - public abstract void later(final Runnable r, final int delay); + public abstract void later(@NotNull final Runnable runnable, final int delay); /** * Run a task later asynchronously * - * @param r + * @param runnable * @param delay in ticks */ - public abstract void laterAsync(final Runnable r, final int delay); + public abstract void laterAsync(@NotNull final Runnable runnable, final int delay); /** * Cancel a task @@ -295,11 +294,11 @@ public abstract class TaskManager { } } - public T syncWhenFree(final RunnableVal function) { + public T syncWhenFree(@NotNull final RunnableVal function) { return syncWhenFree(function, Integer.MAX_VALUE); } - public void taskWhenFree(Runnable run) { + public void taskWhenFree(@NotNull Runnable run) { if (Fawe.isMainThread()) { run.run(); } else { @@ -317,7 +316,7 @@ public abstract class TaskManager { * @param * @return */ - public T syncWhenFree(final RunnableVal function, int timeout) { + public T syncWhenFree(@NotNull final RunnableVal function, int timeout) { if (Fawe.isMainThread()) { function.run(); return function.value; @@ -366,7 +365,7 @@ public abstract class TaskManager { * @param * @return */ - public T sync(final RunnableVal function, int timeout) { + public T sync(@NotNull final RunnableVal function, int timeout) { return sync((Supplier) function, timeout); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 269d9b7b5..5e5274b90 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -382,7 +382,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool switch (targetMode) { case TARGET_BLOCK_RANGE: return offset(trace(editSession, player, getRange(), true), loc).toBlockPoint(); - case FOWARD_POINT_PITCH: { + case FORWARD_POINT_PITCH: { int d = 0; float pitch = loc.getPitch(); pitch = 23 - (pitch / 4); From aea5b68ced63511b0e0c13b3a94c5582b9d013e9 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Thu, 30 May 2019 16:07:30 -0400 Subject: [PATCH 30/94] Upstream merges and a few code cleanups --- .../fawe/bukkit/v1_13/BukkitChunk_1_13.java | 25 +++++------ .../fawe/bukkit/v1_13/BukkitQueue_1_13.java | 41 ++++++++----------- .../com/boydti/fawe/command/Rollback.java | 11 ++--- .../com/boydti/fawe/example/IntFaweChunk.java | 8 ++-- .../fawe/jnbt/CorruptSchematicStreamer.java | 3 +- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 4 +- .../com/boydti/fawe/jnbt/anvil/MCAWriter.java | 3 +- .../fawe/jnbt/anvil/WritableMCAChunk.java | 4 +- .../boydti/fawe/object/FaweOutputStream.java | 4 +- .../object/changeset/DiskStorageHistory.java | 4 +- .../java/com/boydti/fawe/util/MainUtil.java | 15 +++---- .../function/mask/BlockMaskBuilder.java | 4 +- .../com/sk89q/worldedit/registry/Keyed.java | 31 ++++++++++++++ .../sk89q/worldedit/registry/Registry.java | 12 +++--- .../FunctionParametricCallable.java | 6 +-- .../worldedit/world/block/BlockState.java | 2 + .../worldedit/world/block/BlockType.java | 14 ++++--- 17 files changed, 102 insertions(+), 89 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/registry/Keyed.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java index 2ccfa8b5d..9a67be5a9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitChunk_1_13.java @@ -192,11 +192,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk { byte[] newBlockBytes = newBlockLight.asBytes(); byte[] blockLightBytes = blockLight.asBytes(); - for (int i = 0; i < 2048; i++) newBlockBytes[i] = blockLightBytes[i]; + System.arraycopy(blockLightBytes, 0, newBlockBytes, 0, 2048); if (skyLight != null) { byte[] newSkyBytes = newSkyLight.asBytes(); byte[] skyLightBytes = skyLight.asBytes(); - for (int i = 0; i < 2048; i++) newSkyBytes[i] = skyLightBytes[i]; + System.arraycopy(skyLightBytes, 0, newSkyBytes, 0, 2048); } // Copy counters @@ -241,7 +241,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { Object[] currArray = ((Object[]) BukkitQueue_1_13.fieldLinearBlocks.get(currentPalette)); Object[] newArray = ((Object[]) BukkitQueue_1_13.fieldLinearBlocks.get(newPalette)); BukkitQueue_1_13.fieldLinearIndex.set(newPalette, BukkitQueue_1_13.fieldLinearIndex.get(currentPalette)); - for (int i = 0; i < newArray.length; i++) newArray[i] = currArray[i]; + System.arraycopy(currArray, 0, newArray, 0, newArray.length); } BukkitQueue_1_13.fieldPalette.set(paletteBlock, newPalette); @@ -348,8 +348,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { // Remove entities HashSet entsToRemove = this.getEntityRemoves(); if (!entsToRemove.isEmpty()) { - for (int i = 0; i < entities.length; i++) { - Collection ents = entities[i]; + for (Collection ents : entities) { if (!ents.isEmpty()) { Iterator iter = ents.iterator(); while (iter.hasNext()) { @@ -445,13 +444,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk { UUID uuid = entity.getUniqueID(); entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); - if (nativeTag != null) { - NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag); - for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { - tag.remove(name); - } - entity.f(tag); + NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_13.fromNative(nativeTag); + for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { + tag.remove(name); } + entity.f(tag); entity.setLocation(x, y, z, yaw, pitch); synchronized (BukkitQueue_0.class) { nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM); @@ -547,9 +544,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk { // Trim tiles HashMap toRemove = null; if (!tiles.isEmpty()) { - Iterator> iterator = tiles.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); + for (Map.Entry tile : tiles.entrySet()) { BlockPosition pos = tile.getKey(); int lx = pos.getX() & 15; int ly = pos.getY(); @@ -629,4 +624,4 @@ public class BukkitChunk_1_13 extends IntFaweChunk { } return this; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java index 7b9d2bb23..0944fb232 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java @@ -691,27 +691,24 @@ public class BukkitQueue_1_13 extends BukkitQueue_0() { - @Override - public Object get() { - try { - int dirtyBits = fieldDirtyBits.getInt(playerChunk); - if (dirtyBits == 0) { - ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); - } - if (mask == 0) { - dirtyBits = 65535; - } else { - dirtyBits |= mask; - } - - fieldDirtyBits.set(playerChunk, dirtyBits); - fieldDirtyCount.set(playerChunk, 64); - } catch (IllegalAccessException e) { - e.printStackTrace(); + TaskManager.IMP.sync(() -> { + try { + int dirtyBits = fieldDirtyBits.getInt(playerChunk); + if (dirtyBits == 0) { + ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); } - return null; + if (mask == 0) { + dirtyBits = 65535; + } else { + dirtyBits |= mask; + } + + fieldDirtyBits.set(playerChunk, dirtyBits); + fieldDirtyCount.set(playerChunk, 64); + } catch (IllegalAccessException e) { + e.printStackTrace(); } + return null; }); } // if (mask == 0) { @@ -754,8 +751,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0[] entities = nmsChunk.entitySlices; - for (int i = 0; i < entities.length; i++) { - Collection slice = entities[i]; + for (Collection slice : entities) { if (slice != null && !slice.isEmpty()) { return true; } @@ -781,8 +777,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0 u: r: t: