Class PlaceholderType<T>
java.lang.Object
studio.magemonkey.codex.legacy.placeholder.PlaceholderType<T>
- Type Parameters:
T- type of placeholder object.
Represent type of placeholder, like Player for player.name.
Class contains also public static instances of basic types.
Class contains also public static instances of basic types.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PlaceholderType<Object> Objectplaceholder type, used by simple placeholders without any type, like just "points" instead of some object like "player.points" -
Constructor Summary
ConstructorsConstructorDescriptionPlaceholderType(String id, Class<T> type) Construct new placeholder type for given id and class without any super types.PlaceholderType(String id, Class<T> type, Collection<PlaceholderType<? super T>> superTypes) Construct new placeholder type for given id and class with possible super typesPlaceholderType(String id, Class<T> type, PlaceholderType<? super T>... superTypes) Construct new placeholder type for given id and class with possible super types -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PlaceholderType<T> create(String id, Class<T> clazz, PlaceholderType<? super T>... superTypes) static <T> studio.magemonkey.codex.legacy.placeholder.PlaceholderType.GlobalPlaceholderType<T> createGlobal(String id, Class<T> clazz, Supplier<T> globalSupplier, PlaceholderType<? super T>... superTypes) booleanstatic <T> PlaceholderType<? super T> Get placeholder by id, note: this don't check any types.getId()Returns id of this type, like "player" for player.name.Returns item for given id, or null if there isn't any item with maching name.static <T> PlaceholderItem<T> getQualifiedItem(String fullId) getType()Returns class type of this type, like Player for player.name.inthashCode()<C> voidregisterChild(String name, PlaceholderType<C> type, Function<T, C> converter) Register new child-type to this type.registerItem(String id, Function<T, Object> func) Register new placeholder item to this placeholder type.voidregisterItem(PlaceholderItem<T> item) Register new placeholder item to this placeholder type.registerItem(PlaceholderType<T> type, String id, Function<T, Object> func) Register new placeholder item to this placeholder type.static net.md_5.bungee.api.chat.BaseComponentreplaceGlobal(net.md_5.bungee.api.chat.BaseComponent component, Map<String, Collection<PlaceholderData<?>>> placeholders) Replace global placeholders in given component.toString()
-
Field Details
-
OBJECT
Objectplaceholder type, used by simple placeholders without any type, like just "points" instead of some object like "player.points"
-
-
Constructor Details
-
PlaceholderType
Construct new placeholder type for given id and class without any super types.- Parameters:
id- id of placeholder.type- type of placeholder object.
-
PlaceholderType
Construct new placeholder type for given id and class with possible super types- Parameters:
id- id of placeholder.type- type of placeholder object.superTypes- super types of placeholder, this placeholder may use placeholder items from this types.
-
PlaceholderType
@SafeVarargs public PlaceholderType(String id, Class<T> type, PlaceholderType<? super T>... superTypes) Construct new placeholder type for given id and class with possible super types- Parameters:
id- id of placeholder.type- type of placeholder object.superTypes- super types of placeholder, this placeholder may use placeholder items from this types.
-
-
Method Details
-
getQualifiedItem
-
create
@SafeVarargs public static <T> PlaceholderType<T> create(String id, Class<T> clazz, PlaceholderType<? super T>... superTypes) -
createGlobal
@SafeVarargs public static <T> studio.magemonkey.codex.legacy.placeholder.PlaceholderType.GlobalPlaceholderType<T> createGlobal(String id, Class<T> clazz, Supplier<T> globalSupplier, PlaceholderType<? super T>... superTypes) -
replaceGlobal
public static net.md_5.bungee.api.chat.BaseComponent replaceGlobal(net.md_5.bungee.api.chat.BaseComponent component, Map<String, Collection<PlaceholderData<?>>> placeholders) Replace global placeholders in given component.
Used by message implementation classes.- Parameters:
component- message with placeholders.placeholders- placeholders in message.- Returns:
- component with replaced global placeholders.
-
get
Get placeholder by id, note: this don't check any types.- Type Parameters:
T- type of placeholder object.- Parameters:
id- id of placeholder type.- Returns:
- placeholder type or null.
-
registerItem
Register new placeholder item to this placeholder type.- Parameters:
item- item to register.
-
registerItem
Register new placeholder item to this placeholder type.- Parameters:
type- type of placeholder, like that "player" in player.name.id- id/name of placeholder, like that "name" in player.name.func- function that should returnStringorBaseComponent, when using BaseComponent you may add click events, hovers events and all that stuff.- Returns:
- Created placeholder.
-
registerItem
Register new placeholder item to this placeholder type.- Parameters:
id- id/name of placeholder, like that "name" in player.name.func- function that should returnStringorBaseComponent, when using BaseComponent you may add click events, hovers events and all that stuff.- Returns:
- Created placeholder.
-
registerChild
Register new child-type to this type.- Type Parameters:
C- child placeholder type.- Parameters:
name- key-name of type.type- child type to register.converter- function that maps to child placeholder type.
-
getItem
Returns item for given id, or null if there isn't any item with maching name.
If there is no maching item in this types, method will try get maching item from one of super types.- Parameters:
id- id of item, like "name" for player.name.- Returns:
- placeholder item or null.
-
getId
Returns id of this type, like "player" for player.name.- Returns:
- id of this type.
-
getType
Returns class type of this type, like Player for player.name.- Returns:
- class type of this type.
-
equals
-
hashCode
public int hashCode() -
toString
-