diff --git a/src/main/java/io/github/paexception/engelsburg/api/service/scheduled/SubstituteUpdateService.java b/src/main/java/io/github/paexception/engelsburg/api/service/scheduled/SubstituteUpdateService.java index dc1ef11..c1db930 100644 --- a/src/main/java/io/github/paexception/engelsburg/api/service/scheduled/SubstituteUpdateService.java +++ b/src/main/java/io/github/paexception/engelsburg/api/service/scheduled/SubstituteUpdateService.java @@ -311,9 +311,15 @@ private List createSubstituteDTOs(Element row, Date currentDate) private void appendTextOnLastSubstitute(Element row, List substitutes) { int indexOfLastSubstitute = substitutes.size() - 1; String textToAppend = row.children().get(row.children().size() - 1).text(); - SubstituteDTO dto = substitutes.get(indexOfLastSubstitute); - substitutes.set(indexOfLastSubstitute, dto.appendText(textToAppend)); + for (; indexOfLastSubstitute >= 0; indexOfLastSubstitute--) { + SubstituteDTO dto = substitutes.get(indexOfLastSubstitute); + substitutes.set(indexOfLastSubstitute, dto.appendText(textToAppend)); + + if (indexOfLastSubstitute > 0) { + if (!dto.sameBase(substitutes.get(indexOfLastSubstitute - 1))) break; + } + } } /**