Interface PlaceholderData<T>
- Type Parameters:
T- type of placeholder item.
public interface PlaceholderData<T>
Represent placeholder found in string, it contains full string to replace, object name and placeholder item.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault ObjectDelegated method fromBasePlaceholderItemdefault booleanReturns true if this placeholder contains sub-placeholders used as arguments.default Object[]Returns array of arguments used by this placeholder.default Object[]getArguments(T obj) Returns array of parsed arguments used by this placeholder.Returns full string to replace.getItem()Returns placeholder item used in this placeholder.Returns object name, like "player" for player.name, or "killer" for player#killer.name.static Map<String, Collection<PlaceholderData<?>>> parseString(org.bukkit.plugin.Plugin api, String str, boolean warn) Get collectiona of used placeholders grouped by object name in given string.default StringUses this placeholder on given string.default net.md_5.bungee.api.chat.BaseComponentUses this placeholder on givenBaseComponent.static <T> PlaceholderData<T> valueOf(String fullName, String objectName, PlaceholderItem<T> item)
-
Field Details
-
EMPTY_OBJECTS
Empty object array.
-
-
Method Details
-
getFullName
String getFullName()Returns full string to replace.- Returns:
- full string to replace.
-
getObjectName
String getObjectName()Returns object name, like "player" for player.name, or "killer" for player#killer.name.- Returns:
- object name.
-
getItem
PlaceholderItem<T> getItem()Returns placeholder item used in this placeholder.- Returns:
- placeholder item used in this placeholder.
-
getArguments
Returns array of arguments used by this placeholder.- Returns:
- array of arguments used by this placeholder.
-
containsSubPlaceholders
default boolean containsSubPlaceholders()Returns true if this placeholder contains sub-placeholders used as arguments.- Returns:
- true if this placeholder contains sub-placeholders used as arguments.
-
getArguments
Returns array of parsed arguments used by this placeholder.- Parameters:
obj- data object used by placeholder.- Returns:
- array of parsed arguments used by this placeholder.
-
apply
Delegated method fromBasePlaceholderItem- Parameters:
obj- object to fetch the data needed for placeholder.- Returns:
- Object to use instead of placeholder.
- See Also:
-
replace
Uses this placeholder on given string.- Parameters:
str- string to use.obj- object to fetch the data needed for placeholder.- Returns:
- string with replaced placeholder.
-
replace
default net.md_5.bungee.api.chat.BaseComponent replace(net.md_5.bungee.api.chat.BaseComponent component, T obj) Uses this placeholder on givenBaseComponent.
NOTE: placeholder is replaced without duplicating given component, it will make all changes on given component.- Parameters:
component- component to use.obj- object to fetch the data needed for placeholder.- Returns:
- this same component as given.
-
valueOf
-
parseString
static Map<String,Collection<PlaceholderData<?>>> parseString(org.bukkit.plugin.Plugin api, String str, boolean warn) Get collectiona of used placeholders grouped by object name in given string.
Will return null if null string is given.- Parameters:
api- instance of api.str- string to parse.warn- if true, method will print warnings about invalid placeholders to console.- Returns:
- collection of used placeholders.
BasePlaceholderData
-