Пример #1
0
  @Override
  public boolean isCustomBlock(Block block) {

    if (!(block instanceof SpoutCraftBlock)) {
      return false;
    }

    boolean outcome = false;

    SpoutCraftBlock scb = (SpoutCraftBlock) block;

    Integer blockId = scb.getCustomBlockId();
    Integer metaData = scb.getCustomMetaData();

    if (blockId != null && metaData != null) {
      outcome = true;
    }

    return outcome;
  }
Пример #2
0
  public boolean overrideBlock(Block block, Integer blockId, Integer metaData) {

    if (!(block instanceof SpoutCraftBlock)) {
      return false;
    }

    SpoutCraftBlock scb = (SpoutCraftBlock) block;

    if (blockId == null || metaData == null) {
      scb.removeCustomBlockData();
    } else {
      scb.setCustomBlockId(blockId);
      scb.setCustomMetaData(metaData);
    }

    Player[] players = block.getWorld().getPlayers().toArray(new Player[0]);

    sendBlockOverrideToPlayers(players, block, blockId, metaData);

    return true;
  }
Пример #3
0
  public boolean sendBlockOverrideToPlayers(Player[] players, Chunk chunk) {

    SpoutCraftChunk scc = getSpoutCraftChunk(chunk);
    if (scc == null) {
      return false;
    }

    BlockVector[] blocks = scc.getTaggedBlocks();

    if (blocks == null) {
      return false;
    }

    boolean success = true;
    for (BlockVector block : blocks) {
      correctBlockVector(block, scc);

      SpoutCraftBlock scb =
          getSpoutCraftBlock(
              chunk.getWorld().getBlockAt(block.getBlockX(), block.getBlockY(), block.getBlockZ()));

      if (scb == null) {
        success = false;
        continue;
      }

      Integer blockId = scb.getCustomBlockId();
      Integer metaData = scb.getCustomMetaData();

      if (blockId != null && metaData != null) {
        sendBlockOverrideToPlayers(players, block, blockId, metaData);
      }
    }

    return success;
  }