Пример #1
0
    @Override
    public LightStone detect(BlockWorldVector pt, LocalPlayer player)
        throws InvalidMechanismException {

      Block block = BukkitUtil.toWorld(pt).getBlockAt(BukkitUtil.toLocation(pt));
      if (block != null
          && player.getHeldItemType() == CraftBookPlugin.inst().getConfiguration().lightstoneItem
          && player.hasPermission("craftbook.mech.lightstone.use")) return new LightStone();

      return null;
    }
  /**
   * Adds a position to be used a source.
   *
   * @return
   */
  @Override
  public void addSingleSourcePosition(WorldVector arg0) {

    int x = arg0.getBlockX();
    int y = arg0.getBlockY();
    int z = arg0.getBlockZ();

    if (BukkitUtil.toWorld(arg0.getWorld()).getBlockAt(BukkitUtil.toLocation(arg0)).getTypeId()
        == BlockType.CHEST.getID()) {
      BlockState complexBlock = BukkitUtil.toWorld(arg0.getWorld()).getBlockAt(x, y, z).getState();

      if (complexBlock instanceof Chest) {
        Chest chest = (Chest) complexBlock;

        if (!chests.contains(chest)) {
          chests.add((Chest) complexBlock);
        }
      }
    }
  }