@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; }
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; }
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; }