Skip to content

Commit

Permalink
Add a code that allows empty-lines in the description.
Browse files Browse the repository at this point in the history
Only empty lines that appears due generation will be removed.
  • Loading branch information
BONNe committed Mar 2, 2021
1 parent eb7862f commit 1151726
Showing 1 changed file with 85 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,49 @@ protected List<String> generateGeneratorDescription(GeneratorTierObject generato
// Get status in single string
String status = this.generateStatusDescription(generator, isActive, isUnlocked, isPurchased);

String returnString = this.user.getTranslation(reference + "lore",
Constants.DESCRIPTION, description,
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// Remove empty lines and returns as a list.

return Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());
if (!description.replaceAll("(?m)^[ \\t]*\\r?\\n", "").isEmpty())
{
String returnString = this.user.getTranslation(reference + "lore",
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// remove empty lines from the generated text.
List<String> collect =
Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());

// find and replace description from collected blocks.

for (int i = 0; i < collect.size(); i++)
{
if (collect.get(i).contains(Constants.DESCRIPTION))
{
collect.set(i, collect.get(i).replace(Constants.DESCRIPTION, description));
}
}

return collect;
}
else
{
String returnString = this.user.getTranslation(reference + "lore",
Constants.DESCRIPTION, description,
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// Remove empty lines and returns as a list.

return Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());
}
}


Expand Down Expand Up @@ -181,19 +211,49 @@ protected List<String> generateGeneratorDescription(GeneratorTierObject generato
// Get status in single string
String status = this.generateStatusDescription(generator, false, true, false);

String returnString = this.user.getTranslation(reference + "lore",
Constants.DESCRIPTION, description,
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// Remove empty lines and returns as a list.
if (!description.replaceAll("(?m)^[ \\t]*\\r?\\n", "").isEmpty())
{
String returnString = this.user.getTranslation(reference + "lore",
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// remove empty lines from the generated text.
List<String> collect =
Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());

// find and replace description from collected blocks.

for (int i = 0; i < collect.size(); i++)
{
if (collect.get(i).contains(Constants.DESCRIPTION))
{
collect.set(i, collect.get(i).replace(Constants.DESCRIPTION, description));
}
}

return Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());
return collect;
}
else
{
String returnString = this.user.getTranslation(reference + "lore",
Constants.DESCRIPTION, description,
"[blocks]", blocks,
"[treasures]", treasures,
"[requirements]", requirements,
"[type]", type,
"[status]", status);

// Remove empty lines and returns as a list.

return Arrays.stream(returnString.replaceAll("(?m)^[ \\t]*\\r?\\n", "").
split("\n")).
collect(Collectors.toList());
}
}


Expand Down

0 comments on commit 1151726

Please sign in to comment.