/** * Applies a list of transformation on a block, if the block is not protected. * * @param toTransform the Bukkit block object to transform * @param transformations the list if transformations to apply */ public static void transform(Block toTransform, List<List<String>> transformations) { if (isBlockProtected(toTransform)) { return; } for (List<String> toCheck : transformations) { ArrayList<String[]> stateIndex = new ArrayList<String[]>(); for (int i = 0; i != 2; ++i) { String got = toCheck.get(i); if (got.contains(":")) { // Check for data _ appended. stateIndex.add(got.split(":")); } else { stateIndex.add(new String[] {got, "0"}); } } String[] curState = stateIndex.get(0), toState = stateIndex.get(1); if (Integer.valueOf(curState[0]) == toTransform.getTypeId() && Integer.valueOf(curState[1]) == toTransform.getData()) { toTransform.setTypeIdAndData(Integer.valueOf(toState[0]), Byte.parseByte(toState[1]), true); return; } } }