Package org.bukkit.block

Examples of org.bukkit.block.Block


    if (signblock == null) {
      return null;
    }

    final Material type = signblock.getType();
    final Block mainBlock;
    if (type == Material.WALL_SIGN) {
      mainBlock = BlockUtil.getAttachedBlock(signblock);
    } else if (type == Material.SIGN_POST) {
      mainBlock = signblock;
    } else {
      return null;
    }
    boolean hasSigns;
    for (BlockFace dir : possibleFaces) {
      Block block = mainBlock;
      hasSigns = true;
      while (true) {
        // Go to the next block
        block = block.getRelative(dir);

        // Check for rails
        BlockFace columnDir = RailType.getType(block).getSignColumnDirection(block);
        if (dir == columnDir.getOppositeFace()) {
          return block;
View Full Code Here


   * @param rails to check
   * @param direction of the vertical rail
   * @return True if a vertical rail is above, False if not
   */
  public static boolean isVerticalAbove(Block rails, BlockFace direction) {
    Block above = rails.getRelative(BlockFace.UP);
    return Util.ISVERTRAIL.get(above) && getVerticalRailDirection(above) == direction;
  }
View Full Code Here

    return false;
  }

  public static boolean isSupported(Block block) {
    BlockFace attachedFace = BlockUtil.getAttachedFace(block);
    Block attached = block.getRelative(attachedFace);
    if (MaterialUtil.ISSIGN.get(block)) {
      // Only check the 'isBuildable' state of the Material
      Object attachedHandle = Conversion.toBlockHandle.convert(attached);
      if (attachedHandle == null) {
        return false;
View Full Code Here

    }
  }

  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onBlockPhysics(BlockPhysicsEvent event) {
    final Block block = event.getBlock();
    final Material type = block.getType();
    if (MaterialUtil.ISSIGN.get(type)) {
      if (Util.isSupported(block)) {
        // Check for potential redstone changes
        updateRedstonePower(block);
      } else {
        // Remove from block power storage
        poweredBlocks.remove(block);
      }
    } else if (MaterialUtil.ISREDSTONETORCH.get(type)) {
      // Send proper update events for all signs around this power source
      for (BlockFace face : FaceUtil.RADIAL) {
        final Block rel = event.getBlock().getRelative(face);
        if (MaterialUtil.ISSIGN.get(rel)) {
          CommonUtil.nextTick(new Runnable() {
            public void run() {
              updateRedstonePower(rel);
            }
View Full Code Here

    if (TrainCarts.isWorldDisabled(event)) {
      return;
    }
    Material type = event.getBlock().getType();
    if (BlockUtil.isType(type, Material.LEVER)) {
      Block up = event.getBlock().getRelative(BlockFace.UP);
      Block down = event.getBlock().getRelative(BlockFace.DOWN);
      if (MaterialUtil.ISSIGN.get(up)) {
        updateRedstonePower(up, event.getNewCurrent() > 0);
      }
      if (MaterialUtil.ISSIGN.get(down)) {
        updateRedstonePower(down, event.getNewCurrent() > 0);
View Full Code Here

   *
   * @param lever to ignore
   */
  public void ignoreOutputLever(Block lever) {
    // Ignore signs that are attached to the block the lever is attached to
    Block att = BlockUtil.getAttachedBlock(lever);
    for (BlockFace face : FaceUtil.ATTACHEDFACES) {
      Block signblock = att.getRelative(face);
      if (MaterialUtil.ISSIGN.get(signblock) && BlockUtil.getAttachedFace(signblock) == face.getOppositeFace()) {
        if (ignoredSigns.isEmpty()) {
          // clear this the next tick
          CommonUtil.nextTick(new Runnable() {
            public void run() {
View Full Code Here

        if (!lowercase.equalsIgnoreCase("random")) {
            if (arena.getSettings().getBoolean("use-class-chests", false)) {
                Location loc = ac.getClassChest();
                if (loc != null) {
                    Block blockChest = loc.getBlock();
                    InventoryHolder holder = (InventoryHolder) blockChest.getState();
                    ItemStack[] contents = holder.getInventory().getContents();
                    // Guard against double-chests for now
                    if (contents.length > 36) {
                        ItemStack[] newContents = new ItemStack[36];
                        System.arraycopy(contents, 0, newContents, 0, 36);
View Full Code Here

        else if (copy_cuboid != null) locations.addAll(copy_cuboid.getBlockLocations());


        for (Location loc : locations) {

            Block source = copy_location.getBlock();
            BlockState sourceState = source.getState();
            Block update = destination.getBlock();

            update.setTypeIdAndData(source.getTypeId(), source.getData(), false);

            BlockState updateState = update.getState();

            // Note: only a BlockState, not a Block, is actually an instance
            // of InventoryHolder
            if (sourceState instanceof InventoryHolder) {
View Full Code Here

                }

                Viewer viewer = new Viewer(id, content, location);
                viewers.put(id, viewer);

                final Block sign = location.getBlock();
                sign.setType(Material.valueOf(type.name()));

                if (direction != null)
                    Utilities.setSignRotation(sign.getState(), direction);
                else
                    Utilities.setSignRotation(sign.getState());

                int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {
                    public void run() {
                        Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
                        if (player == null)
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{"", viewers.get(id).getContent().split("; ")[1], "is offline.", ""});
                        else
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{String.valueOf((int) player.getLocation().getX()), String.valueOf((int) player.getLocation().getY()), String.valueOf((int) player.getLocation().getZ()), player.getWorld().getName()});

                    }
                }, 0, 20);

                viewer.setTask(task);
                viewer.save();

                break;


            case MODIFY:
                if (!viewers.containsKey(id)) {
                    dB.echoDebug(scriptEntry, "Viewer ID " + id + " doesn't exist!");
                    return;
                }
                if (content != null) viewers.get(id).setContent(content);
                if (location != null) {
                    if (type == null) type = Type.valueOf(viewers.get(id).getLocation().getBlock().getType().name());
                    Bukkit.getScheduler().cancelTask(viewers.get(id).getTask());
                    int newTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {
                        public void run() {
                            Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
                            if (player == null)
                                Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{"", viewers.get(id).getContent().split("; ")[1], "is offline.", ""});
                            else
                                Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{String.valueOf((int) player.getLocation().getX()), String.valueOf((int) player.getLocation().getY()), String.valueOf((int) player.getLocation().getZ()), player.getWorld().getName()});

                        }
                    }, 0, 20);
                    viewers.get(id).getLocation().getBlock().setType(Material.AIR);
                    viewers.get(id).setLocation(location);
                    viewers.get(id).setTask(newTask);
                    location.getBlock().setType(Material.valueOf(type.name()));
                }

                break;

            case REMOVE:
                if (!viewers.containsKey(id)) {
                    dB.echoDebug(scriptEntry, "Viewer ID " + id + " doesn't exist!");
                    return;
                }

                Block block = viewers.get(id).getLocation().getBlock();
                block.setType(Material.AIR);

                Bukkit.getScheduler().cancelTask(viewers.get(id).getTask());
                viewers.get(id).remove();
                viewers.remove(id);
        }
View Full Code Here

        dB.report(scriptEntry, getName(), typeElement.debug()
                                          + location.debug()
                                          + text.debug());

        Type type = Type.valueOf(typeElement.asString().toUpperCase());
        Block sign = location.getBlock();
        if (type != Type.AUTOMATIC
                || (sign.getType() != Material.WALL_SIGN
                && sign.getType() != Material.SIGN_POST))
            sign.setType(type == Type.WALL_SIGN ? Material.WALL_SIGN: Material.SIGN_POST);
        BlockState signState = sign.getState();

        Utilities.setSignLines((Sign) signState, text.toArray(4));
        if (direction != null)
            Utilities.setSignRotation(signState, direction);
        else if (type == Type.WALL_SIGN)
View Full Code Here

TOP

Related Classes of org.bukkit.block.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.