mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 12:56:48 +01:00
Fix trailing/leading space after placeholder once and for all (#427)
This commit is contained in:
parent
2d72e274e3
commit
c648d6a541
@ -100,11 +100,13 @@ public final class CharsReplacer implements Replacer {
|
|||||||
|
|
||||||
boolean identified = false;
|
boolean identified = false;
|
||||||
boolean oopsitsbad = true;
|
boolean oopsitsbad = true;
|
||||||
|
boolean hadSpace = false;
|
||||||
|
|
||||||
while (++i < chars.length) {
|
while (++i < chars.length) {
|
||||||
final char p = chars[i];
|
final char p = chars[i];
|
||||||
|
|
||||||
if (p == ' ' && !identified) {
|
if (p == ' ' && !identified) {
|
||||||
|
hadSpace = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (p == closure.tail) {
|
if (p == closure.tail) {
|
||||||
@ -137,7 +139,9 @@ public final class CharsReplacer implements Replacer {
|
|||||||
builder.append('_').append(parametersString);
|
builder.append('_').append(parametersString);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append(' ');
|
if (hadSpace) {
|
||||||
|
builder.append(' ');
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,15 +172,7 @@ public final class CharsReplacer implements Replacer {
|
|||||||
builder.append(ChatColor.translateAlternateColorCodes('&', replacement));
|
builder.append(ChatColor.translateAlternateColorCodes('&', replacement));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builder.length() == 0) {
|
return builder.toString();
|
||||||
return "";
|
|
||||||
}
|
|
||||||
char c = builder.charAt(builder.length() - 1);
|
|
||||||
if (c == ' ') {
|
|
||||||
return builder.substring(0, builder.length() - 1);
|
|
||||||
} else {
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user