Skip to content

Commit

Permalink
Fixed incorrect parsing of top-related placeholders (#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jan 15, 2022
1 parent 9612783 commit 003ed9c
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -306,16 +306,16 @@ private static Optional<String> handleTopIslandsPlaceholder(Island island, Super
} else if ((matcher = TOP_VALUE_PLACEHOLDER_PATTERN.matcher(placeholderValue)).matches()) {
getValueFunction = targetIsland -> StringUtils.format(targetIsland.getWorth());
} else if ((matcher = TOP_LEADER_PLACEHOLDER_PATTERN.matcher(placeholderValue)).matches()) {
getValueFunction = targetIsland -> targetIsland.getOwner().getName();
} else {
getValueFunction = targetIsland -> targetIsland.getName().isEmpty() ?
targetIsland.getOwner().getName() : targetIsland.getName();
} else {
return Optional.empty();
}

int targetPosition;

try {
targetPosition = Integer.parseInt(matcher.group(1));
targetPosition = Integer.parseInt(matcher.matches() ? matcher.group(1) : placeholderValue);
} catch (NumberFormatException error) {
return Optional.empty();
}
Expand Down

0 comments on commit 003ed9c

Please sign in to comment.