Class PlaceholderType<T>

java.lang.Object
studio.magemonkey.codex.legacy.placeholder.PlaceholderType<T>
Type Parameters:
T - type of placeholder object.

public class PlaceholderType<T> extends Object
Represent type of placeholder, like Player for player.name.

Class contains also public static instances of basic types.
  • Field Details

    • OBJECT

      public static final PlaceholderType<Object> OBJECT
      Object placeholder type, used by simple placeholders without any type, like just "points" instead of some object like "player.points"
  • Constructor Details

    • PlaceholderType

      public PlaceholderType(String id, Class<T> type)
      Construct new placeholder type for given id and class without any super types.
      Parameters:
      id - id of placeholder.
      type - type of placeholder object.
    • PlaceholderType

      public PlaceholderType(String id, Class<T> type, Collection<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.
    • 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

      public static <T> PlaceholderItem<T> getQualifiedItem(String fullId)
    • 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

      public static <T> PlaceholderType<? super T> get(String id)
      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

      public void registerItem(PlaceholderItem<T> item)
      Register new placeholder item to this placeholder type.
      Parameters:
      item - item to register.
    • registerItem

      public PlaceholderItem<T> registerItem(PlaceholderType<T> type, String id, Function<T,Object> func)
      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 return String or BaseComponent, when using BaseComponent you may add click events, hovers events and all that stuff.
      Returns:
      Created placeholder.
    • registerItem

      public PlaceholderItem<T> registerItem(String id, Function<T,Object> func)
      Register new placeholder item to this placeholder type.
      Parameters:
      id - id/name of placeholder, like that "name" in player.name.
      func - function that should return String or BaseComponent, when using BaseComponent you may add click events, hovers events and all that stuff.
      Returns:
      Created placeholder.
    • registerChild

      public <C> void registerChild(String name, PlaceholderType<C> type, Function<T,C> converter)
      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

      public PlaceholderItem<?> getItem(String id)
      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

      public String getId()
      Returns id of this type, like "player" for player.name.
      Returns:
      id of this type.
    • getType

      public Class<T> getType()
      Returns class type of this type, like Player for player.name.
      Returns:
      class type of this type.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object