/** Check the four sides of the base block to see if there's room for a large chest */ public static Block findLarge(Block base) { // Check all 4 sides for air. Block block; block = base.getRelative(BlockFace.NORTH); if (canBeReplaced(block.getState()) && (!Config.getInstance().getNoInterfere() || !checkChest(block, Material.CHEST))) { return block; } block = base.getRelative(BlockFace.EAST); if (canBeReplaced(block.getState()) && (!Config.getInstance().getNoInterfere() || !checkChest(block, Material.CHEST))) { return block; } block = base.getRelative(BlockFace.SOUTH); if (canBeReplaced(block.getState()) && (!Config.getInstance().getNoInterfere() || !checkChest(block, Material.CHEST))) { return block; } block = base.getRelative(BlockFace.WEST); if (canBeReplaced(block.getState()) && (!Config.getInstance().getNoInterfere() || !checkChest(block, Material.CHEST))) { return block; } return null; }
/** * Creates a sign at the specified block * * @param signBlock The block to put a sign * @param player The Player who owns the sign */ public static void createSign(Block signBlock, Player player) { String date = new SimpleDateFormat(Config.getInstance().getDateFormat()).format(new Date()); String time = new SimpleDateFormat(Config.getInstance().getTimeFormat()).format(new Date()); String name = player.getName(); signBlock.setType(Material.SIGN_POST); final Sign sign = (Sign) signBlock.getState(); for (int x = 0; x < 4; x++) { String line = Config.getInstance().getSignMessage()[x]; line = line.replace("{name}", name); line = line.replace("{date}", date); line = line.replace("{time}", time); if (line.length() > 15) { line = line.substring(0, 15); } sign.setLine(x, line); } sign.update(true); }