Class LoreStats

java.lang.Object
redempt.redlib.itemutils.LoreStats

public class LoreStats extends Object
Represents stats or other info stored in item lore
  • Constructor Summary

    Constructors
    Constructor
    Description
    LoreStats(List<String> lines, String... placeholders)
    Create a LoreStats from a list of lore lines and a vararg of placeholder names
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getDouble(org.bukkit.inventory.ItemStack item, String placeholder)
    Gets a double stat from lore
    double
    getDouble(org.bukkit.inventory.ItemStack item, String placeholder, double defaultValue)
    Gets a double stat from lore
    int
    getInt(org.bukkit.inventory.ItemStack item, String placeholder)
    Gets an int stat from lore
    int
    getInt(org.bukkit.inventory.ItemStack item, String placeholder, int defaultValue)
    Gets an int stat from lore
    getStat(org.bukkit.inventory.ItemStack item, String placeholder)
    Gets a stat in String form from the lore of an item
    org.bukkit.inventory.ItemStack
    set(org.bukkit.inventory.ItemStack item, String placeholder, Object obj)
    Sets the stat on the given item to the given object, which will be cast to a String
    void
    setFixedLore(boolean fixedLore)
    True by default.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LoreStats

      public LoreStats(List<String> lines, String... placeholders)
      Create a LoreStats from a list of lore lines and a vararg of placeholder names
      Parameters:
      lines - The lines of lore to load. Placeholders should be surrounded by percent signs.
      placeholders - Placeholder names, WITHOUT being surrounded by percent signs
  • Method Details

    • setFixedLore

      public void setFixedLore(boolean fixedLore)
      True by default. Set to true if the lore lines on the item will always show up at the same positions as what was originally passed when constructing these LoreStats, false if the lore might be on different lines.
      Parameters:
      fixedLore - Whether the lines of the lore should be fixed
    • getStat

      public String getStat(org.bukkit.inventory.ItemStack item, String placeholder)
      Gets a stat in String form from the lore of an item
      Parameters:
      item - The item to check the stat on
      placeholder - The placeholder to use, without percent signs.
      Returns:
      The String stat found, or null if none was found
    • getInt

      public int getInt(org.bukkit.inventory.ItemStack item, String placeholder)
      Gets an int stat from lore
      Parameters:
      item - The item to check the stat on
      placeholder - The placeholder to use, without percent signs
      Returns:
      The int stat found
      Throws:
      NullPointerException - if the stat was not found
    • getInt

      public int getInt(org.bukkit.inventory.ItemStack item, String placeholder, int defaultValue)
      Gets an int stat from lore
      Parameters:
      item - The item to check the stat on
      placeholder - The placeholder to use, without percent signs
      defaultValue - The default value to use if no value was found in the lore
      Returns:
      The int stat found, or the default value
    • getDouble

      public double getDouble(org.bukkit.inventory.ItemStack item, String placeholder)
      Gets a double stat from lore
      Parameters:
      item - The item to check the stat on
      placeholder - The placeholder to use, without percent signs
      Returns:
      The double stat found
      Throws:
      NullPointerException - if the stat was not found
    • getDouble

      public double getDouble(org.bukkit.inventory.ItemStack item, String placeholder, double defaultValue)
      Gets a double stat from lore
      Parameters:
      item - The item to check the stat on
      placeholder - The placeholder to use, without percent signs
      defaultValue - The default value to use if no value was found in the lore
      Returns:
      The double stat found, or the default value
    • set

      public org.bukkit.inventory.ItemStack set(org.bukkit.inventory.ItemStack item, String placeholder, Object obj)
      Sets the stat on the given item to the given object, which will be cast to a String
      Parameters:
      item - The item to set the stat on
      placeholder - The placeholder stat to set
      obj - The object to set the stat to
      Returns:
      The modified ItemStack, or null if it could not be modified