Many upstream changes. Should be non-breaking

This commit is contained in:
MattBDev 2019-06-25 09:00:44 -04:00
parent c672bcfddd
commit a1c15e1c39
53 changed files with 689 additions and 1067 deletions

View File

@ -7,7 +7,6 @@ import com.boydti.fawe.regions.general.CuboidRegionFilter;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;

View File

@ -37,7 +37,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
final RegionManager manager = container.get(fp.getWorld()); final RegionManager manager = container.get(fp.getWorld());
return new FaweMask(new ManagerRegion(manager, localplayer), null) { return new FaweMask(new ManagerRegion(manager, localplayer)) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(FawePlayer player, MaskType type) {
// We rely on the region mask instead of this // We rely on the region mask instead of this

View File

@ -2,20 +2,20 @@ package com.boydti.fawe.bukkit.util;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.bukkit.inventory.ItemStack;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.bukkit.inventory.ItemStack;
public class ItemUtil { public class ItemUtil {
private final Class<?> classCraftItemStack;
private final Method methodAsNMSCopy; private final Method methodAsNMSCopy;
private final Class<?> classNMSItem;
private final Method methodGetTag; private final Method methodGetTag;
private final Method methodHasTag; private final Method methodHasTag;
private final Method methodSetTag; private final Method methodSetTag;
@ -25,8 +25,8 @@ public class ItemUtil {
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>()); private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
public ItemUtil() throws Exception { public ItemUtil() throws Exception {
this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack"); Class<?> classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack"); Class<?> classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class)); this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class));
this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag")); this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag"));
this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag")); this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag"));

View File

@ -11,20 +11,12 @@ import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import java.io.File;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot; import org.bukkit.ChunkSnapshot;
@ -33,6 +25,14 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import java.io.File;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> { public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> {
private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker() private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker()
@ -78,15 +78,6 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
} }
private static Class<?> classRegionFileCache; private static Class<?> classRegionFileCache;
private static Class<?> classRegionFile;
private static Class<?> classCraftChunk;
private static Class<?> classCraftWorld;
private static Class<?> classNMSChunk;
private static Class<?> classNMSWorld;
private static Class<?> classChunkProviderServer;
private static Class<?> classIChunkLoader;
private static Class<?> classChunkRegionLoader;
private static Class<?> classIChunkProvider;
private static Method methodGetHandleChunk; private static Method methodGetHandleChunk;
private static Method methodGetHandleWorld; private static Method methodGetHandleWorld;
private static Method methodFlush; private static Method methodFlush;
@ -100,15 +91,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
try { try {
BukkitReflectionUtils.init(); BukkitReflectionUtils.init();
classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache"); classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache");
classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile"); Class<?> classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk"); Class<?> classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk"); Class<?> classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld"); Class<?> classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
classNMSWorld = BukkitReflectionUtils.getNmsClass("World"); Class<?> classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer"); Class<?> classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider"); Class<?> classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader"); Class<?> classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader"); Class<?> classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle")); methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle")); methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
@ -289,15 +280,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
private ChunkSnapshot tryGetSnasphot(Chunk chunk) { private ChunkSnapshot tryGetSnasphot(Chunk chunk) {
try { try {
return chunk.getChunkSnapshot(false, true, false); return chunk.getChunkSnapshot(false, true, false);
} catch (Throwable ignore) { } catch (Throwable throwable) {
Throwable cause = ignore; Throwable cause = throwable;
while (cause.getCause() != null) { while (cause.getCause() != null) {
cause = cause.getCause(); cause = cause.getCause();
} }
if (cause instanceof IllegalStateException) { if (cause instanceof IllegalStateException) {
return null; return null;
} }
throw ignore; throw throwable;
} }
} }
@ -391,8 +382,8 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
if (disableResult != null) { if (disableResult != null) {
try { try {
fieldNeighbors.set(disableResult[0], disableResult[1]); fieldNeighbors.set(disableResult[0], disableResult[1]);
} catch (Throwable ignore) { } catch (Throwable throwable) {
ignore.printStackTrace(); throwable.printStackTrace();
} }
} }
} }

View File

@ -15,8 +15,8 @@ import com.boydti.fawe.object.brush.visualization.VisualChunk;
import com.boydti.fawe.object.visitor.FaweChunkVisitor; import com.boydti.fawe.object.visitor.FaweChunkVisitor;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
@ -62,24 +62,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
final static Field fieldNonEmptyBlockCount; final static Field fieldNonEmptyBlockCount;
final static Field fieldSection; final static Field fieldSection;
final static Field fieldLiquidCount; final static Field fieldLiquidCount;
private final static Field fieldEmittedLight;
private final static Field fieldSkyLight;
// protected final static Field fieldBiomes;
private final static Field fieldChunkGenerator;
private final static Field fieldSeed;
// protected final static Field fieldBiomeCache;
// protected final static Field fieldBiomes2;
private final static Field fieldGenLayer1;
private final static Field fieldGenLayer2;
private final static Field fieldSave;
// protected final static MutableGenLayer genLayer;
private final static ChunkSection emptySection; private final static ChunkSection emptySection;
// protected static final Method methodResize;
private final static Field fieldDirtyCount; private final static Field fieldDirtyCount;
private final static Field fieldDirtyBits; private final static Field fieldDirtyBits;
@ -89,12 +73,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
Arrays.fill(emptySection.getSkyLightArray().asBytes(), (byte) 255); Arrays.fill(emptySection.getSkyLightArray().asBytes(), (byte) 255);
fieldSection = ChunkSection.class.getDeclaredField("blockIds"); fieldSection = ChunkSection.class.getDeclaredField("blockIds");
fieldLiquidCount = ChunkSection.class.getDeclaredField("e"); fieldLiquidCount = ChunkSection.class.getDeclaredField("e");
fieldEmittedLight = ChunkSection.class.getDeclaredField("emittedLight");
fieldSkyLight = ChunkSection.class.getDeclaredField("skyLight");
fieldSection.setAccessible(true); fieldSection.setAccessible(true);
fieldLiquidCount.setAccessible(true); fieldLiquidCount.setAccessible(true);
fieldEmittedLight.setAccessible(true);
fieldSkyLight.setAccessible(true);
fieldFluidCount = ChunkSection.class.getDeclaredField("e"); fieldFluidCount = ChunkSection.class.getDeclaredField("e");
fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount"); fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount");
@ -103,25 +83,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
fieldTickingBlockCount.setAccessible(true); fieldTickingBlockCount.setAccessible(true);
fieldNonEmptyBlockCount.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_13_R2.Chunk.class.getDeclaredField("s")); //*
fieldHashBlocks = DataPaletteHash.class.getDeclaredField("b"); fieldHashBlocks = DataPaletteHash.class.getDeclaredField("b");
fieldHashBlocks.setAccessible(true); fieldHashBlocks.setAccessible(true);
fieldLinearBlocks = DataPaletteLinear.class.getDeclaredField("b"); fieldLinearBlocks = DataPaletteLinear.class.getDeclaredField("b");
@ -156,9 +117,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
fieldPalette = DataPaletteBlock.class.getDeclaredField("h"); fieldPalette = DataPaletteBlock.class.getDeclaredField("h");
fieldPalette.setAccessible(true); fieldPalette.setAccessible(true);
// methodResize = DataPaletteBlock.class.getDeclaredMethod("b", int.class);
// methodResize.setAccessible(true);
fieldDirtyCount = PlayerChunk.class.getDeclaredField("dirtyCount"); fieldDirtyCount = PlayerChunk.class.getDeclaredField("dirtyCount");
fieldDirtyBits = PlayerChunk.class.getDeclaredField("h"); fieldDirtyBits = PlayerChunk.class.getDeclaredField("h");
fieldDirtyCount.setAccessible(true); fieldDirtyCount.setAccessible(true);
@ -229,54 +187,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
@Override @Override
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) { 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_13_R2.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_13_R2.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); return super.regenerateChunk(world, x, z, biome, seed);
} }
@ -409,89 +319,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, 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<Object>() {
// @Override
// public void run(Object value) {
// try {
// Field field = CraftServer.class.getDeclaredField("worlds");
// field.setAccessible(true);
// Map<Object, Object> existing = (Map<Object, Object>) 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<World>() {
// @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 @Override
public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) { public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) {
DataPaletteBlock<IBlockData> dataPalette = lastSection.getBlocks(); DataPaletteBlock<IBlockData> dataPalette = lastSection.getBlocks();
@ -681,40 +508,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
return null; 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; return true;
} }

View File

@ -19,28 +19,21 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.bekvon.bukkit.residence.commands.material;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.command.tool.BlockDataCyler;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState; 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.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry; import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial; import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
public class BukkitBlockRegistry extends BundledBlockRegistry { public class BukkitBlockRegistry extends BundledBlockRegistry {

View File

@ -19,19 +19,17 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagException; import com.sk89q.worldedit.extent.inventory.BlockBagException;
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException; import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException; import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag { public class BukkitPlayerBlockBag extends BlockBag {
private Player player; private Player player;
private ItemStack[] items; private ItemStack[] items;
@ -182,16 +180,4 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
public void addSingleSourcePosition(Location pos) { public void addSingleSourcePosition(Location pos) {
} }
@Override
public BaseItem getItem(int slot) {
loadInventory();
return BukkitAdapter.adapt(items[slot]);
}
@Override
public void setItem(int slot, BaseItem block) {
loadInventory();
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
items[slot] = BukkitAdapter.adapt(stack);
}
} }

View File

@ -36,14 +36,13 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
public class BukkitServerInterface implements MultiUserPlatform { public class BukkitServerInterface implements MultiUserPlatform {
public Server server; public Server server;
public WorldEditPlugin plugin; public WorldEditPlugin plugin;

View File

@ -1,4 +1,5 @@
/* /*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com> * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors * Copyright (C) WorldEdit team and contributors
* *
@ -18,11 +19,10 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.boydti.fawe.Fawe; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -38,7 +38,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.TreeType; import org.bukkit.TreeType;
import org.bukkit.World; import org.bukkit.World;
@ -57,7 +56,6 @@ import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
public class BukkitWorld extends AbstractWorld { public class BukkitWorld extends AbstractWorld {

View File

@ -24,13 +24,14 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.plugin.messaging.PluginMessageListener;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/** /**
* Handles incoming WorldEditCui init message. * Handles incoming WorldEditCui init message.
*/ */
public class CUIChannelListener implements PluginMessageListener { public class CUIChannelListener implements PluginMessageListener {
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
private final WorldEditPlugin plugin; private final WorldEditPlugin plugin;
public CUIChannelListener(WorldEditPlugin plugin) { public CUIChannelListener(WorldEditPlugin plugin) {

View File

@ -1,52 +0,0 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import javax.annotation.Nullable;
public class DelegateEntity implements Entity {
private final Entity parent;
public DelegateEntity(Entity parent) {
this.parent = parent;
}
public Entity getParent() {
return parent;
}
@Override
@Nullable
public BaseEntity getState() {
return parent.getState();
}
@Override
public Location getLocation() {
return parent.getLocation();
}
@Override
public Extent getExtent() {
return parent.getExtent();
}
@Override
public boolean remove() {
return parent.remove();
}
@Override
@Nullable
public <T> T getFacet(Class<? extends T> cls) {
return parent.getFacet(cls);
}
@Override
public boolean setLocation(Location location) {
return parent.setLocation(location);
}
}

View File

@ -28,7 +28,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.CommandMapping; import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Event.Result; import org.bukkit.event.Event.Result;
@ -111,15 +110,12 @@ public class WorldEditListener implements Listener {
public void onPlayerCommand(PlayerCommandSendEvent event) { public void onPlayerCommand(PlayerCommandSendEvent event) {
CommandLocals locals = new CommandLocals(); CommandLocals locals = new CommandLocals();
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer())); locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher(); Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
if (dispatcher != null) {
Set<String> toRemove = dispatcher.getCommands().stream()
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals)) .filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
.map(CommandMapping::getPrimaryAlias) .map(CommandMapping::getPrimaryAlias)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
event.getCommands().removeIf(toRemove::contains); event.getCommands().removeIf(toRemove::contains);
} }
}
/** /**
* Called when a player interacts * Called when a player interacts

View File

@ -23,7 +23,9 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2; import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.wepif.PermissionsResolverManager; import com.sk89q.wepif.PermissionsResolverManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -61,7 +63,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.*; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -72,8 +78,6 @@ import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Plugin for Bukkit. * Plugin for Bukkit.
*/ */
@ -89,7 +93,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private static Map<String, Plugin> lookupNames; private static Map<String, Plugin> lookupNames;
static { static {
{ // Disable AWE as otherwise both fail to load // Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager(); PluginManager manager = Bukkit.getPluginManager();
try { try {
Field pluginsField = manager.getClass().getDeclaredField("plugins"); Field pluginsField = manager.getClass().getDeclaredField("plugins");
@ -122,7 +126,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
}); });
} catch (Throwable ignore) {} } catch (Throwable ignore) {}
} }
}
public WorldEditPlugin() { public WorldEditPlugin() {
init(); init();
@ -180,10 +183,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
PermissionsResolverManager.initialize(this); // Setup permission resolver PermissionsResolverManager.initialize(this); // Setup permission resolver
// Register CUI // Register CUI
fail(() -> { getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
getServer().getMessenger().registerIncomingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL, new CUIChannelListener(INSTANCE)); getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
getServer().getMessenger().registerOutgoingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL);
}, "Failed to register CUI");
// Now we can register events // Now we can register events
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this); getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
@ -193,7 +194,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// platforms to be worried about... at the current time of writing // platforms to be worried about... at the current time of writing
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
{ // Register 1.13 Material ids with LegacyMapper // Register 1.13 Material ids with LegacyMapper
LegacyMapper legacyMapper = LegacyMapper.getInstance(); LegacyMapper legacyMapper = LegacyMapper.getInstance();
for (Material m : Material.values()) { for (Material m : Material.values()) {
if (!m.isLegacy() && m.isBlock()) { if (!m.isLegacy() && m.isBlock()) {
@ -201,7 +202,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
} }
} }
} }
}
public void setupRegistries() { public void setupRegistries() {
// Biome // Biome
@ -262,8 +262,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
} }
private void rename() { private void rename() {
File dir = getDataFolder(); File dir = new File(getDataFolder().getParentFile(), "FastAsyncWorldEdit");
dir = new File(dir.getParentFile(), "FastAsyncWorldEdit");
try { try {
Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder"); Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder");
descriptionField.setAccessible(true); descriptionField.setAccessible(true);

View File

@ -30,9 +30,67 @@ limits:
butcher-radius: butcher-radius:
default: -1 default: -1
maximum: -1 maximum: -1
# Use either block ids, names, or regex disallowed-blocks:
# Regex supports properties as well (see FAWE mask documentation) - "minecraft:oak_sapling"
disallowed-blocks: [] - "minecraft:jungle_sapling"
- "minecraft:dark_oak_sapling:"
- "minecraft:spruce_sapling"
- "minecraft:birch_sapling"
- "minecraft:acacia_sapling"
- "minecraft:black_bed"
- "minecraft:blue_bed"
- "minecraft:brown_bed"
- "minecraft:cyan_bed"
- "minecraft:gray_bed"
- "minecraft:green_bed"
- "minecraft:light_blue_bed"
- "minecraft:light_gray_bed"
- "minecraft:lime_bed"
- "minecraft:magenta_bed"
- "minecraft:orange_bed"
- "minecraft:pink_bed"
- "minecraft:purple_bed"
- "minecraft:red_bed"
- "minecraft:white_bed"
- "minecraft:yellow_bed"
- "minecraft:powered_rail"
- "minecraft:detector_rail"
- "minecraft:grass"
- "minecraft:dead_bush"
- "minecraft:moving_piston"
- "minecraft:piston_head"
- "minecraft:sunflower"
- "minecraft:rose_bush"
- "minecraft:dandelion"
- "minecraft:poppy"
- "minecraft:brown_mushroom"
- "minecraft:red_mushroom"
- "minecraft:tnt"
- "minecraft:torch"
- "minecraft:fire"
- "minecraft:redstone_wire"
- "minecraft:wheat"
- "minecraft:potatoes"
- "minecraft:carrots"
- "minecraft:melon_stem"
- "minecraft:pumpkin_stem"
- "minecraft:beetroots"
- "minecraft:rail"
- "minecraft:lever"
- "minecraft:redstone_torch"
- "minecraft:redstone_wall_torch"
- "minecraft:repeater"
- "minecraft:comparator"
- "minecraft:stone_button"
- "minecraft:birch_button"
- "minecraft:acacia_button"
- "minecraft:dark_oak_button"
- "minecraft:jungle_button"
- "minecraft:oak_button"
- "minecraft:spruce_button"
- "minecraft:cactus"
- "minecraft:sugar_cane"
- "minecraft:bedrock"
use-inventory: use-inventory:
enable: false enable: false

View File

@ -8,6 +8,7 @@ import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.IOUtil; import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
@ -19,6 +20,7 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompressedCompoundTag; import com.sk89q.jnbt.CompressedCompoundTag;
import com.sk89q.jnbt.CompressedSchematicTag; import com.sk89q.jnbt.CompressedSchematicTag;
import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -27,9 +29,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -48,7 +48,7 @@ public class FaweSchematicHandler extends SchematicHandler {
return true; return true;
} }
FaweQueue faweQueue = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false); FaweQueue faweQueue = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false);
faweQueue.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(compoundTag)); faweQueue.setTile(x, y, z, (CompoundTag) FaweCache.asTag(compoundTag));
faweQueue.flush(); faweQueue.flush();
return false; return false;
} }
@ -98,7 +98,7 @@ public class FaweSchematicHandler extends SchematicHandler {
} }
} else { } else {
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) { try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) {
Map<String, com.sk89q.jnbt.Tag> map = tag.getValue(); Map<String, Tag> map = tag.getValue();
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag)); output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
} }
} }
@ -123,9 +123,9 @@ public class FaweSchematicHandler extends SchematicHandler {
public void run(OutputStream output) { public void run(OutputStream output) {
try { try {
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) { try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
com.sk89q.jnbt.CompoundTag weTag = (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(tag); CompoundTag weTag = (CompoundTag) FaweCache.asTag(tag);
try (NBTOutputStream nos = new NBTOutputStream(gzip)) { try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
Map<String, com.sk89q.jnbt.Tag> map = weTag.getValue(); Map<String, Tag> map = weTag.getValue();
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag)); nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));
} }
} }

View File

@ -12,6 +12,7 @@ import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet; import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
import com.boydti.fawe.object.changeset.FaweStreamChangeSet; import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
import com.boydti.fawe.object.io.AbstractDelegateOutputStream; import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
import com.github.luben.zstd.ZstdInputStream; import com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdOutputStream; import com.github.luben.zstd.ZstdOutputStream;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -21,10 +22,12 @@ import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import static java.lang.System.arraycopy;
import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream; import net.jpountz.lz4.LZ4BlockOutputStream;
import net.jpountz.lz4.LZ4Compressor; import net.jpountz.lz4.LZ4Compressor;
@ -39,7 +42,6 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -76,8 +78,6 @@ import java.util.zip.Inflater;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import static java.lang.System.arraycopy;
public class MainUtil { public class MainUtil {
/* /*
* Generic non plugin related utils * Generic non plugin related utils
@ -132,13 +132,6 @@ public class MainUtil {
return size.get(); return size.get();
} }
public static double getJavaVersion() {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
pos = version.indexOf('.', pos + 1);
return Double.parseDouble(version.substring(0, pos));
}
public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) { public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) {
try { try {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() { Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@ -507,45 +500,6 @@ public class MainUtil {
return new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath()); return new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
} }
public static void sendCompressedMessage(FaweStreamChangeSet set, FawePlayer actor) {
try {
long elements = set.size();
long compressedSize = set.getCompressedSize();
if (compressedSize == 0) {
return;
}
/*
* BlockVector
* - reference to the object --> 8 bytes
* - object header (java internals) --> 8 bytes
* - double x, y, z --> 24 bytes
*
* BaseBlock
* - reference to the object --> 8 bytes
* - object header (java internals) --> 8 bytes
* - short id, data --> 4 bytes
* - NBTCompound (assuming null) --> 4 bytes
*
* There are usually two lists for the block changes:
* 2 * BlockVector + 2 * BaseBlock = 128b
*
* WE has a lot more overhead, this is just a generous lower bound
*
* This compares FAWE's usage to standard WE.
*/
long total = 128 * elements;
long ratio = total / compressedSize;
long saved = total - compressedSize;
if (ratio > 3 && !Fawe.isMainThread() && actor != null) {
BBC.COMPRESSED.send(actor, saved, ratio);
}
} catch (Exception e) {
MainUtil.handleError(e);
}
}
public static Thread[] getThreads() { public static Thread[] getThreads() {
ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( ); ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( );
ThreadGroup parentGroup; ThreadGroup parentGroup;
@ -667,47 +621,6 @@ public class MainUtil {
} }
e.printStackTrace(); } e.printStackTrace(); }
public static String[] getTrace(Throwable e) {
if (e == null) {
return new String[0];
}
StackTraceElement[] elems = e.getStackTrace();
String[] msg = new String[elems.length];//[elems.length + 1];
// HashSet<String> packages = new HashSet<>();
for (int i = 0; i < elems.length; i++) {
StackTraceElement elem = elems[i];
elem.getLineNumber();
String methodName = elem.getMethodName();
int index = elem.getClassName().lastIndexOf('.');
String className = elem.getClassName();
// if (!(index == -1 || className.startsWith("io.netty") || className.startsWith("javax") || className.startsWith("java") || className.startsWith("sun") || className.startsWith("net.minecraft") || className.startsWith("org.spongepowered") || className.startsWith("org.bukkit") || className.startsWith("com.google"))) {
// packages.add(className.substring(0, index-1));
// }
String name = className.substring(index == -1 ? 0 : index + 1);
name = name.length() == 0 ? elem.getClassName() : name;
String argString = "(...)";
try {
for (Method method : Class.forName(elem.getClassName()).getDeclaredMethods()) {
if (method.getName().equals(methodName)) {
Class<?>[] params = method.getParameterTypes();
argString = "";
String prefix = "";
for (Class param : params) {
argString += prefix + param.getSimpleName();
prefix = ",";
}
argString = "[" + method.getReturnType().getSimpleName() + "](" + argString + ")";
break;
}
}
} catch (Throwable ignore) {
}
msg[i] = name + "." + methodName + argString + ":" + elem.getLineNumber();
}
// msg[msg.length-1] = StringMan.getString(packages);
return msg;
}
public static int[] regionNameToCoords(String fileName) { public static int[] regionNameToCoords(String fileName) {
int[] res = new int[2]; int[] res = new int[2];
int len = fileName.length() - 4; int len = fileName.length() - 4;
@ -935,7 +848,7 @@ public class MainUtil {
long age = now - file.lastModified(); long age = now - file.lastModified();
if (age > timeDiff) { if (age > timeDiff) {
pool.submit(file::delete); pool.submit(file::delete);
if (printDebug) BBC.FILE_DELETED.send(null, file); if (printDebug) BBC.FILE_DELETED.send((Player)null, file);
} }
}); });
pool.shutdown(); pool.shutdown();
@ -946,51 +859,4 @@ public class MainUtil {
} }
} }
public enum OS {
LINUX, WINDOWS, MACOS, UNKNOWN;
}
public static File getWorkingDirectory(String applicationName) {
String userHome = System.getProperty("user.home", ".");
File workingDirectory;
switch (getPlatform()) {
case LINUX:
workingDirectory = new File(userHome, '.' + applicationName + '/');
break;
case WINDOWS:
String applicationData = System.getenv("APPDATA");
if (applicationData != null) {
workingDirectory = new File(applicationData, "." + applicationName + '/');
} else {
workingDirectory = new File(userHome, '.' + applicationName + '/');
}
break;
case MACOS:
workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
break;
default:
workingDirectory = new File(userHome, applicationName + '/');
}
if ((!workingDirectory.exists()) && (!workingDirectory.mkdirs())) {
throw new RuntimeException("The working directory could not be created: " + workingDirectory);
}
return workingDirectory;
}
public static OS getPlatform() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
return OS.WINDOWS;
}
if (osName.contains("mac")) {
return OS.MACOS;
}
if (osName.contains("linux")) {
return OS.LINUX;
}
if (osName.contains("unix")) {
return OS.LINUX;
}
return OS.UNKNOWN;
}
} }

View File

@ -57,31 +57,6 @@ public class ReflectionUtils9 {
} }
} }
public static <T extends Enum<?>> void clearEnum(Class<T> enumType) {
// 0. Sanity checks
if (!Enum.class.isAssignableFrom(enumType)) {
throw new RuntimeException("class " + enumType + " is not an instance of Enum");
}
// 1. Lookup "$VALUES" holder in enum class and get previous enum instances
Field valuesField = null;
Field[] fields = enumType.getDeclaredFields();
for (Field field : fields) {
if (field.getName().contains("$VALUES")) {
valuesField = field;
break;
}
}
AccessibleObject.setAccessible(new Field[]{valuesField}, true);
try {
setFailsafeFieldValue(valuesField, null, Array.newInstance(enumType, 0));
// 6. Clean enum cache
cleanEnumCache(enumType);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
}
}
public static Object makeEnum(Class<?> enumClass, String value, int ordinal) throws Exception { public static Object makeEnum(Class<?> enumClass, String value, int ordinal) throws Exception {
Constructor<?> constructor = Unsafe.class.getDeclaredConstructors()[0]; Constructor<?> constructor = Unsafe.class.getDeclaredConstructors()[0];
constructor.setAccessible(true); constructor.setAccessible(true);

View File

@ -44,17 +44,7 @@ import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.FastWorldEditExtent; import com.boydti.fawe.object.extent.*;
import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.object.extent.HeightBoundExtent;
import com.boydti.fawe.object.extent.MultiRegionExtent;
import com.boydti.fawe.object.extent.NullExtent;
import com.boydti.fawe.object.extent.ProcessedWEExtent;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.boydti.fawe.object.extent.SlowExtent;
import com.boydti.fawe.object.extent.SourceMaskExtent;
import com.boydti.fawe.object.extent.StripNBTExtent;
import com.boydti.fawe.object.function.SurfaceRegionFunction; import com.boydti.fawe.object.function.SurfaceRegionFunction;
import com.boydti.fawe.object.mask.ResettableMask; import com.boydti.fawe.object.mask.ResettableMask;
import com.boydti.fawe.object.pattern.ExistingPattern; import com.boydti.fawe.object.pattern.ExistingPattern;
@ -68,6 +58,9 @@ import com.boydti.fawe.util.Perm;
import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.WorldWrapper; import com.boydti.fawe.wrappers.WorldWrapper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
@ -88,17 +81,7 @@ import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.ForestGenerator; import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.*;
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -120,8 +103,8 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException; import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException;
import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.MathUtils;
@ -139,6 +122,9 @@ import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.Regions;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape; import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
import com.sk89q.worldedit.regions.shape.ArbitraryShape; import com.sk89q.worldedit.regions.shape.ArbitraryShape;
import com.sk89q.worldedit.regions.shape.RegionShape; import com.sk89q.worldedit.regions.shape.RegionShape;
@ -150,22 +136,27 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.SimpleWorld; import com.sk89q.worldedit.world.SimpleWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockID;
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.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
/** /**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits, * An {@link Extent} that handles history, {@link BlockBag}s, change limits,
* block re-ordering, and much more. Most operations in WorldEdit use this class. * block re-ordering, and much more. Most operations in WorldEdit use this class.
@ -213,7 +204,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
} }
private final World world; @SuppressWarnings("ProtectedField")
protected final World world;
private String worldName; private String worldName;
private FaweQueue queue; private FaweQueue queue;
private boolean wrapped; private boolean wrapped;
@ -245,7 +237,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
super(world); super(world);
this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName; this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName;
if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName); if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName);
this.world = world; this.world = world;
if (bus == null) { if (bus == null) {
bus = WorldEdit.getInstance().getEventBus(); bus = WorldEdit.getInstance().getEventBus();
} }
@ -650,6 +644,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return changeTask != null ? changeTask : history != null ? history.getChangeSet() : null; return changeTask != null ? changeTask : history != null ? history.getChangeSet() : null;
} }
/**
* Will be removed very soon. Use getChangeSet()
*/
@Deprecated
public FaweChangeSet getChangeTask() { public FaweChangeSet getChangeTask() {
return changeTask; return changeTask;
} }
@ -867,7 +865,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* *
* @param enabled true to enable * @param enabled true to enable
*/ */
public void setFastMode(final boolean enabled) { public void setFastMode(boolean enabled) {
this.fastMode = enabled; this.fastMode = enabled;
disableHistory(enabled); disableHistory(enabled);
} }
@ -1004,6 +1002,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
/** /**
* Disable all buffering extents. * Disable all buffering extents.
* *
* @see #setReorderMode(ReorderMode)
* @see #setBatchingChunks(boolean) * @see #setBatchingChunks(boolean)
*/ */
public void disableBuffering() { public void disableBuffering() {
@ -1021,12 +1020,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
@Override @Override
public BiomeType getBiome(final BlockVector2 position) { public BiomeType getBiome(BlockVector2 position) {
return this.extent.getBiome(position); return this.extent.getBiome(position);
} }
@Override @Override
public boolean setBiome(final BlockVector2 position, final BiomeType biome) { public boolean setBiome(BlockVector2 position, BiomeType biome) {
this.changes++; this.changes++;
return this.extent.setBiome(position, biome); return this.extent.setBiome(position, biome);
} }
@ -1272,19 +1271,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public boolean setBlockIfAir(final BlockVector3 position, final BlockStateHolder block) throws MaxChangedBlocksException { public boolean setBlockIfAir(final BlockVector3 position, final BlockStateHolder block) throws MaxChangedBlocksException {
return this.getBlock(position).getBlockType().getMaterial().isAir() && this.setBlock(position, block); return this.getBlock(position).getBlockType().getMaterial().isAir() && this.setBlock(position, block);
} }
// private int setBlocks(Set<BlockVector3> vset, Pattern pattern) throws MaxChangedBlocksException {
// int affected = 0;
// for (BlockVector3 v : vset) {
// affected += setBlock(v, pattern) ? 1 : 0;
// }
// return affected;
// }
@Override @Override
@Nullable @Nullable
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) { public Entity createEntity(com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
Entity result = this.extent.createEntity(location, entity); return this.extent.createEntity(location, entity);
return result;
} }
/** /**
@ -1615,7 +1606,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
MaskIntersection mask = new MaskIntersection( MaskIntersection mask = new MaskIntersection(
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
new BoundedHeightMask( new BoundedHeightMask(
Math.max((origin.getBlockY() - depth) + 1, getMinimumPoint().getBlockY()), Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())), Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())),
Masks.negate(new ExistingBlockMask(this))); Masks.negate(new ExistingBlockMask(this)));
@ -1735,6 +1726,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return wrapped || getMask() != null || getSourceMask() != null || history != null; return wrapped || getMask() != null || getSourceMask() != null || history != null;
} }
/**
* Remove blocks of a certain type nearby a given position.
*
* @param position center position of cuboid
* @param blockType the block type to match
* @param apothem an apothem of the cuboid, where the minimum is 1
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException { public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
checkNotNull(position); checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1"); checkArgument(apothem >= 1, "apothem >= 1");
@ -1800,8 +1800,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (pattern instanceof BlockStateHolder) { if (pattern instanceof BlockStateHolder) {
return setBlocks(region, (BlockStateHolder) pattern); return setBlocks(region, (BlockStateHolder) pattern);
} }
final BlockReplace replace = new BlockReplace(EditSession.this, pattern); BlockReplace replace = new BlockReplace(this, pattern);
final RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null); RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected(); return this.changes = visitor.getAffected();
} }
@ -2002,6 +2002,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
*/ */
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException { public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block); checkNotNull(block);
return overlayCuboidBlocks(region, new BlockPattern(block)); return overlayCuboidBlocks(region, new BlockPattern(block));
} }
@ -2017,6 +2018,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
checkNotNull(region); checkNotNull(region);
checkNotNull(pattern); checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern); BlockReplace replace = new BlockReplace(this, pattern);
RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace); RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
int minY = region.getMinimumPoint().getBlockY(); int minY = region.getMinimumPoint().getBlockY();
@ -2045,10 +2047,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return this.changes = naturalizer.getAffected(); return this.changes = naturalizer.getAffected();
} }
public int stackCuboidRegion(final Region region, final BlockVector3 dir, final int count, final boolean copyAir) {
return stackCuboidRegion(region, dir, count, copyAir, true, false);
}
/** /**
* Stack a cuboid region. * Stack a cuboid region.
* *
@ -2063,6 +2061,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
checkNotNull(region); checkNotNull(region);
checkNotNull(dir); checkNotNull(dir);
checkArgument(count >= 1, "count >= 1 required"); checkArgument(count >= 1, "count >= 1 required");
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
BlockVector3 to = region.getMinimumPoint(); BlockVector3 to = region.getMinimumPoint();
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to); ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
@ -2094,22 +2093,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return number of blocks moved * @return number of blocks moved
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException { public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, boolean copyEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException {
return moveRegion(region, dir, distance, copyAir, true, false, replacement);
}
public int moveRegion(final Region region, final BlockVector3 dir, final int distance, final boolean copyAir, final boolean copyEntities, final boolean copyBiomes, BlockStateHolder replacement) {
return moveRegion(region, dir, distance, copyAir, copyEntities, copyBiomes, (Pattern) replacement);
}
public int moveRegion(final Region region, final BlockVector3 dir, final int distance, final boolean copyAir, final boolean copyEntities, final boolean copyBiomes, Pattern replacement) {
checkNotNull(region); checkNotNull(region);
checkNotNull(dir); checkNotNull(dir);
checkArgument(distance >= 1, "distance >= 1 required"); checkArgument(distance >= 1, "distance >= 1 required");
final BlockVector3 displace = dir.multiply(distance); BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
final BlockVector3 displace = dir.multiply(distance);
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
final BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
BlockVector3 disAbs = displace.abs(); BlockVector3 disAbs = displace.abs();
@ -2122,10 +2113,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState(); if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement); final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
copy.setCopyBiomes(copyBiomes); copy.setCopyBiomes(copyBiomes);
copy.setCopyingEntities(copyEntities); copy.setCopyingEntities(copyEntities);
copy.setSourceFunction(remove); copy.setSourceFunction(remove); // Remove
copy.setRemovingEntities(true);
copy.setRepetitions(1); copy.setRepetitions(1);
Mask sourceMask = getSourceMask(); Mask sourceMask = getSourceMask();
if (sourceMask != null) { if (sourceMask != null) {
@ -2179,6 +2170,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException { public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException {
checkNotNull(origin); checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required"); checkArgument(radius >= 0, "radius >= 0 required");
Mask liquidMask; Mask liquidMask;
// Not thread safe, use hardcoded liquidmask // Not thread safe, use hardcoded liquidmask
// if (getWorld() != null) { // if (getWorld() != null) {
@ -2188,9 +2180,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER); liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
MaskIntersection mask = new MaskIntersection( MaskIntersection mask = new MaskIntersection(
new BoundedHeightMask(0, getWorld().getMaxY()), new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask( new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
new EllipsoidRegion(null, origin, liquidMask);
Vector3.at(radius, radius, radius))), liquidMask);
BlockReplace replace; BlockReplace replace;
if (waterlogged) { if (waterlogged) {
replace = new BlockReplace(this, new WaterloggedRemover(this)); replace = new BlockReplace(this, new WaterloggedRemover(this));
@ -2207,6 +2198,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
return this.changes = visitor.getAffected(); return this.changes = visitor.getAffected();
} }
@ -2287,11 +2279,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
private int makeCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness, final boolean filled) { private int makeCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness, final boolean filled) {
int affected = 0;
radiusX += 0.5; radiusX += 0.5;
radiusZ += 0.5; radiusZ += 0.5;
MutableBlockVector3 posv = new MutableBlockVector3(pos); MutableBlockVector3 posv = new MutableBlockVector3(pos);
if (height == 0) { if (height == 0) {
return this.changes; return 0;
} else if (height < 0) { } else if (height < 0) {
height = -height; height = -height;
posv.mutY(posv.getY() - height); posv.mutY(posv.getY() - height);
@ -2320,8 +2315,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
double nextMinXn = 0; double nextMinXn = 0;
final double minInvRadiusX = 1 / (radiusX - thickness); final double minInvRadiusX = 1 / (radiusX - thickness);
final double minInvRadiusZ = 1 / (radiusZ - thickness); final double minInvRadiusZ = 1 / (radiusZ - thickness);
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
double dx2 = nextMinXn * nextMinXn; double dx2 = nextMinXn * nextMinXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
@ -2329,8 +2323,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
double nextZn = 0; double nextZn = 0;
double nextMinZn = 0; double nextMinZn = 0;
dx = xn * xn; dx = xn * xn;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
double dz2 = nextMinZn * nextMinZn; double dz2 = nextMinZn * nextMinZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
@ -2357,14 +2350,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
} }
} else { } else {
forX: forX: for (int x = 0; x <= ceilRadiusX; ++x) {
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextZn = 0; double nextZn = 0;
dx = xn * xn; dx = xn * xn;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
dz = zn * zn; dz = zn * zn;
@ -2509,6 +2500,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException { public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
radiusX += 0.5; radiusX += 0.5;
radiusY += 0.5; radiusY += 0.5;
radiusZ += 0.5; radiusZ += 0.5;
@ -2526,26 +2519,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = invRadiusX; double nextXn = invRadiusX;
double dx, dy, dz, dxz, dxyz; forX: for (int x = 0; x <= ceilRadiusX; ++x) {
forX:
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn; final double xn = nextXn;
dx = xn * xn; double dx = xn * xn;
nextXn = (x + 1) * invRadiusX; nextXn = (x + 1) * invRadiusX;
double nextZn = invRadiusZ; double nextZn = invRadiusZ;
forZ: forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
for (int z = 0; z <= ceilRadiusZ; ++z) {
final double zn = nextZn; final double zn = nextZn;
dz = zn * zn; double dz = zn * zn;
dxz = dx + dz; double dxz = dx + dz;
nextZn = (z + 1) * invRadiusZ; nextZn = (z + 1) * invRadiusZ;
double nextYn = invRadiusY; double nextYn = invRadiusY;
forY: forY: for (int y = 0; y <= ceilRadiusY; ++y) {
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn; final double yn = nextYn;
dy = yn * yn; double dy = yn * yn;
dxyz = dxz + dy; double dxyz = dxz + dy;
nextYn = (y + 1) * invRadiusY; nextYn = (y + 1) * invRadiusY;
if (dxyz > 1) { if (dxyz > 1) {
@ -2783,13 +2772,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (block.getBlockType() == BlockTypes.DIRT || if (block.getBlockType() == BlockTypes.DIRT ||
(!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) { (!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
if (setBlock(pt, grass)) { if (setBlock(pt, grass)) {
break loop; break;
} }
break; break;
} else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) { } else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) {
break loop; break;
} else if (block.getBlockType().getMaterial().isMovementBlocker()) { } else if (block.getBlockType().getMaterial().isMovementBlocker()) {
break loop; break;
} }
} }
} }

View File

@ -35,6 +35,7 @@ import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.ImgurUtility; import com.boydti.fawe.util.ImgurUtility;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandException;
@ -85,9 +86,11 @@ import java.util.Set;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
/** /**
* Clipboard commands. * Clipboard commands.
*/ */
@ -101,9 +104,9 @@ public class ClipboardCommands extends MethodCommands {
*/ */
public ClipboardCommands(WorldEdit worldEdit) { public ClipboardCommands(WorldEdit worldEdit) {
super(worldEdit); super(worldEdit);
checkNotNull(worldEdit);
} }
@Command( @Command(
aliases = { "/lazycopy" }, aliases = { "/lazycopy" },
flags = "em", flags = "em",
@ -455,6 +458,7 @@ public class ClipboardCommands extends MethodCommands {
@Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin, @Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
@Switch('b') boolean ignoreBiomes, @Switch('e') boolean ignoreEntities, @Switch('b') boolean ignoreBiomes, @Switch('e') boolean ignoreEntities,
@Switch('s') boolean selectPasted) throws WorldEditException { @Switch('s') boolean selectPasted) throws WorldEditException {
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) { if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
place(player, session, editSession, ignoreAirBlocks, atOrigin, selectPasted); place(player, session, editSession, ignoreAirBlocks, atOrigin, selectPasted);
@ -462,6 +466,7 @@ public class ClipboardCommands extends MethodCommands {
} }
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
Region region = clipboard.getRegion(); Region region = clipboard.getRegion();
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
checkPaste(player, editSession, to, holder, clipboard); checkPaste(player, editSession, to, holder, clipboard);
Operation operation = holder Operation operation = holder
@ -594,6 +599,4 @@ public class ClipboardCommands extends MethodCommands {
session.setClipboard(null); session.setClipboard(null);
BBC.CLIPBOARD_CLEARED.send(player); BBC.CLIPBOARD_CLEARED.send(player);
} }
} }

View File

@ -20,10 +20,15 @@
package com.sk89q.worldedit.command.composition; package com.sk89q.worldedit.command.composition;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.*; import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.extent.FaweRegionExtent; import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.minecraft.util.commands.CommandLocals;
@ -52,8 +57,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public class SelectionCommand extends SimpleCommand<Operation> { public class SelectionCommand extends SimpleCommand<Operation> {
private final CommandExecutor<Contextual<? extends Operation>> delegate; private final CommandExecutor<Contextual<? extends Operation>> delegate;
@ -116,11 +119,6 @@ public class SelectionCommand extends SimpleCommand<Operation> {
fc.fillCuboid(0, 15, minY, maxY, 0, 15, block.getInternalId()); fc.fillCuboid(0, 15, minY, maxY, 0, 15, block.getInternalId());
fc.optimize(); fc.optimize();
int bcx = (current.minX) >> 4;
int bcz = (current.minZ) >> 4;
int tcx = (current.maxX) >> 4;
int tcz = (current.maxZ) >> 4;
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge] // [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() { MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() {
@Override @Override
@ -181,7 +179,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
} }
@Override @Override
public boolean testPermission0(CommandLocals locals) { protected boolean testPermission0(CommandLocals locals) {
return locals.get(Actor.class).hasPermission(permission); return locals.get(Actor.class).hasPermission(permission);
} }

View File

@ -19,18 +19,17 @@
package com.sk89q.worldedit.extension.factory.parser; package com.sk89q.worldedit.extension.factory.parser;
import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.JSON2NBT;
import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.jnbt.NBTException;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.MobSpawnerBlock; import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.SignBlock;
import com.sk89q.worldedit.blocks.SkullBlock; import com.sk89q.worldedit.blocks.SkullBlock;
@ -42,9 +41,6 @@ import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
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.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
@ -59,9 +55,6 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* Parses block input strings. * Parses block input strings.
@ -163,11 +156,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException { private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
BlockType blockType = null;
String[] blockAndExtraData = input.trim().split("\\|", 2); String[] blockAndExtraData = input.trim().split("\\|", 2);
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]); blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
BlockState state = null; BlockState state = null;
CompoundTag nbt = null;
// Legacy matcher // Legacy matcher
if (context.isTryingLegacy()) { if (context.isTryingLegacy()) {
@ -196,6 +189,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
} }
CompoundTag nbt = null;
if (state == null) { if (state == null) {
String typeString; String typeString;
String stateString = null; String stateString = null;
@ -209,14 +203,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (typeString == null || typeString.isEmpty()) { if (typeString == null || typeString.isEmpty()) {
throw new InputParseException("Invalid format"); throw new InputParseException("Invalid format");
} }
// PosX String[] stateProperties = EMPTY_STRING_ARRAY;
if (typeString.matches("pos[0-9]+")) { if (typeString.matches("pos[0-9]+")) {
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", "")); int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
// Get the block type from the "primary position" // Get the block type from the "primary position"
final World world = context.requireWorld(); final World world = context.requireWorld();
final BlockVector3 primaryPosition; final BlockVector3 primaryPosition;
try { try {
primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1); primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
throw new InputParseException("Your selection is not complete."); throw new InputParseException("Your selection is not complete.");
} }
@ -227,33 +221,15 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} else if ("offhand".equalsIgnoreCase(typeString)) { } else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand. // Get the block type from the item in the user's off hand.
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND); state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
} else if (typeString.matches("slot[0-9]+")) {
int slot = Integer.parseInt(typeString.substring(4)) - 1;
Actor actor = context.requireActor();
if (!(actor instanceof Player)) {
throw new InputParseException("The user is not a player!");
}
Player player = (Player) actor;
BlockBag bag = player.getInventoryBlockBag();
if (bag == null || !(bag instanceof SlottableBlockBag)) {
throw new InputParseException("Unsupported!");
}
SlottableBlockBag slottable = (SlottableBlockBag) bag;
BaseItem item = slottable.getItem(slot);
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else { } else {
// Attempt to lookup a block from ID or name.
BlockType type = BlockTypes.parse(typeString.toLowerCase()); BlockType type = BlockTypes.parse(typeString.toLowerCase());
if (type != null) state = type.getDefaultState();
if (state == null) { if (type == null) {
throw new NoMatchException("Does not match a valid block type: '" + input + "'"); throw new NoMatchException("Does not match a valid block type: '" + input + "'");
} }
} }
if (nbt == null) nbt = state.getNbtData(); nbt = state.getNbtData();
if (stateString != null) { if (stateString != null) {
state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state); state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state);
@ -288,7 +264,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
// Check if the item is allowed // Check if the item is allowed
BlockType blockType = state.getBlockType(); blockType = state.getBlockType();
if (context.isRestricted()) {
Actor actor = context.requireActor();
if (actor != null && !actor.hasPermission("worldedit.anyblock")
&& worldEdit.getConfiguration().checkDisallowedBlocks(state)) {
throw new DisallowedUsageException("You are not allowed to use '" + input + "'");
}
}
if (nbt != null) return validate(context, state.toBaseBlock(nbt)); if (nbt != null) return validate(context, state.toBaseBlock(nbt));
@ -299,7 +282,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : ""; text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : ""; text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : ""; text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
return validate(context, new SignBlock(state, text)); return new SignBlock(state, text);
} else if (blockType == BlockTypes.SPAWNER) { } else if (blockType == BlockTypes.SPAWNER) {
// Allow setting mob spawn type // Allow setting mob spawn type
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
@ -311,27 +294,23 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
} }
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) { if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
final String finalMobName = mobName.toLowerCase(); throw new NoMatchException("Unknown mob type '" + mobName + "'");
throw new SuggestInputParseException("Unknown mob type '" + mobName + "'", mobName, () -> Stream.of(MobType.values())
.map(m -> m.getName().toLowerCase())
.filter(s -> s.startsWith(finalMobName))
.collect(Collectors.toList()));
} }
return validate(context, new MobSpawnerBlock(state, mobName)); return new MobSpawnerBlock(state, mobName);
} else { } else {
return validate(context, new MobSpawnerBlock(state, MobType.PIG.getName())); return new MobSpawnerBlock(state, MobType.PIG.getName());
} }
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) { } else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
// allow setting type/player/rotation // allow setting type/player/rotation
if (blockAndExtraData.length <= 1) { if (blockAndExtraData.length <= 1) {
return validate(context, new SkullBlock(state)); return new SkullBlock(state);
} }
String type = blockAndExtraData[1]; String type = blockAndExtraData[1];
return validate(context, new SkullBlock(state, type.replace(" ", "_"))); // valid MC usernames return new SkullBlock(state, type.replace(" ", "_")); // valid MC usernames
} else { } else {
return validate(context, state.toBaseBlock()); return state.toBaseBlock();
} }
} }

View File

@ -1,17 +0,0 @@
package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.blocks.BaseItem;
public interface SlottableBlockBag {
BaseItem getItem(int slot);
void setItem(int slot, BaseItem block);
default int size() {
return 36;
}
default int getSelectedSlot() {
return -1;
}
}

View File

@ -24,16 +24,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collection;
import java.util.List;
/** /**
* Executes several region functions in order. * Executes several region functions in order.
*/ */
public class CombinedRegionFunction implements RegionFunction { public class CombinedRegionFunction implements RegionFunction {
private RegionFunction[] functions; private final List<RegionFunction> functions = new ArrayList<>();
/** /**
* Create a combined region function. * Create a combined region function.
@ -48,8 +49,7 @@ public class CombinedRegionFunction implements RegionFunction {
*/ */
public CombinedRegionFunction(Collection<RegionFunction> functions) { public CombinedRegionFunction(Collection<RegionFunction> functions) {
checkNotNull(functions); checkNotNull(functions);
this.functions = functions.toArray(new RegionFunction[functions.size()]); this.functions.addAll(functions);
} }
/** /**
@ -58,7 +58,7 @@ public class CombinedRegionFunction implements RegionFunction {
* @param function an array of functions to match * @param function an array of functions to match
*/ */
public CombinedRegionFunction(RegionFunction... function) { public CombinedRegionFunction(RegionFunction... function) {
this.functions = function; this(Arrays.asList(checkNotNull(function)));
} }
public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) { public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) {
@ -82,9 +82,7 @@ public class CombinedRegionFunction implements RegionFunction {
*/ */
public void add(Collection<RegionFunction> functions) { public void add(Collection<RegionFunction> functions) {
checkNotNull(functions); checkNotNull(functions);
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions)); this.functions.addAll(functions);
functionsList.addAll(functions);
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
} }
/** /**
@ -107,6 +105,4 @@ public class CombinedRegionFunction implements RegionFunction {
return ret; return ret;
} }
} }

View File

@ -19,17 +19,14 @@
package com.sk89q.worldedit.function; package com.sk89q.worldedit.function;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector)} to the * Passes calls to {@link #apply(BlockVector3)} to the
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they * delegate {@link RegionFunction} if they
* match the given mask. * match the given mask.
*/ */
public class RegionMaskTestFunction implements RegionFunction { public class RegionMaskTestFunction implements RegionFunction {
@ -41,7 +38,7 @@ public class RegionMaskTestFunction implements RegionFunction {
* Create a new masking filter. * Create a new masking filter.
* *
* @param mask the mask * @param mask the mask
* @param function the function * @param failure the function
*/ */
public RegionMaskTestFunction(Mask mask, RegionFunction success, RegionFunction failure) { public RegionMaskTestFunction(Mask mask, RegionFunction success, RegionFunction failure) {
checkNotNull(success); checkNotNull(success);

View File

@ -53,6 +53,4 @@ public class BlockReplace implements RegionFunction {
return pattern.apply(extent, position, position); return pattern.apply(extent, position, position);
} }
} }

View File

@ -19,13 +19,9 @@
package com.sk89q.worldedit.function.block; package com.sk89q.worldedit.function.block;
import com.boydti.fawe.util.ReflectionUtils; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.jnbt.CompoundTagBuilder;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -36,8 +32,6 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Direction.Flag; import com.sk89q.worldedit.util.Direction.Flag;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
/** /**
@ -75,11 +69,13 @@ public class ExtentBlockCopy implements RegionFunction {
@Override @Override
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
BaseBlock block = source.getFullBlock(position);
BlockVector3 orig = position.subtract(from); BlockVector3 orig = position.subtract(from);
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint(); BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
// Apply transformations to NBT data if necessary // Apply transformations to NBT data if necessary
BaseBlock block = transformNbtData(source.getFullBlock(position)); block = transformNbtData(block);
return destination.setBlock(transformed.add(to), block); return destination.setBlock(transformed.add(to), block);
} }
@ -118,6 +114,4 @@ public class ExtentBlockCopy implements RegionFunction {
return state; return state;
} }
} }

View File

@ -19,21 +19,16 @@
package com.sk89q.worldedit.function.block; package com.sk89q.worldedit.function.block;
import com.google.common.collect.Sets; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
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.function.LayerFunction; import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Makes a layer of grass on top, three layers of dirt below, and smooth stone * Makes a layer of grass on top, three layers of dirt below, and smooth stone
* only below that for all layers that originally consist of grass, dirt, * only below that for all layers that originally consist of grass, dirt,
@ -76,15 +71,15 @@ public class Naturalizer implements LayerFunction {
affected++; affected++;
switch (depth) { switch (depth) {
case 0: case 0:
editSession.setBlock(position, BlockTypes.GRASS_BLOCK); editSession.setBlock(position, BlockTypes.GRASS_BLOCK.getDefaultState());
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
editSession.setBlock(position, BlockTypes.DIRT); editSession.setBlock(position, BlockTypes.DIRT.getDefaultState());
break; break;
default: default:
editSession.setBlock(position, BlockTypes.STONE); editSession.setBlock(position, BlockTypes.STONE.getDefaultState());
} }
} }

View File

@ -20,13 +20,15 @@
package com.sk89q.worldedit.function.entity; package com.sk89q.worldedit.function.entity;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.FloatTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.jnbt.CompoundTagBuilder;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -38,14 +40,12 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Direction.Flag; import com.sk89q.worldedit.util.Direction.Flag;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.entity.EntityTypes;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Copies entities provided to the function to the provided destination * Copies entities provided to the function to the provided destination
* {@code Extent}. * {@code Extent}.
@ -103,7 +103,7 @@ public class ExtentEntityCopy implements EntityFunction {
Location location = entity.getLocation(); Location location = entity.getLocation();
Vector3 pivot = from.round().add(0.5, 0.5, 0.5); Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
Vector3 newPosition = transform.apply(location.subtract(pivot)); Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
Vector3 newDirection; Vector3 newDirection;
newDirection = transform.isIdentity() ? newDirection = transform.isIdentity() ?
@ -111,12 +111,13 @@ public class ExtentEntityCopy implements EntityFunction {
: transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize(); : transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize();
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
// Some entities store their position data in NBT
state = transformNbtData(state); state = transformNbtData(state);
boolean success = destination.createEntity(newLocation, state) != null; boolean success = destination.createEntity(newLocation, state) != null;
// Remove // Remove
if (isRemoving()) { if (isRemoving() && success) {
entity.remove(); entity.remove();
} }
@ -135,6 +136,7 @@ public class ExtentEntityCopy implements EntityFunction {
*/ */
private BaseEntity transformNbtData(BaseEntity state) { private BaseEntity transformNbtData(BaseEntity state) {
CompoundTag tag = state.getNbtData(); CompoundTag tag = state.getNbtData();
if (tag != null) { if (tag != null) {
boolean changed = false; boolean changed = false;
// Handle hanging entities (paintings, item frames, etc.) // Handle hanging entities (paintings, item frames, etc.)
@ -205,6 +207,4 @@ public class ExtentEntityCopy implements EntityFunction {
return state; return state;
} }
} }

View File

@ -19,6 +19,12 @@
package com.sk89q.worldedit.function.factory; package com.sk89q.worldedit.function.factory;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.Contextual;
@ -33,10 +39,6 @@ import com.sk89q.worldedit.math.noise.RandomNoise;
import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.NullRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.*;
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
public class Paint implements Contextual<Operation> { public class Paint implements Contextual<Operation> {
private final Extent destination; private final Extent destination;

View File

@ -25,7 +25,6 @@ import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -84,9 +83,9 @@ public class FloraGenerator implements RegionFunction {
*/ */
public static Pattern getDesertPattern() { public static Pattern getDesertPattern() {
RandomPattern pattern = new RandomPattern(); RandomPattern pattern = new RandomPattern();
pattern.add((BlockTypes.DEAD_BUSH.getDefaultState()), 30); pattern.add(new BlockPattern(BlockTypes.DEAD_BUSH.getDefaultState()), 30);
pattern.add((BlockTypes.CACTUS.getDefaultState()), 20); pattern.add(new BlockPattern(BlockTypes.CACTUS.getDefaultState()), 20);
pattern.add((BlockTypes.AIR.getDefaultState()), 300); pattern.add(new BlockPattern(BlockTypes.AIR.getDefaultState()), 300);
return pattern; return pattern;
} }
@ -97,9 +96,9 @@ public class FloraGenerator implements RegionFunction {
*/ */
public static Pattern getTemperatePattern() { public static Pattern getTemperatePattern() {
RandomPattern pattern = new RandomPattern(); RandomPattern pattern = new RandomPattern();
pattern.add((BlockTypes.GRASS.getDefaultState()), 300); pattern.add(new BlockPattern(BlockTypes.GRASS.getDefaultState()), 300);
pattern.add((BlockTypes.POPPY.getDefaultState()), 5); pattern.add(new BlockPattern(BlockTypes.POPPY.getDefaultState()), 5);
pattern.add((BlockTypes.DANDELION.getDefaultState()), 5); pattern.add(new BlockPattern(BlockTypes.DANDELION.getDefaultState()), 5);
return pattern; return pattern;
} }

View File

@ -24,7 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -53,15 +52,12 @@ public class ForestGenerator implements RegionFunction {
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
BlockState block = editSession.getBlock(position); BlockState block = editSession.getBlock(position);
BlockType t = block.getBlockType(); BlockType t = block.getBlockType();
switch (t.getInternalId()) {
case BlockID.GRASS_BLOCK: if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
case BlockID.DIRT: return treeType.generate(editSession, position.add(0, 1, 0));
treeType.generate(editSession, position.add(0, 1, 0)); } else if (t.getMaterial().isReplacedDuringPlacement()) {
return true; // since the implementation's tree generators generally don't generate in non-air spots,
case BlockID.TALL_GRASS: // TODO: This list needs to be moved // we trick editsession history here in the first call
case BlockID.DEAD_BUSH:
case BlockID.POPPY:
case BlockID.DANDELION:
editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
// and then trick the generator here by directly setting into the world // and then trick the generator here by directly setting into the world
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
@ -71,7 +67,7 @@ public class ForestGenerator implements RegionFunction {
editSession.setBlock(position, block); // restore on failure editSession.setBlock(position, block); // restore on failure
} }
return success; return success;
default: // Trees won't grow on this! } else { // Trees won't grow on this!
return false; return false;
} }
} }

View File

@ -104,7 +104,7 @@ public class GardenPatchGenerator implements RegionFunction {
int h = random.nextInt(3) - 1; int h = random.nextInt(3) - 1;
BlockVector3 p; BlockVector3 p;
BlockStateHolder log = BlockTypes.OAK_LOG.getDefaultState(); BlockState log = BlockTypes.OAK_LOG.getDefaultState();
switch (t) { switch (t) {
case 0: case 0:
@ -167,7 +167,7 @@ public class GardenPatchGenerator implements RegionFunction {
return false; return false;
} }
BlockStateHolder leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState(); BlockState leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState();
if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) { if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
editSession.setBlock(position, leavesBlock); editSession.setBlock(position, leavesBlock);
@ -187,7 +187,7 @@ public class GardenPatchGenerator implements RegionFunction {
* @return a pumpkin pattern * @return a pumpkin pattern
*/ */
public static Pattern getPumpkinPattern() { public static Pattern getPumpkinPattern() {
return BlockTypes.PUMPKIN.getDefaultState(); return new BlockPattern(BlockTypes.PUMPKIN.getDefaultState());
} }
/** /**
@ -208,6 +208,6 @@ public class GardenPatchGenerator implements RegionFunction {
* @return a melon pattern * @return a melon pattern
*/ */
public static Pattern getMelonPattern() { public static Pattern getMelonPattern() {
return (BlockTypes.MELON.getDefaultState()); return new BlockPattern(BlockTypes.MELON.getDefaultState());
} }
} }

View File

@ -1,7 +1,28 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.object.collection.FastBitSet; import com.boydti.fawe.object.collection.FastBitSet;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -32,16 +53,31 @@ public class BlockMask extends AbstractExtentMask {
private final long[][] bitSets; private final long[][] bitSets;
protected final static long[] ALL = new long[0]; protected final static long[] ALL = new long[0];
/**
* Create a new block mask.
*
* @param extent the extent
* @param blocks a list of blocks to match
*/
@Deprecated @Deprecated
public BlockMask(Extent extent, Collection<BaseBlock> blocks) { public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
super(extent); super(extent);
checkNotNull(blocks);
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits(); this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
} }
/**
* Create a new block mask.
*
* @param extent the extent
* @param block an array of blocks to match
*/
@Deprecated @Deprecated
public BlockMask(Extent extent, BaseBlock... blocks) { public BlockMask(Extent extent, BaseBlock... block) {
super(extent); super(extent);
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits(); checkNotNull(block);
this.bitSets = new BlockMaskBuilder().addBlocks(block).optimize().getBits();
} }
public BlockMask() { public BlockMask() {
@ -236,5 +272,4 @@ public class BlockMask extends AbstractExtentMask {
return null; return null;
} }
} }

View File

@ -1,20 +1,43 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable; /**
* A mask that checks whether blocks at the given positions are matched by
import static com.google.common.base.Preconditions.checkNotNull; * a block in a list.
*
* <p>This mask checks for ONLY the block type. If state should also be checked,
* use {@link BlockMask}.</p>
*/
public class BlockTypeMask extends AbstractExtentMask { public class BlockTypeMask extends AbstractExtentMask {
private final boolean[] types; private final boolean[] types;
@ -57,12 +80,10 @@ public class BlockTypeMask extends AbstractExtentMask {
/** /**
* Add the given blocks to the list of criteria. * Add the given blocks to the list of criteria.
* *
* @param blocks an array of blocks * @param block an array of blocks
*/ */
public void add(BlockType... blocks) { public void add(BlockType... block) {
for (BlockType type : blocks) { add(Arrays.asList(checkNotNull(block)));
this.types[type.getInternalId()] = true;
}
} }
/** /**

View File

@ -73,7 +73,12 @@ public class ExpressionMask extends AbstractMask {
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) { if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
} }
if (timeout == null) {
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0; return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
} else {
return expression.evaluate(new double[]{vector.getX(), vector.getY(), vector.getZ()},
timeout.getAsInt()) > 0;
}
} catch (EvaluationException e) { } catch (EvaluationException e) {
return false; return false;
} }

View File

@ -19,14 +19,23 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Combines several masks and requires that all masks return true * Combines several masks and requires that all masks return true
@ -177,6 +186,7 @@ public class MaskIntersection extends AbstractMask {
return false; return false;
} }
} }
return true; return true;
} }
@ -194,4 +204,5 @@ public class MaskIntersection extends AbstractMask {
} }
return new MaskIntersection2D(mask2dList); return new MaskIntersection2D(mask2dList);
} }
} }

View File

@ -18,13 +18,13 @@
*/ */
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Various utility functions related to {@link Mask} and {@link Mask2D}. * Various utility functions related to {@link Mask} and {@link Mask2D}.
*/ */

View File

@ -1,3 +1,22 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -6,9 +25,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Checks whether another mask tests true for a position that is offset * Checks whether another mask tests true for a position that is offset
* a given vector. * a given vector.
@ -85,5 +101,4 @@ public class OffsetMask extends AbstractMask {
} }
} }
} }

View File

@ -1,10 +1,28 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -22,6 +40,7 @@ public class SolidBlockMask extends BlockTypeMask {
public SolidBlockMask(Extent extent) { public SolidBlockMask(Extent extent) {
super(extent, getTypes()); super(extent, getTypes());
} }
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(BlockVector3 vector) {
Extent extent = getExtent(); Extent extent = getExtent();
@ -35,5 +54,4 @@ public class SolidBlockMask extends BlockTypeMask {
return null; return null;
} }
} }

View File

@ -20,17 +20,18 @@
package com.sk89q.worldedit.function.operation; package com.sk89q.worldedit.function.operation;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Performs an undo or redo from a given {@link ChangeSet}. * Performs an undo or redo from a given {@link ChangeSet}.
*/ */
@ -53,6 +54,7 @@ public class ChangeSetExecutor implements Operation {
checkNotNull(changeSet); checkNotNull(changeSet);
checkNotNull(type); checkNotNull(type);
checkNotNull(context); checkNotNull(context);
this.type = type; this.type = type;
this.context = context; this.context = context;
if (changeSet instanceof FaweChangeSet) { if (changeSet instanceof FaweChangeSet) {
@ -66,15 +68,15 @@ public class ChangeSetExecutor implements Operation {
@Override @Override
public Operation resume(RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
while (iterator.hasNext()) {
Change change = iterator.next();
if (type == Type.UNDO) { if (type == Type.UNDO) {
while (iterator.hasNext()) { change.undo(context);
iterator.next().undo(context);
}
} else { } else {
while (iterator.hasNext()) { change.redo(context);
iterator.next().redo(context);
} }
} }
return null; return null;
} }
@ -114,5 +116,4 @@ public class ChangeSetExecutor implements Operation {
return new ChangeSetExecutor(changeSet, Type.REDO, context, null, 0); return new ChangeSetExecutor(changeSet, Type.REDO, context, null, 0);
} }
} }

View File

@ -27,14 +27,11 @@ import com.boydti.fawe.object.function.block.BiomeCopy;
import com.boydti.fawe.object.function.block.CombinedBlockCopy; import com.boydti.fawe.object.function.block.CombinedBlockCopy;
import com.boydti.fawe.object.function.block.SimpleBlockCopy; import com.boydti.fawe.object.function.block.SimpleBlockCopy;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import com.google.common.base.Predicate;
import com.sk89q.worldedit.EditSession;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
@ -42,32 +39,26 @@ import com.sk89q.worldedit.function.CombinedRegionFunction;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.RegionMaskTestFunction; import com.sk89q.worldedit.function.RegionMaskTestFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter; import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.ExtentBlockCopy;
import com.sk89q.worldedit.function.entity.ExtentEntityCopy; import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.visitor.EntityVisitor; import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction; import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Identity; import com.sk89q.worldedit.math.transform.Identity;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Makes a copy of a portion of one extent to another extent or another point. * Makes a copy of a portion of one extent to another extent or another point.
* <p> *
* <p>This is a forward extent copy, meaning that it iterates over the blocks * <p>This is a forward extent copy, meaning that it iterates over the blocks
* in the source extent, and will copy as many blocks as there are in the * in the source extent, and will copy as many blocks as there are in the
* source. Therefore, interpolation will not occur to fill in the gaps.</p> * source. Therefore, interpolation will not occur to fill in the gaps.</p>
@ -82,11 +73,11 @@ public class ForwardExtentCopy implements Operation {
private int repetitions = 1; private int repetitions = 1;
private Mask sourceMask = Masks.alwaysTrue(); private Mask sourceMask = Masks.alwaysTrue();
private boolean removingEntities; private boolean removingEntities;
private boolean copyingEntities = true; // default to true for backwards compatibility, sort of
private RegionFunction sourceFunction = null; private RegionFunction sourceFunction = null;
private Transform transform = new Identity(); private Transform transform = new Identity();
private Transform currentTransform = null; private Transform currentTransform = null;
private int affected; private int affected;
private boolean copyEntities = true;
private boolean copyBiomes = false; private boolean copyBiomes = false;
private RegionFunction filterFunction; private RegionFunction filterFunction;
@ -128,7 +119,7 @@ public class ForwardExtentCopy implements Operation {
/** /**
* Get the transformation that will occur on every point. * Get the transformation that will occur on every point.
* <p> *
* <p>The transformation will stack with each repetition.</p> * <p>The transformation will stack with each repetition.</p>
* *
* @return a transformation * @return a transformation
@ -150,7 +141,7 @@ public class ForwardExtentCopy implements Operation {
/** /**
* Get the mask that gets applied to the source extent. * Get the mask that gets applied to the source extent.
* <p> *
* <p>This mask can be used to filter what will be copied from the source.</p> * <p>This mask can be used to filter what will be copied from the source.</p>
* *
* @return a source mask * @return a source mask
@ -159,14 +150,6 @@ public class ForwardExtentCopy implements Operation {
return sourceMask; return sourceMask;
} }
public void setCopyingEntities(boolean copyEntities) {
this.copyEntities = copyEntities;
}
public boolean isCopyingEntities() {
return copyEntities;
}
public void setCopyBiomes(boolean copyBiomes) { public void setCopyBiomes(boolean copyBiomes) {
this.copyBiomes = copyBiomes; this.copyBiomes = copyBiomes;
} }
@ -206,7 +189,6 @@ public class ForwardExtentCopy implements Operation {
* *
* @param function a source function, or null if none is to be applied * @param function a source function, or null if none is to be applied
*/ */
@Deprecated
public void setSourceFunction(RegionFunction function) { public void setSourceFunction(RegionFunction function) {
this.sourceFunction = function; this.sourceFunction = function;
} }
@ -230,6 +212,24 @@ public class ForwardExtentCopy implements Operation {
this.repetitions = repetitions; this.repetitions = repetitions;
} }
/**
* Return whether entities should be copied along with blocks.
*
* @return true if copying
*/
public boolean isCopyingEntities() {
return copyingEntities;
}
/**
* Set whether entities should be copied along with blocks.
*
* @param copyingEntities true if copying
*/
public void setCopyingEntities(boolean copyingEntities) {
this.copyingEntities = copyingEntities;
}
/** /**
* Return whether entities that are copied should be removed. * Return whether entities that are copied should be removed.
* *

View File

@ -30,17 +30,15 @@ public final class Operations {
private Operations() { private Operations() {
} }
private static RunContext context = new RunContext();
/** /**
* Complete a given operation synchronously until it completes. * Complete a given operation synchronously until it completes.
* *
* @param operation operation to execute * @param op operation to execute
* @throws WorldEditException WorldEdit exception * @throws WorldEditException WorldEdit exception
*/ */
public static void complete(Operation operation) throws WorldEditException { public static void complete(Operation op) throws WorldEditException {
while (operation != null) { while (op != null) {
operation = operation.resume(context); op = op.resume(new RunContext());
} }
} }
@ -48,11 +46,19 @@ public final class Operations {
* Complete a given operation synchronously until it completes. Catch all * Complete a given operation synchronously until it completes. Catch all
* errors that is not {@link MaxChangedBlocksException} for legacy reasons. * errors that is not {@link MaxChangedBlocksException} for legacy reasons.
* *
* @param operation operation to execute * @param op operation to execute
* @throws MaxChangedBlocksException thrown when too many blocks have been changed * @throws MaxChangedBlocksException thrown when too many blocks have been changed
*/ */
public static void completeLegacy(Operation operation) throws MaxChangedBlocksException { public static void completeLegacy(Operation op) throws MaxChangedBlocksException {
completeBlindly(operation); while (op != null) {
try {
op = op.resume(new RunContext());
} catch (MaxChangedBlocksException e) {
throw e;
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
} }
/** /**
@ -60,25 +66,16 @@ public final class Operations {
* {@link com.sk89q.worldedit.WorldEditException} exceptions as * {@link com.sk89q.worldedit.WorldEditException} exceptions as
* {@link java.lang.RuntimeException}s. * {@link java.lang.RuntimeException}s.
* *
* @param operation operation to execute * @param op operation to execute
*/ */
public static void completeBlindly(Operation operation) { public static void completeBlindly(Operation op) {
while (op != null) {
try { try {
while (operation != null) { op = op.resume(new RunContext());
operation = operation.resume(context);
}
} catch (WorldEditException e) { } catch (WorldEditException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public static void completeSmart(final Operation op, final Runnable whenDone, final boolean threadsafe) {
completeBlindly(op);
if (whenDone != null) {
whenDone.run();
}
return;
} }
} }

View File

@ -22,12 +22,10 @@ package com.sk89q.worldedit.function.pattern;
import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.collection.RandomCollection;
import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.object.random.SimpleRandom;
import com.boydti.fawe.object.random.TrueRandom; import com.boydti.fawe.object.random.TrueRandom;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -36,8 +34,6 @@ import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Uses a random pattern of a weighted list of patterns. * Uses a random pattern of a weighted list of patterns.
*/ */
@ -83,8 +79,8 @@ public class RandomPattern extends AbstractPattern {
} }
@Override @Override
public BaseBlock apply(BlockVector3 get) { public BaseBlock apply(BlockVector3 position) {
return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(get); return collection.next(position.getBlockX(), position.getBlockY(), position.getBlockZ()).apply(position);
} }
@Override @Override

View File

@ -90,9 +90,9 @@ public class RepeatingExtentPattern extends AbstractExtentPattern {
@Override @Override
public BaseBlock apply(BlockVector3 p) { public BaseBlock apply(BlockVector3 p) {
int x = (Math.abs((p.getX() + offset.getX())) % size.getBlockX()) + origin.getX(); int x = Math.abs(p.getX() + offset.getX()) % size.getBlockX() + origin.getX();
int y = (Math.abs((p.getY() + offset.getY())) % size.getBlockY()) + origin.getY(); int y = Math.abs(p.getY() + offset.getY()) % size.getBlockY() + origin.getY();
int z = (Math.abs((p.getZ() + offset.getZ())) % size.getBlockZ()) + origin.getZ(); int z = Math.abs(p.getZ() + offset.getZ()) % size.getBlockZ() + origin.getZ();
return getExtent().getFullBlock(mutable.setComponents(x, y, z)); return getExtent().getFullBlock(mutable.setComponents(x, y, z));
} }

View File

@ -26,19 +26,18 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.object.collection.BlockVectorSet; import com.boydti.fawe.object.collection.BlockVectorSet;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
/** /**
@ -98,13 +97,17 @@ public abstract class BreadthFirstSearch implements Operation {
*/ */
public BreadthFirstSearch(RegionFunction function) { public BreadthFirstSearch(RegionFunction function) {
this(function, Integer.MAX_VALUE); this(function, Integer.MAX_VALUE);
checkNotNull(function);
} }
public BreadthFirstSearch(final RegionFunction function, int maxDepth) { public BreadthFirstSearch(RegionFunction function, int maxDepth) {
this(function, maxDepth, null); this(function, maxDepth, null);
checkNotNull(function);
} }
public BreadthFirstSearch(final RegionFunction function, int maxDepth, HasFaweQueue faweQueue) { public BreadthFirstSearch(RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
checkNotNull(function);
FaweQueue fq = faweQueue != null ? faweQueue.getQueue() : null; FaweQueue fq = faweQueue != null ? faweQueue.getQueue() : null;
this.mFaweQueue = fq instanceof MappedFaweQueue ? (MappedFaweQueue) fq : null; this.mFaweQueue = fq instanceof MappedFaweQueue ? (MappedFaweQueue) fq : null;
this.queue = new BlockVectorSet(); this.queue = new BlockVectorSet();
@ -179,21 +182,15 @@ public abstract class BreadthFirstSearch implements Operation {
* *
* @param position the position * @param position the position
*/ */
public void visit(BlockVector3 position) { public void visit(BlockVector3 position) {
if (!isVisited(position)) { BlockVector3 blockVector = position;
isVisitable(position, position); // Ignore this, just to initialize mask on this point if (!visited.contains(blockVector)) {
queue.add(position); isVisitable(blockVector, blockVector); // Ignore this, just to initialize mask on this point
visited.add(position); queue.add(blockVector);
visited.add(blockVector);
} }
} }
public void resetVisited() {
queue.clear();
visited.clear();
affected = 0;
}
public void setVisited(BlockVectorSet set) { public void setVisited(BlockVectorSet set) {
this.visited = set; this.visited = set;
} }

View File

@ -20,26 +20,26 @@
package com.sk89q.worldedit.function.visitor; package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.EntityFunction; import com.sk89q.worldedit.function.EntityFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Visits entities as provided by an {@code Iterator}. * Visits entities as provided by an {@code Iterator}.
*/ */
public class EntityVisitor implements Operation { public class EntityVisitor implements Operation {
private final Iterator<? extends Entity> iterator;
private final EntityFunction function; private final EntityFunction function;
private int affected = 0; private int affected = 0;
private final Iterator<? extends Entity> iterator;
/** /**
* Create a new instance. * Create a new instance.
@ -47,12 +47,11 @@ public class EntityVisitor implements Operation {
* @param iterator the iterator * @param iterator the iterator
* @param function the function * @param function the function
*/ */
public EntityVisitor(final Iterator<? extends Entity> iterator, final EntityFunction function) { public EntityVisitor(Iterator<? extends Entity> iterator, EntityFunction function) {
checkNotNull(iterator); checkNotNull(iterator);
checkNotNull(function); checkNotNull(function);
this.function = function;
this.iterator = iterator; this.iterator = iterator;
this.function = function;
} }
/** /**
@ -61,16 +60,17 @@ public class EntityVisitor implements Operation {
* @return the number of affected * @return the number of affected
*/ */
public int getAffected() { public int getAffected() {
return this.affected; return affected;
} }
@Override @Override
public Operation resume(final RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
while (this.iterator.hasNext()) { while (iterator.hasNext()) {
if (this.function.apply(this.iterator.next())) { if (function.apply(iterator.next())) {
affected++; affected++;
} }
} }
return null; return null;
} }
@ -79,9 +79,8 @@ public class EntityVisitor implements Operation {
} }
@Override @Override
public void addStatusMessages(final List<String> messages) { public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_ENTITY.format(getAffected())); messages.add(BBC.VISITOR_ENTITY.format(getAffected()));
} }
} }

View File

@ -24,20 +24,17 @@ import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.visitor.Fast2DIterator; import com.boydti.fawe.object.visitor.Fast2DIterator;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.FlatRegionFunction; import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Applies region functions to columns in a {@link FlatRegion}. * Applies region functions to columns in a {@link FlatRegion}.
*/ */
@ -54,9 +51,10 @@ public class FlatRegionVisitor implements Operation {
* @param flatRegion a flat region * @param flatRegion a flat region
* @param function a function to apply to columns * @param function a function to apply to columns
*/ */
public FlatRegionVisitor(final FlatRegion flatRegion, final FlatRegionFunction function) { public FlatRegionVisitor(FlatRegion flatRegion, FlatRegionFunction function) {
checkNotNull(flatRegion); checkNotNull(flatRegion);
checkNotNull(function); checkNotNull(function);
this.function = function; this.function = function;
this.iterator = flatRegion.asFlatRegion(); this.iterator = flatRegion.asFlatRegion();
} }
@ -76,20 +74,25 @@ public class FlatRegionVisitor implements Operation {
* @return the number of affected * @return the number of affected
*/ */
public int getAffected() { public int getAffected() {
return this.affected; return affected;
} }
@Override @Override
public Operation resume(final RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
if (this.queue != null) { if (queue != null) {
for (final BlockVector2 pt : new Fast2DIterator(this.iterator, queue)) { for (BlockVector2 pt : new Fast2DIterator(iterator, queue)) {
if (this.function.apply(pt)) affected++; if (function.apply(pt)) {
affected++;
}
} }
} else { } else {
for (final BlockVector2 pt : this.iterator) { for (BlockVector2 pt : this.iterator) {
if (this.function.apply(pt)) affected++; if (function.apply(pt)) {
affected++;
} }
} }
}
return null; return null;
} }
@ -98,10 +101,9 @@ public class FlatRegionVisitor implements Operation {
} }
@Override @Override
public void addStatusMessages(final List<String> messages) { public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_FLAT.format(getAffected())); messages.add(BBC.VISITOR_FLAT.format(getAffected()));
} }
} }

View File

@ -19,6 +19,9 @@
package com.sk89q.worldedit.function.visitor; package com.sk89q.worldedit.function.visitor;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.mask.Mask2D;
@ -31,9 +34,6 @@ import com.sk89q.worldedit.regions.FlatRegion;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Visits the layers within a region. * Visits the layers within a region.
* *
@ -62,6 +62,7 @@ public class LayerVisitor implements Operation {
checkNotNull(flatRegion); checkNotNull(flatRegion);
checkArgument(minY <= maxY, "minY <= maxY required"); checkArgument(minY <= maxY, "minY <= maxY required");
checkNotNull(function); checkNotNull(function);
this.flatRegion = flatRegion; this.flatRegion = flatRegion;
this.minY = minY; this.minY = minY;
this.maxY = maxY; this.maxY = maxY;
@ -119,6 +120,7 @@ public class LayerVisitor implements Operation {
} }
} }
} }
return null; return null;
} }
@ -130,5 +132,4 @@ public class LayerVisitor implements Operation {
public void addStatusMessages(List<String> messages) { public void addStatusMessages(List<String> messages) {
} }
} }

View File

@ -20,8 +20,7 @@
package com.sk89q.worldedit.function.visitor; package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.HasFaweQueue;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -39,7 +38,6 @@ public class NonRisingVisitor extends RecursiveVisitor {
* @param mask the mask * @param mask the mask
* @param function the function * @param function the function
*/ */
public NonRisingVisitor(Mask mask, RegionFunction function) { public NonRisingVisitor(Mask mask, RegionFunction function) {
this(mask, function, Integer.MAX_VALUE, null); this(mask, function, Integer.MAX_VALUE, null);
} }
@ -48,13 +46,11 @@ public class NonRisingVisitor extends RecursiveVisitor {
super(mask, function, depth, hasFaweQueue); super(mask, function, depth, hasFaweQueue);
Collection<BlockVector3> directions = getDirections(); Collection<BlockVector3> directions = getDirections();
directions.clear(); directions.clear();
directions.add(BlockVector3.at(1, 0, 0)); directions.add(BlockVector3.UNIT_X);
directions.add(BlockVector3.at(-1, 0, 0)); directions.add(BlockVector3.UNIT_MINUS_X);
directions.add(BlockVector3.at(0, 0, 1)); directions.add(BlockVector3.UNIT_Z);
directions.add(BlockVector3.at(0, 0, -1)); directions.add(BlockVector3.UNIT_MINUS_Z);
directions.add(BlockVector3.at(0, -1, 0)); directions.add(BlockVector3.UNIT_MINUS_Y);
} }
} }

View File

@ -34,7 +34,7 @@ public class RecursiveVisitor extends BreadthFirstSearch {
private final Mask mask; private final Mask mask;
public RecursiveVisitor(final Mask mask, final RegionFunction function) { public RecursiveVisitor(Mask mask, RegionFunction function) {
this(mask, function, Integer.MAX_VALUE); this(mask, function, Integer.MAX_VALUE);
} }
@ -44,11 +44,11 @@ public class RecursiveVisitor extends BreadthFirstSearch {
* @param mask the mask * @param mask the mask
* @param function the function * @param function the function
*/ */
public RecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth) { public RecursiveVisitor(Mask mask, RegionFunction function, int maxDepth) {
this(mask, function, maxDepth, null); this(mask, function, maxDepth, null);
} }
public RecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth, HasFaweQueue faweQueue) { public RecursiveVisitor(Mask mask, RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
super(function, maxDepth, faweQueue); super(function, maxDepth, faweQueue);
checkNotNull(mask); checkNotNull(mask);
this.mask = mask; this.mask = mask;
@ -58,6 +58,4 @@ public class RecursiveVisitor extends BreadthFirstSearch {
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) { protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
return mask.test(to); return mask.test(to);
} }
} }

View File

@ -25,14 +25,15 @@ import com.boydti.fawe.example.MappedFaweQueue;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.HasFaweQueue;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -42,11 +43,10 @@ import java.util.List;
public class RegionVisitor implements Operation { public class RegionVisitor implements Operation {
public final Region region; public final Region region;
public final Iterable<? extends BlockVector3> iterable;
public final RegionFunction function; public final RegionFunction function;
private final MappedFaweQueue queue;
private boolean useCuboidIterator = false;
public int affected = 0; public int affected = 0;
public final Iterable<? extends BlockVector3> iterable;
private final MappedFaweQueue queue;
/** /**
* Deprecated in favor of the other constructors which will preload chunks during iteration * Deprecated in favor of the other constructors which will preload chunks during iteration
@ -68,9 +68,9 @@ public class RegionVisitor implements Operation {
} }
public RegionVisitor(Iterable<? extends BlockVector3> iterable, RegionFunction function, HasFaweQueue hasQueue) { public RegionVisitor(Iterable<? extends BlockVector3> iterable, RegionFunction function, HasFaweQueue hasQueue) {
region = (iterable instanceof Region) ? (Region) iterable : null; this.region = iterable instanceof Region ? (Region) iterable : null;
this.iterable = iterable;
this.function = function; this.function = function;
this.iterable = iterable;
this.queue = hasQueue != null && hasQueue.getQueue() instanceof MappedFaweQueue ? (MappedFaweQueue) hasQueue.getQueue() : null; this.queue = hasQueue != null && hasQueue.getQueue() instanceof MappedFaweQueue ? (MappedFaweQueue) hasQueue.getQueue() : null;
} }
@ -80,11 +80,11 @@ public class RegionVisitor implements Operation {
* @return the number of affected * @return the number of affected
*/ */
public int getAffected() { public int getAffected() {
return this.affected; return affected;
} }
@Override @Override
public Operation resume(final RunContext run) throws WorldEditException { public Operation resume(RunContext run) throws WorldEditException {
if (queue != null && Settings.IMP.QUEUE.PRELOAD_CHUNKS > 1) { if (queue != null && Settings.IMP.QUEUE.PRELOAD_CHUNKS > 1) {
/* /*
* The following is done to reduce iteration cost * The following is done to reduce iteration cost
@ -194,9 +194,9 @@ public class RegionVisitor implements Operation {
} }
@Override @Override
public void addStatusMessages(final List<String> messages) { public void addStatusMessages(List<String> messages) {
messages.add(BBC.VISITOR_BLOCK.format(getAffected())); messages.add(BBC.VISITOR_BLOCK.format(getAffected()));
} }
} }

View File

@ -27,7 +27,11 @@ import com.sk89q.worldedit.regions.iterator.RegionIterator;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public abstract class AbstractRegion implements Region { public abstract class AbstractRegion implements Region {

View File

@ -28,10 +28,9 @@ import com.google.common.io.Resources;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -48,11 +47,8 @@ import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Map; import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
public class LegacyMapper { public class LegacyMapper {
private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class); private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
@ -90,7 +86,6 @@ public class LegacyMapper {
} }
String source = Resources.toString(url, Charset.defaultCharset()); String source = Resources.toString(url, Charset.defaultCharset());
LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {}.getType()); LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {}.getType());
ParserContext parserContext = new ParserContext(); ParserContext parserContext = new ParserContext();
parserContext.setPreferringWildcard(false); parserContext.setPreferringWildcard(false);
parserContext.setRestricted(false); parserContext.setRestricted(false);