use of org.bukkit.block.BlockFace in project Essentials by drtshock.
the class EssentialsSign method checkIfBlockBreaksSigns.
protected static boolean checkIfBlockBreaksSigns(final Block block) {
final Block sign = block.getRelative(BlockFace.UP);
if (sign.getType() == Material.SIGN_POST && isValidSign(new BlockSign(sign))) {
return true;
}
final BlockFace[] directions = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
for (BlockFace blockFace : directions) {
final Block signblock = block.getRelative(blockFace);
if (signblock.getType() == Material.WALL_SIGN) {
try {
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) signblock.getState().getData();
if (signMat != null && signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock))) {
return true;
}
} catch (NullPointerException ex) {
// Sometimes signs enter a state of being semi broken, having no text or state data, usually while burning.
}
}
}
return false;
}
use of org.bukkit.block.BlockFace in project HawkEye by oliverwoodings.
the class SignEntry method interpretSqlData.
@Override
public void interpretSqlData(String data) {
if (data.indexOf("@") == -1)
return;
String[] arr = data.split("@");
//Parse wall sign or not
if (arr[0].equals("true"))
wallSign = true;
else
wallSign = false;
//Parse sign direction
for (BlockFace face : BlockFace.values()) if (face.toString().equalsIgnoreCase(arr[1]))
facing = face;
//Parse lines
if (arr.length != 3)
return;
BASE64Decoder decoder = new BASE64Decoder();
List<String> decoded = new ArrayList<String>();
String[] encLines = arr[2].split(",");
for (int i = 0; i < encLines.length; i++) {
try {
decoded.add(new String(decoder.decodeBuffer(encLines[i])));
} catch (IOException e) {
Util.severe("Unable to decode sign data from database");
}
}
lines = decoded.toArray(new String[0]);
}
use of org.bukkit.block.BlockFace in project Prism-Bukkit by prism.
the class HangingItemAction method hangItem.
/**
*
*/
public ChangeResult hangItem(Player player, QueryParameters parameters, boolean is_preview) {
final BlockFace attachedFace = getDirection();
final Location loc = new Location(getWorld(), getX(), getY(), getZ()).getBlock().getRelative(getDirection()).getLocation();
// Ensure there's a block at this location that accepts an attachment
if (me.botsko.elixr.BlockUtils.materialMeansBlockDetachment(loc.getBlock().getType())) {
return new ChangeResult(ChangeResultType.SKIPPED, null);
}
try {
if (getHangingType().equals("item_frame")) {
final Hanging hangingItem = getWorld().spawn(loc, ItemFrame.class);
hangingItem.setFacingDirection(attachedFace, true);
return new ChangeResult(ChangeResultType.APPLIED, null);
} else if (getHangingType().equals("painting")) {
final Hanging hangingItem = getWorld().spawn(loc, Painting.class);
hangingItem.setFacingDirection(getDirection(), true);
return new ChangeResult(ChangeResultType.APPLIED, null);
}
} catch (final IllegalArgumentException e) {
// Something interfered with being able to place the painting
}
return new ChangeResult(ChangeResultType.SKIPPED, null);
}
use of org.bukkit.block.BlockFace in project Denizen-For-Bukkit by DenizenScript.
the class Utilities method setSignRotation.
/**
* Make a wall sign attach itself to an available surface
*
* @param signState The sign's blockState
*/
public static void setSignRotation(BlockState signState) {
BlockFace[] blockFaces = { BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH };
for (BlockFace blockFace : blockFaces) {
Block block = signState.getBlock().getRelative(blockFace);
if ((block.getType() != Material.AIR) && block.getType() != Material.SIGN_POST && block.getType() != Material.WALL_SIGN) {
((org.bukkit.material.Sign) signState.getData()).setFacingDirection(blockFace.getOppositeFace());
signState.update();
}
}
}
use of org.bukkit.block.BlockFace in project Denizen-For-Bukkit by DenizenScript.
the class Utilities method setSignRotation.
// TODO: Javadocs, comments
//
public static void setSignRotation(BlockState signState, String direction) {
BlockFace[] blockFaces = { BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH };
for (BlockFace blockFace : blockFaces) {
if (blockFace.name().startsWith(direction.toUpperCase().substring(0, 1))) {
((org.bukkit.material.Sign) signState.getData()).setFacingDirection(blockFace);
}
}
signState.update();
}
Aggregations