Skip to content

Commit

Permalink
Fix apply PAPI method
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed Mar 4, 2025
1 parent 40b5448 commit da0e62c
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,10 @@ public boolean isPrimaryThread() {
return Bukkit.isPrimaryThread();
}

private final WeakHashMap<Player, Pattern> playerPatternMap = new WeakHashMap<>();
private static final Pattern PLAYER_PATTERN = Pattern.compile("\\{player}");

/**
* Applies {player} internal placeholder (using cache for patterns) and PAPI placeholders
* for the player while respecting the plugin config.
* Applies {player} internal placeholder and PAPI placeholders for the player while respecting the plugin config.
*
* @param type type of config option
* @param player the player to apply placeholders for
Expand All @@ -998,8 +997,7 @@ public boolean isPrimaryThread() {

// Handle internal {player} replacement
if (player != null) {
final Pattern pattern = this.playerPatternMap.computeIfAbsent(player, key -> Pattern.compile('{' + key.getName() + '}', Pattern.LITERAL));
str = pattern.matcher(str).replaceAll(player.getName());
str = PLAYER_PATTERN.matcher(str).replaceAll(player.getName());
}

// Handle PlaceholderAPI placeholders
Expand Down

0 comments on commit da0e62c

Please sign in to comment.