Class FontImageWrapper

java.lang.Object
dev.lone.itemsadder.api.FontImages.FontImageWrapper

public class FontImageWrapper extends Object
Wrapper for an ItemsAdder font image.
  • Constructor Details

    • FontImageWrapper

      public FontImageWrapper(String namespacedID) throws IllegalArgumentException
      Creates a font image wrapper.
      Parameters:
      namespacedID - the font image namespaced id.
      Throws:
      IllegalArgumentException - if the namespaced id is null, empty, or not registered.
  • Method Details

    • instance

      public static FontImageWrapper instance(String namespacedID)
      Creates a font image wrapper if the font image exists.
      Parameters:
      namespacedID - the font image namespaced id.
      Returns:
      the wrapper, or null if the font image does not exist.
    • getNamespacedIdsInRegistry

      public static Set<String> getNamespacedIdsInRegistry()
      Gets all font image namespaced ids currently registered.
      Returns:
      the registered font image namespaced ids.
    • getNamespacedIdsAndValueInRegistry

      public static Map<String,String> getNamespacedIdsAndValueInRegistry()
      Gets all font image namespaced ids and their unicode values.
      Returns:
      a map of namespaced ids to unicode values.
    • replaceFontImages

      public static String replaceFontImages(String string)
      Replaces font image placeholders in a string.
      Parameters:
      string - the source string.
      Returns:
      the string with font images replaced.
    • replaceFontImages

      @NotNull public static @NotNull net.kyori.adventure.text.Component replaceFontImages(net.kyori.adventure.text.Component adventureComponent)
      Replaces font image placeholders in an Adventure component.
      Parameters:
      adventureComponent - the source component.
      Returns:
      the component with font images replaced.
    • replaceFontImages

      public static String replaceFontImages(Permissible player, String string)
      Replaces font image placeholders in a string using player permissions.
      Parameters:
      player - the permissible used for permission checks.
      string - the source string.
      Returns:
      the string with font images replaced.
    • replaceFontImages

      @NotNull public static @NotNull net.kyori.adventure.text.Component replaceFontImages(Permissible player, net.kyori.adventure.text.Component adventureComponent)
      Replaces font image placeholders in an Adventure component using player permissions.
      Parameters:
      player - the permissible used for permission checks.
      adventureComponent - the source component.
      Returns:
      the component with font images replaced.
    • applyPixelsOffsetToString

      public static String applyPixelsOffsetToString(String str, int offset)
      Applies a pixel offset to a string.
      Parameters:
      str - the source string.
      offset - the pixel offset.
      Returns:
      the shifted string.
    • getNamespacedID

      public String getNamespacedID()
      Gets the font image namespaced id.
      Returns:
      the namespaced id.
    • exists

      public boolean exists()
      Checks if the wrapped font image exists.
      Returns:
      true if the internal font image is present.
    • getString

      public String getString()
      Gets the font image string with the current offset applied.
      Returns:
      the font image string.
    • getWidth

      public int getWidth()
      Gets the font image width.
      Returns:
      the width in pixels.
    • getHeight

      public int getHeight()
      Gets the font image height.
      Returns:
      the height in pixels.
    • applyPixelsOffset

      @Deprecated public String applyPixelsOffset(int offset)
      Deprecated.
      use setOffset(int) and getString() instead.
      Applies an offset to this wrapper and returns the shifted font image string.
      Parameters:
      offset - the pixel offset.
      Returns:
      the shifted font image string.
    • getColor

      public net.kyori.adventure.text.format.TextColor getColor()
      Gets the current font image color.
      Returns:
      the current text color.
    • setColor

      public FontImageWrapper setColor(net.kyori.adventure.text.format.TextColor color)
      Sets the font image color.
      Parameters:
      color - the new text color.
      Returns:
      this wrapper.
    • setColor

      public FontImageWrapper setColor(ChatColor bukkitChatColor)
      Sets the font image color from a Bukkit chat color.
      Parameters:
      bukkitChatColor - the Bukkit chat color.
      Returns:
      this wrapper.
    • setOffset

      public FontImageWrapper setOffset(int offset)
      Sets the pixel offset applied to this font image.
      Parameters:
      offset - the pixel offset.
      Returns:
      this wrapper.
    • getOffset

      public int getOffset()
      Gets the current pixel offset.
      Returns:
      the current pixel offset.
    • internalGetUnicode

      public String internalGetUnicode()
      INTERNAL USE ONLY!