Optimize Placeholder API detection

This commit is contained in:
filoghost 2021-08-02 22:38:53 +02:00
parent 016de63f93
commit e7e27885b3
1 changed files with 7 additions and 1 deletions

View File

@ -22,7 +22,13 @@ public class PlaceholderAPIHook {
}
public static boolean containsPlaceholders(String text) {
return PlaceholderAPI.containsPlaceholders(text);
int firstIndex = text.indexOf('%');
if (firstIndex < 0) {
return false;
}
int lastIndex = text.lastIndexOf('%');
return lastIndex - firstIndex >= 2; // At least one character between the two indexes
}
public static String replacePlaceholders(Player player, String text) {