Search in sources :

Example 21 with BlockFace

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;
}
Also used : BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) Sign(org.bukkit.block.Sign)

Example 22 with BlockFace

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]);
}
Also used : BlockFace(org.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BASE64Decoder(sun.misc.BASE64Decoder)

Example 23 with BlockFace

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);
}
Also used : BlockFace(org.bukkit.block.BlockFace) ChangeResult(me.botsko.prism.appliers.ChangeResult) Location(org.bukkit.Location)

Example 24 with BlockFace

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();
        }
    }
}
Also used : BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) Sign(org.bukkit.block.Sign)

Example 25 with BlockFace

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();
}
Also used : BlockFace(org.bukkit.block.BlockFace) Sign(org.bukkit.block.Sign)

Aggregations

BlockFace (org.bukkit.block.BlockFace)50 GlowBlock (net.glowstone.block.GlowBlock)20 Block (org.bukkit.block.Block)17 MaterialData (org.bukkit.material.MaterialData)9 BlockState (org.bukkit.block.BlockState)8 Vector (org.bukkit.util.Vector)8 GlowBlockState (net.glowstone.block.GlowBlockState)6 Location (org.bukkit.Location)6 ItemStack (org.bukkit.inventory.ItemStack)6 ItemTable (net.glowstone.block.ItemTable)5 BlockType (net.glowstone.block.blocktype.BlockType)4 PulseTask (net.glowstone.scheduler.PulseTask)4 Sign (org.bukkit.block.Sign)4 ArrayList (java.util.ArrayList)3 GlowPlayer (net.glowstone.entity.GlowPlayer)3 GlowWorld (net.glowstone.GlowWorld)2 BlockLiquid (net.glowstone.block.blocktype.BlockLiquid)2 ItemType (net.glowstone.block.itemtype.ItemType)2 Material (org.bukkit.Material)2 Action (org.bukkit.event.block.Action)2