use of org.bukkit.block.data.type.Sign in project BuildSystem by einTosti.
the class CustomBlocks_1_14_R1 method rotate.
@Override
public void rotate(Block block, Player player, BlockFace blockFace) {
BlockFace direction = blockFace != null ? blockFace : getDirection(player);
BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
Directional directional = (Directional) blockData;
directional.setFacing(direction);
block.setBlockData(directional);
} else if (blockData instanceof Sign) {
Sign sign = (Sign) blockData;
sign.setRotation(direction);
block.setBlockData(sign);
}
}
use of org.bukkit.block.data.type.Sign in project BuildSystem by einTosti.
the class CustomBlocks_1_13_R1 method rotate.
@Override
public void rotate(Block block, Player player, BlockFace blockFace) {
BlockFace direction = blockFace != null ? blockFace : getDirection(player);
BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
Directional directional = (Directional) blockData;
directional.setFacing(direction);
block.setBlockData(directional);
} else if (blockData instanceof Sign) {
Sign sign = (Sign) blockData;
sign.setRotation(direction);
block.setBlockData(sign);
}
}
use of org.bukkit.block.data.type.Sign in project BuildSystem by Trichtern.
the class CustomBlocks_1_13_R1 method rotate.
@Override
public void rotate(Block block, Player player, BlockFace blockFace) {
BlockFace direction = blockFace != null ? blockFace : getDirection(player);
BlockData blockData = block.getBlockData();
if (blockData instanceof Directional) {
Directional directional = (Directional) blockData;
directional.setFacing(direction);
block.setBlockData(directional);
} else if (blockData instanceof Sign) {
Sign sign = (Sign) blockData;
sign.setRotation(direction);
block.setBlockData(sign);
}
}
use of org.bukkit.block.data.type.Sign in project SignShop by wargamer.
the class SignShopBlockListener method getAttachables.
private List<Block> getAttachables(Block originalBlock) {
List<Block> attachables = new ArrayList<>();
List<BlockFace> checkFaces = new ArrayList<>();
checkFaces.add(BlockFace.UP);
checkFaces.add(BlockFace.NORTH);
checkFaces.add(BlockFace.EAST);
checkFaces.add(BlockFace.SOUTH);
checkFaces.add(BlockFace.WEST);
Block relativeBlock;
BlockData relativeBlockData;
for (BlockFace face : checkFaces) {
relativeBlock = originalBlock.getRelative(face);
relativeBlockData = relativeBlock.getBlockData();
if (relativeBlockData instanceof Switch) {
Switch switchData = (Switch) relativeBlockData;
if (switchData.getFace() == Switch.Face.FLOOR && relativeBlock.getRelative(BlockFace.DOWN).equals(originalBlock)) {
attachables.add(relativeBlock);
}
} else if (relativeBlockData instanceof WallSign) {
WallSign wallSign = (WallSign) relativeBlockData;
if (relativeBlock.getRelative(wallSign.getFacing().getOppositeFace()).equals(originalBlock)) {
// may need to add getOppositeFace
attachables.add(relativeBlock);
}
} else if (relativeBlockData instanceof Sign)
if (relativeBlock.getRelative(BlockFace.DOWN).equals(originalBlock)) {
attachables.add(relativeBlock);
}
}
return attachables;
}
use of org.bukkit.block.data.type.Sign in project Towny by TownyAdvanced.
the class TownyPlayerListener method onAdminToolUseOnBlocks.
/*
* Handles AdminTool use on Blocks
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onAdminToolUseOnBlocks(PlayerInteractEvent event) {
if (plugin.isError()) {
event.setCancelled(true);
return;
}
if (!TownyAPI.getInstance().isTownyWorld(event.getPlayer().getWorld()))
return;
if (event.hasItem() && event.getPlayer().getInventory().getItemInMainHand().getType() == Material.getMaterial(TownySettings.getTool()) && TownyUniverse.getInstance().getPermissionSource().isTownyAdmin(event.getPlayer()) && event.getClickedBlock() != null) {
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if (Tag.SIGNS.isTagged(block.getType())) {
BlockFace facing = null;
if (block.getBlockData() instanceof Sign) {
org.bukkit.block.data.type.Sign sign = (org.bukkit.block.data.type.Sign) block.getBlockData();
facing = sign.getRotation();
}
if (block.getBlockData() instanceof WallSign) {
org.bukkit.block.data.type.WallSign sign = (org.bukkit.block.data.type.WallSign) block.getBlockData();
facing = sign.getFacing();
}
TownyMessaging.sendMessage(player, Arrays.asList(ChatTools.formatTitle("Sign Info"), ChatTools.formatCommand("", "Sign Type", "", block.getType().name()), ChatTools.formatCommand("", "Facing", "", facing.toString())));
} else if (Tag.DOORS.isTagged(block.getType())) {
org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) block.getBlockData();
TownyMessaging.sendMessage(player, Arrays.asList(ChatTools.formatTitle("Door Info"), ChatTools.formatCommand("", "Door Type", "", block.getType().name()), ChatTools.formatCommand("", "hinged on ", "", String.valueOf(door.getHinge())), ChatTools.formatCommand("", "isOpen", "", String.valueOf(door.isOpen())), ChatTools.formatCommand("", "getFacing", "", door.getFacing().name())));
} else {
TownyMessaging.sendMessage(player, Arrays.asList(ChatTools.formatTitle("Block Info"), ChatTools.formatCommand("", "Material", "", block.getType().name()), ChatTools.formatCommand("", "MaterialData", "", block.getBlockData().getAsString())));
}
event.setUseInteractedBlock(Event.Result.DENY);
event.setCancelled(true);
}
}
Aggregations