-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move papi dependency from config class (see revert) to ConfiguredPlac…
…eholderAPIStack class.
- Loading branch information
Showing
3 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...re/src/main/java/com/eternalcode/formatter/placeholder/ConfiguredPlaceholderAPIStack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.eternalcode.formatter.placeholder; | ||
|
||
import com.eternalcode.formatter.config.PluginConfig; | ||
import java.util.Map; | ||
import me.clip.placeholderapi.PlaceholderAPI; | ||
import org.bukkit.entity.Player; | ||
|
||
public class ConfiguredPlaceholderAPIStack implements PlayerPlaceholderStack { | ||
|
||
private final PluginConfig pluginConfig; | ||
|
||
public ConfiguredPlaceholderAPIStack(PluginConfig pluginConfig) { | ||
this.pluginConfig = pluginConfig; | ||
} | ||
|
||
@Override | ||
public String apply(String text, Player target) { | ||
String value = text; | ||
|
||
value = PlaceholderAPI.setPlaceholders(target, value); | ||
|
||
for (Map.Entry<String, String> entry : this.pluginConfig.placeholders.entrySet()) { | ||
value = value.replace(entry.getKey(), entry.getValue()); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
} |