mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-08-07 04:53:04 +00:00
Added PlaceholderAPI support
This commit is contained in:
parent
5f0b4905ae
commit
2d7c78a06c
15 changed files with 115 additions and 69 deletions
|
@ -0,0 +1,33 @@
|
|||
package dev.esophose.playerparticles.hook;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
public final class PlaceholderAPIHook {
|
||||
|
||||
private static Boolean enabled;
|
||||
|
||||
/**
|
||||
* @return true if PlaceholderAPI is enabled, otherwise false
|
||||
*/
|
||||
public static boolean enabled() {
|
||||
if (enabled != null)
|
||||
return enabled;
|
||||
return enabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies placeholders from PlaceholderAPI to strings
|
||||
*
|
||||
* @param player The Player to apply placeholders with
|
||||
* @param text The text to replace placeholders
|
||||
* @return A string with replaced placeholders
|
||||
*/
|
||||
public static String applyPlaceholders(Player player, String text) {
|
||||
if (enabled())
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue