Skip to content
Permalink
Browse files

Revert "Better BaseBlock usage."

This reverts commit 56ddef5.
  • Loading branch information...
me4502 committed Dec 27, 2018
1 parent 56ddef5 commit d51a185a8ddb13215660d241ca225d492d21d39f
@@ -19,7 +19,6 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Bukkit;
@@ -443,12 +442,12 @@ public static boolean isEnabled(Types type) {
private int pistonMaxDistance;
private boolean pistonsCrusher;
private boolean pistonsCrusherInstaKill;
private List<BaseBlock> pistonsCrusherBlacklist;
private List<BlockStateHolder> pistonsCrusherBlacklist;
private boolean pistonsSuperPush;
private boolean pistonsSuperSticky;
private List<BaseBlock> pistonsMovementBlacklist;
private List<BlockStateHolder> pistonsMovementBlacklist;
private boolean pistonsBounce;
private List<BaseBlock> pistonsBounceBlacklist;
private List<BlockStateHolder> pistonsBounceBlacklist;
private double pistonBounceMaxVelocity;

public static List<String> getDefaultBlacklist() {
@@ -12,7 +12,7 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.apache.commons.lang.StringUtils;
import org.bukkit.block.Block;
@@ -31,9 +31,9 @@

public class BounceBlocks extends AbstractCraftBookMechanic {

private List<BaseBlock> blocks;
private List<BlockStateHolder> blocks;
private double sensitivity;
private Map<BaseBlock, Vector> autoBouncers = new HashMap<>();
private Map<BlockStateHolder, Vector> autoBouncers = new HashMap<>();

@Override
public void loadConfiguration (YAMLProcessor config, String path) {
@@ -67,7 +67,7 @@ public void loadConfiguration (YAMLProcessor config, String path) {
z = Double.parseDouble(bits[2]);
}

BaseBlock block = BlockSyntax.getBlock(key, true);
BlockStateHolder block = BlockSyntax.getBlock(key, true);

autoBouncers.put(block, new Vector(x,y,z));
}
@@ -133,7 +133,7 @@ public void onPlayerMove(final PlayerMoveEvent event) {
}
}

for(Entry<BaseBlock, Vector> entry : autoBouncers.entrySet()) {
for(Entry<BlockStateHolder, Vector> entry : autoBouncers.entrySet()) {
if(entry.getKey().equalsFuzzy(BukkitAdapter.adapt(block.getBlockData()))) {

CraftBookPlugin.logDebugMessage("Player jumped on a auto block that is a BoucneBlock!", "bounce-blocks");
@@ -19,8 +19,8 @@
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemTypes;
import org.bukkit.Bukkit;
@@ -388,7 +388,7 @@ public void disable () {
private boolean chairAllowHeldBlock;
private boolean chairHealth;
private double chairHealAmount;
private List<BaseBlock> chairBlocks;
private List<BlockStateHolder> chairBlocks;
private boolean chairFacing;
private boolean chairRequireSign;
private int chairMaxDistance;
@@ -7,7 +7,7 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Material;
import org.bukkit.Tag;
@@ -89,7 +89,7 @@ public void disable () {
footsteps = null;
}

private List<BaseBlock> blocks;
private List<BlockStateHolder> blocks;

@Override
public void loadConfiguration (YAMLProcessor config, String path) {
@@ -13,7 +13,7 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@@ -551,7 +551,7 @@ public int hashCode() {
private boolean pileHigh;
private int maxPileHeight;
private boolean jumpTrample;
private List<BaseBlock> realisticReplacables;
private List<BlockStateHolder> realisticReplacables;
private int animationTicks;
private boolean freezeWater;
private boolean meltSunlight;
@@ -14,7 +14,6 @@
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@@ -161,7 +160,7 @@ else if (data instanceof Tree)
return true;
}

List<BaseBlock> enabledBlocks;
List<BlockStateHolder> enabledBlocks;
List<ItemType> enabledItems;
private int maxSearchSize;
private boolean allowDiagonals;
@@ -33,8 +33,8 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Bukkit;
@@ -306,7 +306,7 @@ public boolean isApplicableSign(String line) {
private boolean allowRedstone;
private int maxLength;
private int maxWidth;
private List<BaseBlock> blocks;
private List<BlockStateHolder> blocks;

public List<String> getDefaultBlocks() {
List<String> materials = new ArrayList<>();
@@ -33,8 +33,8 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Bukkit;
@@ -327,10 +327,10 @@ public boolean isApplicableSign(String line) {
return line.equals("[Door Up]") || line.equals("[Door Down]");
}

private boolean allowRedstone;
private int maxLength;
private int maxWidth;
private List<BaseBlock> blocks;
boolean allowRedstone;
int maxLength;
int maxWidth;
List<BlockStateHolder> blocks;

public List<String> getDefaultBlocks() {
List<String> materials = new ArrayList<>();
@@ -34,7 +34,6 @@
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@@ -677,7 +676,7 @@ public int hashCode() {
private boolean allowRedstone;
private boolean limitColumns;
private int columnLimit;
private List<BaseBlock> blocks;
private List<BlockStateHolder> blocks;
private boolean enforceType;
private int columnHeight;
private int searchRadius;
@@ -17,7 +17,6 @@
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Material;
@@ -102,7 +101,7 @@ public void dropItem(ItemStack item) {

boolean above;

List<BaseBlock> blockBlacklist;
List<BlockStateHolder> blockBlacklist;

public Factory(Server server, boolean above) {

@@ -123,7 +122,7 @@ public void verify(ChangedSign sign) throws ICVerificationException {
BlockStateHolder item = BlockSyntax.getBlock(sign.getLine(2), true);
if(item == null)
throw new ICVerificationException("An invalid block was provided on line 2!");
if(Blocks.containsFuzzy(blockBlacklist, item))
if(blockBlacklist.contains(item))
throw new ICVerificationException("A blacklisted block was provided on line 2!");
}
}
@@ -28,7 +28,6 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Material;
@@ -74,7 +73,7 @@ protected void doSet(Block body, BlockStateHolder blockData, boolean force) {

boolean above;

public List<BaseBlock> blockBlacklist;
public List<BlockStateHolder> blockBlacklist;

public Factory(Server server, boolean above) {

@@ -96,7 +95,7 @@ public void verify(ChangedSign sign) throws ICVerificationException {
BlockStateHolder item = BlockSyntax.getBlock(sign.getLine(2), true);
if(item == null)
throw new ICVerificationException("An invalid block was provided on line 2!");
if(Blocks.containsFuzzy(blockBlacklist, item))
if(blockBlacklist.contains(item))
throw new ICVerificationException("A blacklisted block was provided on line 2!");
}

@@ -11,7 +11,6 @@
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Material;
@@ -63,7 +62,7 @@ protected void doSet(Block body, BlockStateHolder item, boolean force) {

boolean above;

public List<BaseBlock> blockBlacklist;
public List<BlockStateHolder> blockBlacklist;

public Factory(Server server, boolean above) {

@@ -21,7 +21,6 @@
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bukkit.Material;
@@ -38,18 +37,18 @@
BLOCK_CONTEXT.setRestricted(false);
}

public static BaseBlock getBlock(String line) {
public static BlockStateHolder getBlock(String line) {
return getBlock(line, false);
}

public static BaseBlock getBlock(String line, boolean wild) {
public static BlockStateHolder getBlock(String line, boolean wild) {
if (line == null || line.trim().isEmpty()) {
return null;
}

BLOCK_CONTEXT.setPreferringWildcard(wild);

BaseBlock blockState = null;
BlockStateHolder blockState = null;
try {
blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(line, BLOCK_CONTEXT);
} catch (InputParseException e) {
@@ -66,7 +65,7 @@ public static BaseBlock getBlock(String line, boolean wild) {
data = 0;
}
}
blockState = LegacyMapper.getInstance().getBlockFromLegacy(BukkitAdapter.asBlockType(material).getLegacyId(), data).toBaseBlock();
blockState = LegacyMapper.getInstance().getBlockFromLegacy(BukkitAdapter.asBlockType(material).getLegacyId(), data);
}
if (material == null) {
CraftBookPlugin.logger().warning("Invalid block format: " + line);
@@ -75,11 +74,11 @@ public static BaseBlock getBlock(String line, boolean wild) {
return blockState;
}

public static List<BaseBlock> getBlocks(List<String> lines) {
public static List<BlockStateHolder> getBlocks(List<String> lines) {
return getBlocks(lines, false);
}

public static List<BaseBlock> getBlocks(List<String> lines, boolean wild) {
public static List<BlockStateHolder> getBlocks(List<String> lines, boolean wild) {
return lines.stream().map(line -> getBlock(line, wild)).collect(Collectors.toList());
}

@@ -33,7 +33,7 @@
@PrepareForTest({TreeLopper.class,BlockBreakEvent.class})
public class TreeLopperTest extends BaseTestCase {

private TreeLopper lopper;
TreeLopper lopper;

@Test
public void testOnBlockBreak() {
@@ -63,7 +63,7 @@ public void testOnBlockBreak() {
when(block.getLocation()).thenReturn(new Location(world, 64,64,64));

lopper.enabledBlocks = new ArrayList<>();
lopper.enabledBlocks.add(BlockTypes.OAK_LOG.getDefaultState().toBaseBlock());
lopper.enabledBlocks.add(BlockTypes.OAK_LOG.getDefaultState());

lopper.enabledItems = new ArrayList<>();
lopper.enabledItems.add(ItemTypes.DIAMOND_AXE);

0 comments on commit d51a185

Please sign in to comment.
You can’t perform that action at this time.