Merge pull request #1016 from joerez/feature/1015/goal-revamps

#1015 Feature/1015/goal revamps
This commit is contained in:
Leijurv 2019-10-05 19:42:02 -07:00 committed by GitHub
commit 6e1e355a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,8 +26,7 @@ import java.util.stream.Stream;
public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
INSTANCE;
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)|)$");
private static Pattern PATTERN = Pattern.compile("^(~?)([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)([k-k]?)|)$");
@Override
public Double apply(IDatatypeContext ctx, Double origin) throws CommandException {
@ -41,7 +40,15 @@ public enum RelativeCoordinate implements IDatatypePost<Double, Double> {
}
boolean isRelative = !matcher.group(1).isEmpty();
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2));
double offset = matcher.group(2).isEmpty() ? 0 : Double.parseDouble(matcher.group(2).replaceAll("k", ""));
if (matcher.group(2).contains("k")) {
String newString = matcher.group(2).replaceAll("k", "");
double convertedNumber = Double.parseDouble(newString);
convertedNumber = convertedNumber * 1000;
offset = convertedNumber;
}
if (isRelative) {
return origin + offset;