/** * Validates the IC's environment. The position of the sign is given. Return a string in order to * state an error message and deny creation, otherwise return null to allow. * * @param sign * @return */ @Override public String validateEnvironment(CraftBookWorld cbworld, Vector pos, SignText sign) { String id = sign.getLine3().toLowerCase(); if (id.length() != 0) { if (id.length() < 3 || id.charAt(1) != ':' || (id.charAt(0) != 'g' && id.charAt(0) != 'p')) { return "Invalid player or group name on Third line."; } } if (sign.getLine4().isEmpty()) { sign.setLine4("1"); } else { try { int damage = Integer.parseInt(sign.getLine4()); if (damage > 20 || damage < 1) return "4th line damage value must be a number from 1 to 20"; } catch (NumberFormatException e) { return "4th line must be a number."; } } return null; }