Skip to content

Commit 44f3145

Browse files
committed
Cleanup has placeholder check
1 parent ef59acf commit 44f3145

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/main/java/me/rothes/protocolstringreplacer/replacer/ReplacerManager.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,22 +450,18 @@ public List<Integer> getPapiIndexes(@Nonnull List<Replaceable> replaceables) {
450450
}
451451

452452
public boolean hasPlaceholder(@NotNull String string) {
453-
boolean headFound = false;
454-
boolean tailFound = false;
455-
for(int i = 0; i < string.length(); i++) {
456-
char Char = string.charAt(i);
457-
if (!headFound) {
458-
if (Char == papiHead) {
459-
headFound = true;
460-
}
461-
} else {
462-
if (Char == papiTail) {
463-
tailFound = true;
464-
break;
453+
boolean findHead = true;
454+
for(int i = 0, length = string.length(); i < length; i++) {
455+
char ch = string.charAt(i);
456+
if (findHead) {
457+
if (ch == papiHead) {
458+
findHead = false;
465459
}
460+
} else if (ch == papiTail) {
461+
return true;
466462
}
467463
}
468-
return tailFound;
464+
return false;
469465
}
470466

471467
public String setPlaceholder(@NotNull PsrUser user, @NotNull String string) {

0 commit comments

Comments
 (0)