Skip to content

Commit

Permalink
[F] 修复替换变量时多余的换行
Browse files Browse the repository at this point in the history
  • Loading branch information
hykilpikonna committed Aug 26, 2018
1 parent bd0d999 commit 8e0c31a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/cc/moecraft/utils/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,19 @@ public static String replaceVariables(String original, Object ... variablesAndRe
{
StringBuilder builder = new StringBuilder();

boolean first = true;
for (String line : original.split("\n"))
{
for (int i = 0; i < variablesAndReplacements.length; i += 2)
line = line.replace("%{" + String.valueOf(variablesAndReplacements[i]) + "}",
String.valueOf(variablesAndReplacements[i + 1]));

builder.append("\n").append(line);
if (first)
{
builder.append(line);
first = false;
}
else builder.append("\n").append(line);
}

return builder.toString();
Expand Down

0 comments on commit 8e0c31a

Please sign in to comment.