Skip to content
Permalink
Browse files

Spigot has broken some of their compatibility code :shrug:

  • Loading branch information...
me4502 committed May 24, 2019
1 parent fe928e7 commit 8c259116364a31db6b2091087ce4155c4fe2ad09
@@ -182,21 +182,20 @@ private boolean toggleColumn(CraftBookPlayer player, ChangedSign sign, Block blo

CraftBookPlugin.logDebugMessage("Setting column at " + block.getX() + ':' + block.getY() + ':' + block.getZ() + " to " + item.toString(), "gates.search");

for (BlockVector3 bl : column.getRegion()) {
Block blo = CraftBookBukkitUtil.toLocation(block.getWorld(), bl.toVector3()).getBlock();

//sign = CraftBookBukkitUtil.toChangedSign(sign.getSign().getBlock());
if(sign == null) {
CraftBookPlugin.logDebugMessage("Invalid Sign!", "gates.search");
return false;
}

if(sign == null) {
CraftBookPlugin.logDebugMessage("Invalid Sign!", "gates.search");
return false;
}
ChangedSign otherSign = null;

ChangedSign otherSign = null;
Block ot = SignUtil.getNextSign(CraftBookBukkitUtil.toSign(sign).getBlock(), sign.getLine(1), 4);
if(ot != null) {
otherSign = CraftBookBukkitUtil.toChangedSign(ot);
}

Block ot = SignUtil.getNextSign(CraftBookBukkitUtil.toSign(sign).getBlock(), sign.getLine(1), 4);
if(ot != null)
otherSign = CraftBookBukkitUtil.toChangedSign(ot);
for (BlockVector3 bl : column.getRegion()) {
Block blo = CraftBookBukkitUtil.toLocation(block.getWorld(), bl.toVector3()).getBlock();

if (sign.getLine(2).equalsIgnoreCase("NoReplace")) {
// If NoReplace is on line 3 of sign, do not replace blocks.
@@ -208,13 +207,16 @@ private boolean toggleColumn(CraftBookPlayer player, ChangedSign sign, Block blo

// bag.setBlockID(w, x, y1, z, ID);
if (CraftBookPlugin.inst().getConfiguration().safeDestruction) {
if (!close || hasEnoughBlocks(sign, otherSign)) {
if (!close && isValidGateBlock(sign, smallSearchSize, BukkitAdapter.adapt(blo.getBlockData()), true))
boolean hasBlocks = hasEnoughBlocks(sign, otherSign);
if (!close || hasBlocks) {
if (!close && isValidGateBlock(sign, smallSearchSize, BukkitAdapter.adapt(blo.getBlockData()), true)) {
addBlocks(sign, 1);
else if (close && canPassThrough(sign, smallSearchSize, BukkitAdapter.adapt(blo.getBlockData())) && isValidGateBlock(sign, smallSearchSize, BukkitAdapter.adapt(item), true) && item.getMaterial() != blo.getType())
} else if (close && canPassThrough(sign, smallSearchSize, BukkitAdapter.adapt(blo.getBlockData())) && isValidGateBlock(sign,
smallSearchSize, BukkitAdapter.adapt(item), true) && item.getMaterial() != blo.getType()) {
removeBlocks(sign, 1);
}
blo.setBlockData(item, true);
} else if (!hasEnoughBlocks(sign, otherSign) && isValidGateBlock(sign, smallSearchSize, BukkitAdapter.adapt(item), true))
} else if (isValidGateBlock(sign, smallSearchSize, BukkitAdapter.adapt(item), true))
if (player != null) {
player.printError("mech.not-enough-blocks");
return false;
@@ -406,12 +408,12 @@ public boolean isValidGateBlock(BlockStateHolder block) {
* @param check Should search.
* @return
*/
public boolean isValidGateBlock(ChangedSign sign, boolean smallSearchSize, BlockStateHolder block, boolean check) {
public boolean isValidGateBlock(ChangedSign sign, boolean smallSearchSize, BlockStateHolder<?> block, boolean check) {
BlockState type;

if (sign != null && !sign.getLine(0).isEmpty()) {
try {
BlockStateHolder def = BlockSyntax.getBlock(sign.getLine(0), true);
BlockStateHolder<?> def = BlockSyntax.getBlock(sign.getLine(0), true);
return block.equalsFuzzy(def);
} catch (Exception e) {
if (check) {
@@ -20,6 +20,9 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.event.block.SignChangeEvent;

/**
@@ -76,49 +79,13 @@ public static BlockFace getFacing(Block sign) {
* while facing north, this will return south).
*/
public static BlockFace getFront(Block sign) {

if (sign.getType() == Material.SIGN) {
switch (sign.getData()) {
case 0x0:
return BlockFace.SOUTH;
case 0x1:
case 0x2:
case 0x3:
return BlockFace.SOUTH_WEST;
case 0x4:
return BlockFace.WEST;
case 0x5:
case 0x6:
case 0x7:
return BlockFace.NORTH_WEST;
case 0x8:
return BlockFace.NORTH;
case 0x9:
case 0xA:
case 0xB:
return BlockFace.NORTH_EAST;
case 0xC:
return BlockFace.EAST;
case 0xD:
case 0xE:
case 0xF:
return BlockFace.SOUTH_EAST;
default:
return BlockFace.SELF;
}
BlockData blockData = sign.getBlockData();
if (blockData instanceof Sign) {
return ((Sign) blockData).getRotation();
} else if (blockData instanceof WallSign) {
return ((WallSign) blockData).getFacing();
} else {
switch (sign.getData()) {
case 0x2:
return BlockFace.NORTH;
case 0x3:
return BlockFace.SOUTH;
case 0x4:
return BlockFace.WEST;
case 0x5:
return BlockFace.EAST;
default:
return BlockFace.SELF;
}
return BlockFace.SELF;
}
}

@@ -138,50 +105,7 @@ public static Block getFrontBlock(Block sign) {
* #getFacing(Block)}.
*/
public static BlockFace getBack(Block sign) {

if (sign.getType() == Material.SIGN) {
switch (sign.getData()) {
case 0x0:
return BlockFace.NORTH;
case 0x1:
case 0x2:
case 0x3:
return BlockFace.NORTH_EAST;
case 0x4:
return BlockFace.EAST;
case 0x5:
case 0x6:
case 0x7:
return BlockFace.SOUTH_EAST;
case 0x8:
return BlockFace.SOUTH;
case 0x9:
case 0xA:
case 0xB:
return BlockFace.SOUTH_WEST;
case 0xC:
return BlockFace.WEST;
case 0xD:
case 0xE:
case 0xF:
return BlockFace.NORTH_WEST;
default:
return BlockFace.SELF;
}
} else {
switch (sign.getData()) {
case 0x2:
return BlockFace.SOUTH;
case 0x3:
return BlockFace.NORTH;
case 0x4:
return BlockFace.EAST;
case 0x5:
return BlockFace.WEST;
default:
return BlockFace.SELF;
}
}
return getFront(sign).getOppositeFace();
}

public static Block getBackBlock(Block sign) {
@@ -218,50 +142,7 @@ public static Block getNextSign(Block sign, String criterea, int searchRadius) {
* the result is rounded to the nearest ordinal direction.
*/
public static BlockFace getRight(Block sign) {

if (sign.getType() == Material.SIGN) {
switch (sign.getData()) {
case 0x0:
return BlockFace.EAST;
case 0x1:
case 0x2:
case 0x3:
return BlockFace.SOUTH_EAST;
case 0x4:
return BlockFace.SOUTH;
case 0x5:
case 0x6:
case 0x7:
return BlockFace.SOUTH_WEST;
case 0x8:
return BlockFace.WEST;
case 0x9:
case 0xA:
case 0xB:
return BlockFace.NORTH_WEST;
case 0xC:
return BlockFace.NORTH;
case 0xD:
case 0xE:
case 0xF:
return BlockFace.NORTH_EAST;
default:
return BlockFace.SELF;
}
} else {
switch (sign.getData()) {
case 0x2:
return BlockFace.WEST;
case 0x3:
return BlockFace.EAST;
case 0x4:
return BlockFace.SOUTH;
case 0x5:
return BlockFace.NORTH;
default:
return BlockFace.SELF;
}
}
return getClockWise(getFront(sign));
}

public static Block getLeftBlock(Block sign) {
@@ -279,50 +160,7 @@ public static Block getLeftBlock(Block sign) {
* result is rounded to the nearest ordinal direction.
*/
public static BlockFace getLeft(Block sign) {

if (sign.getType() == Material.SIGN) {
switch (sign.getData()) {
case 0x0:
return BlockFace.WEST;
case 0x1:
case 0x2:
case 0x3:
return BlockFace.NORTH_WEST;
case 0x4:
return BlockFace.NORTH;
case 0x5:
case 0x6:
case 0x7:
return BlockFace.NORTH_EAST;
case 0x8:
return BlockFace.EAST;
case 0x9:
case 0xA:
case 0xB:
return BlockFace.SOUTH_EAST;
case 0xC:
return BlockFace.SOUTH;
case 0xD:
case 0xE:
case 0xF:
return BlockFace.SOUTH_WEST;
default:
return BlockFace.SELF;
}
} else {
switch (sign.getData()) {
case 0x2:
return BlockFace.EAST;
case 0x3:
return BlockFace.WEST;
case 0x4:
return BlockFace.NORTH;
case 0x5:
return BlockFace.SOUTH;
default:
return BlockFace.SELF;
}
}
return getCounterClockWise(getFront(sign));
}

public static Block getRightBlock(Block sign) {
@@ -340,18 +178,16 @@ public static Block getRightBlock(Block sign) {
* directions); false otherwise.
*/
public static boolean isCardinal(Block sign) {

if (sign.getType() == Material.SIGN) {
switch (sign.getData()) {
case 0x0:
case 0x4:
case 0x8:
case 0xC:
return true;
default:
return false;
}
} else return true;
BlockFace facing = getFront(sign);
switch (facing) {
case NORTH:
case SOUTH:
case EAST:
case WEST:
return true;
default:
return false;
}
}

/**

0 comments on commit 8c25911

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