Interface PlaceholderBridge
- All Superinterfaces:
Bridge
- All Known Implementing Classes:
PlaceholderApiBridge
The
PlaceholderBridge
interface defines the contract for integrating
placeholder functionality within the application. Implementations of this interface
allow for the registration and replacement of placeholders in strings, typically
used for dynamic content rendering.
This bridge is intended to be used with external placeholder plugins or systems.
It extends the Bridge
interface and provides methods for registering
custom placeholders and replacing them in input strings.
- Since:
- 1.0.4
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
Returns the name of this bridge implementation.void
registerPlaceholder
(String identifier, BiFunction<org.bukkit.entity.Player, String, String> replacer) Registers a new placeholder with the given identifier and replacement function.replacePlaceholders
(String input) Replaces all registered placeholders in the given input string with their corresponding values.replacePlaceholders
(String input, org.bukkit.entity.Player player) Replaces all registered placeholders in the given input string with their corresponding values, using the providedPlayer
context for player-specific placeholders.Methods inherited from interface dev.crafty.core.bridge.Bridge
canRegister, getName, pluginEnabled
-
Method Details
-
registerPlaceholder
void registerPlaceholder(String identifier, BiFunction<org.bukkit.entity.Player, String, String> replacer) Registers a new placeholder with the given identifier and replacement function.- Parameters:
identifier
- the unique identifier for the placeholder (e.g., "player_name")replacer
- a function that takes the input string and returns the replacement value
-
replacePlaceholders
Replaces all registered placeholders in the given input string with their corresponding values.- Parameters:
input
- the input string containing placeholders to be replaced- Returns:
- the input string with all placeholders replaced
-
replacePlaceholders
Replaces all registered placeholders in the given input string with their corresponding values, using the providedPlayer
context for player-specific placeholders.- Parameters:
input
- the input string containing placeholders to be replacedplayer
- the player whose context should be used for placeholder replacement- Returns:
- the input string with all placeholders replaced, using player context where applicable
-
bridgeName
Returns the name of this bridge implementation.- Specified by:
bridgeName
in interfaceBridge
- Returns:
- the string "Placeholder"
-