diff --git a/config/checkstyle/import-control.xml b/config/checkstyle/import-control.xml
index d620978fd..2fe94d97d 100644
--- a/config/checkstyle/import-control.xml
+++ b/config/checkstyle/import-control.xml
@@ -38,6 +38,7 @@
+
@@ -58,6 +59,7 @@
+
diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle
index ca6b81c2b..e67742793 100644
--- a/worldedit-bukkit/build.gradle
+++ b/worldedit-bukkit/build.gradle
@@ -89,4 +89,4 @@ shadowJar {
build.dependsOn(shadowJar)
build.finalizedBy(copyFiles)
-copyFiles.dependsOn(createPom)
\ No newline at end of file
+copyFiles.dependsOn(createPom)
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java
index d5596f562..a74cec6fe 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java
@@ -60,9 +60,9 @@ public class MutableFullBlockChange implements Change {
}
public void perform(FaweQueue queue) {
- BlockTypes idFrom = BlockTypes.get(from);
+ BlockTypes idFrom = BlockTypes.getFromStateId(from);
if (blockBag != null) {
- BlockTypes idTo = BlockTypes.get(to);
+ BlockTypes idTo = BlockTypes.getFromStateId(to);
if (idFrom != idTo) {
if (allowFetch && from != 0) {
try {
diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java
index 943dfe2bf..3a8665303 100644
--- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java
+++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/BlockBagChangeSet.java
@@ -81,6 +81,7 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
@Override
public void add(int x, int y, int z, BlockStateHolder from, BlockStateHolder to) {
check(from.getBlockType(), to.getBlockType());
+ super.add(x, y, z, from, to);
}
public void check(BlockType typeFrom, BlockType typeTo) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
index 5f5c29c8e..89af6d6c8 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
@@ -1522,6 +1522,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
public boolean canBypassAll(Region region, boolean get, boolean set) {
if (wrapped) return false;
+ if (history != null) return false;
FaweRegionExtent regionExtent = getRegionExtent();
if (!(region instanceof CuboidRegion)) return false;
if (regionExtent != null) {
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java
index 7fb2aa98e..f3fa24a92 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java
@@ -63,7 +63,7 @@ public class BlockMask extends AbstractExtentMask {
if (set == ALL) {
strings.add(type.getId());
} else {
- for (BlockState state : type.getStates()) {
+ for (BlockState state : type.getAllStates()) {
if (test(state)) {
strings.add(state.getAsString());
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
index 2b1d6d006..de6c1cc80 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
@@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.block;
+import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BlockMaterial;
@@ -155,6 +156,13 @@ public interface BlockType extends FawePattern, Comparable {
*/
BlockState getDefaultState();
+ /**
+ * Gets a list of all possible states for this BlockType.
+ *
+ * @return All possible states
+ */
+ List getAllStates();
+
/**
* Gets whether this block type has an item representation.
*
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
index 2f084df28..b86105d2f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java
@@ -820,7 +820,7 @@ public enum BlockTypes implements BlockType {
* @return collection of states
*/
@Deprecated
- public Collection getStates() {
+ public List getAllStates() {
if (settings.stateOrdinals == null) return Collections.singletonList(getDefaultState());
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> states[i]).collect(Collectors.toList());
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
index 555a27933..cfca55233 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
@@ -28,21 +28,21 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
+import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
+import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.annotation.Nullable;
-
public class AnvilChunk implements Chunk {
private CompoundTag rootTag;
@@ -53,8 +53,6 @@ public class AnvilChunk implements Chunk {
private int rootZ;
private Map> tileEntities;
- @SuppressWarnings("unused")
- private World world; // TODO: remove if stays unused.
/**
* Construct the chunk with a compound tag.
@@ -65,7 +63,6 @@ public class AnvilChunk implements Chunk {
*/
public AnvilChunk(World world, CompoundTag tag) throws DataException {
rootTag = tag;
- this.world = world;
rootX = NBTUtils.getChildTag(rootTag.getValue(), "xPos", IntTag.class).getValue();
rootZ = NBTUtils.getChildTag(rootTag.getValue(), "zPos", IntTag.class).getValue();
@@ -257,14 +254,22 @@ public class AnvilChunk implements Chunk {
}
@Override
- public BaseBlock getBlock(Vector position) throws DataException {
+ public BlockStateHolder getBlock(Vector position) throws DataException {
int id = getBlockID(position);
int data = getBlockData(position);
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
- CompoundTag tileEntity = getBlockTileEntity(position);
-
- return new BaseBlock(state, tileEntity);
+ if (state == null) {
+ WorldEdit.logger.warning("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
+ return BlockTypes.AIR.getDefaultState();
+ }
+ if (state.getMaterial().hasContainer()) {
+ CompoundTag tileEntity = getBlockTileEntity(position);
+ if (tileEntity != null) {
+ return new BaseBlock(state, tileEntity);
+ }
+ }
+ return state;
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
index 631e57962..f5af9bf58 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
@@ -32,6 +32,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.DataException;
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.storage.InvalidFormatException;
@@ -230,7 +231,7 @@ public class AnvilChunk13 implements Chunk {
}
@Override
- public BlockState getBlock(Vector position) throws DataException {
+ public BlockStateHolder getBlock(Vector position) throws DataException {
int x = position.getBlockX() - rootX * 16;
int y = position.getBlockY();
int z = position.getBlockZ() - rootZ * 16;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
index 5e6042901..09c7440d4 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
@@ -20,9 +20,8 @@
package com.sk89q.worldedit.world.chunk;
import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.DataException;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
/**
* A 16 by 16 block chunk.
@@ -36,6 +35,5 @@ public interface Chunk {
* @return block the block
* @throws DataException thrown on data error
*/
- BlockState getBlock(Vector position) throws DataException;
-
+ BlockStateHolder getBlock(Vector position) throws DataException;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
index bf18c49f9..7e5b00e7f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
@@ -27,13 +27,13 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.world.block.BlockState;
+import com.sk89q.worldedit.world.DataException;
+import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
-import com.sk89q.worldedit.world.DataException;
-import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
@@ -155,7 +155,7 @@ public class OldChunk implements Chunk {
}
@Override
- public BlockState getBlock(Vector position) throws DataException {
+ public BlockStateHolder getBlock(Vector position) throws DataException {
if(position.getBlockY() >= 128) return BlockTypes.VOID_AIR.getDefaultState();
int id, dataVal;
@@ -183,6 +183,10 @@ public class OldChunk implements Chunk {
}
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, dataVal);
+ if (state == null) {
+ WorldEdit.logger.warning("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk.");
+ return BlockTypes.AIR.getDefaultState();
+ }
if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) return new BaseBlock(state, tileEntity);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java
index c8b031d59..4d4a19939 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java
@@ -29,6 +29,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.DataException;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.chunk.Chunk;
import com.sk89q.worldedit.world.storage.ChunkStore;
import com.sk89q.worldedit.world.storage.MissingChunkException;
@@ -149,8 +150,7 @@ public class SnapshotRestore {
// Now just copy blocks!
for (Vector pos : entry.getValue()) {
try {
- BlockState block = chunk.getBlock(pos);
- editSession.setBlock(pos, block);
+ editSession.setBlock(pos, chunk.getBlock(pos));
} catch (DataException e) {
// this is a workaround: just ignore for now
}
diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePermissionsProvider.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePermissionsProvider.java
index d9970ecb1..986dd2555 100644
--- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePermissionsProvider.java
+++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePermissionsProvider.java
@@ -26,8 +26,6 @@ import org.spongepowered.api.service.permission.PermissionDescription;
import org.spongepowered.api.service.permission.PermissionService;
import org.spongepowered.api.service.permission.SubjectReference;
-import java.util.stream.Collectors;
-
public class SpongePermissionsProvider {
public boolean hasPermission(Player player, String permission) {
@@ -44,6 +42,6 @@ public class SpongePermissionsProvider {
public String[] getGroups(Player player) {
return player.getParents().stream()
.map(SubjectReference::getSubjectIdentifier)
- .collect(Collectors.toList()).toArray(new String[0]);
+ .toArray(String[]::new);
}
}