public static Location<World> parseBlockLocation(Sign sign, int lPos) { return parseBlockLocation(sign, lPos, LocationCheckType.OFFSET); }
public static Vector3d parseRadius(Sign sign) { return parseRadius(sign, 2); }
public static void verifySignSyntax(Sign sign) throws CraftBookException { verifySignLocationSyntax(sign, 2); }
@Override public void load() { super.load(); if (!getLine(2).isEmpty()) { radius = ParsingUtil.parseRadius(getSign()); if(getLine(2).contains("=")) { center = ParsingUtil.parseBlockLocation(getSign()); } else { center = getBackBlock(); } } else { center = getBackBlock(); radius = new Vector3d(1, 1, 1); } if(!getLine(3).isEmpty()) { try { chance = Math.min(Integer.parseInt(getLine(3)), 100); } catch(Exception e){ chance = 100; } } else { chance = 100; } }
public static Vector3d parseRadius(String line) { Vector3d radius = new Vector3d(10,10,10); try { radius = parseUnsafeRadius(line); } catch (NumberFormatException ignored) { } return radius; }
public static Vector3d parseUnsafeRadius(String line) throws NumberFormatException { String[] radians = RegexUtil.COMMA_PATTERN.split(RegexUtil.EQUALS_PATTERN.split(line, 2)[0]); if(radians.length > 1) { double x = verifyRadius(Double.parseDouble(radians[0]), CraftBookPlugin.spongeInst().moduleController.getModule(ICSocket.class).get().getModule().get().maxRadius.getValue()); double y = verifyRadius(Double.parseDouble(radians[1]), CraftBookPlugin.spongeInst().moduleController.getModule(ICSocket.class).get().getModule().get().maxRadius.getValue()); double z = verifyRadius(Double.parseDouble(radians[2]), CraftBookPlugin.spongeInst().moduleController.getModule(ICSocket.class).get().getModule().get().maxRadius.getValue()); return new Vector3d(x,y,z); } else { double r = Double.parseDouble(radians[0]); r = verifyRadius(r, CraftBookPlugin.spongeInst().moduleController.getModule(ICSocket.class).get().getModule().get().maxRadius.getValue()); return new Vector3d(r,r,r); } }
public static Location<World> parseBlockLocation(Sign sign, String line, LocationCheckType relative) { Location<World> target = SignUtil.getBackBlock(sign.getLocation()); if (line.contains("!")) relative = LocationCheckType.getTypeFromChar('!'); else if (line.contains("^")) relative = LocationCheckType.getTypeFromChar('^'); else if (line.contains("&")) relative = LocationCheckType.getTypeFromChar('&'); Vector3d offsets = new Vector3d(0,0,0); try { offsets = parseUnsafeBlockLocation(line); } catch (NumberFormatException | ArrayIndexOutOfBoundsException ignored) { } if(offsets.getFloorX() == 0 && offsets.getFloorY() == 0 && offsets.getFloorZ() == 0) return target; switch (relative) { case RELATIVE: target = LocationUtil.getRelativeOffset(sign.getLocation(), offsets.getFloorX(), offsets.getFloorY(), offsets.getFloorZ()); break; case OFFSET: target = LocationUtil.getOffset(target, offsets.getFloorX(), offsets.getFloorY(), offsets.getFloorZ()); break; case ABSOLUTE: target = target.getExtent().getLocation(offsets.getX(), offsets.getY(), offsets.getZ()); break; } return target; }
public static Location<World> parseBlockLocation(Sign sign) { return parseBlockLocation(sign, 2, LocationCheckType.OFFSET); }
public static Vector3d parseRadius(Sign sign, int lPos) { return parseRadius(SignUtil.getTextRaw(sign, lPos)); }
public static Location<World> parseBlockLocation(Sign sign, int lPos, LocationCheckType relative) { return parseBlockLocation(sign, SignUtil.getTextRaw(sign, lPos), relative); }