Fix checking for attached wall signs

This commit is contained in:
md678685 2019-05-27 11:51:56 +01:00
parent 4201e6ef85
commit e21863956c

View File

@ -1,7 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.*;
import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.MaterialUtil;
import com.earth2me.essentials.utils.NumberUtil;
import net.ess3.api.IEssentials;
@ -14,6 +13,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
@ -211,11 +211,10 @@ public class EssentialsSign {
}
final BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace blockFace : directions) {
final Block signblock = block.getRelative(blockFace);
if (MaterialUtil.isWallSign(signblock.getType())) {
final Block signBlock = block.getRelative(blockFace);
if (MaterialUtil.isWallSign(signBlock.getType())) {
try {
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) signblock.getState().getData();
if (signMat != null && signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock))) {
if (getWallSignFacing(signBlock) == blockFace && isValidSign(new BlockSign(signBlock))) {
return true;
}
} catch (NullPointerException ex) {
@ -445,6 +444,16 @@ public class EssentialsSign {
ess.showError(sender, exception, "\\ sign: " + signName);
}
private static BlockFace getWallSignFacing(Block block) {
try {
final WallSign signData = (WallSign) block.getState().getBlockData();
return signData.getFacing();
} catch (NoClassDefFoundError e) {
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) block.getState().getData();
return signMat.getFacing();
}
}
static class EventSign implements ISign {
private final transient SignChangeEvent event;