Package redempt.redlib.itemutils
Class LoreStats
java.lang.Object
redempt.redlib.itemutils.LoreStats
Represents stats or other info stored in item lore
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Gets a double stat from loredouble
Gets a double stat from loreint
Gets an int stat from loreint
Gets an int stat from loreGets a stat in String form from the lore of an itemorg.bukkit.inventory.ItemStack
Sets the stat on the given item to the given object, which will be cast to a Stringvoid
setFixedLore
(boolean fixedLore) True by default.
-
Constructor Details
-
LoreStats
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
Gets a stat in String form from the lore of an item- Parameters:
item
- The item to check the stat onplaceholder
- The placeholder to use, without percent signs.- Returns:
- The String stat found, or null if none was found
-
getInt
Gets an int stat from lore- Parameters:
item
- The item to check the stat onplaceholder
- The placeholder to use, without percent signs- Returns:
- The int stat found
- Throws:
NullPointerException
- if the stat was not found
-
getInt
Gets an int stat from lore- Parameters:
item
- The item to check the stat onplaceholder
- The placeholder to use, without percent signsdefaultValue
- The default value to use if no value was found in the lore- Returns:
- The int stat found, or the default value
-
getDouble
Gets a double stat from lore- Parameters:
item
- The item to check the stat onplaceholder
- 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 onplaceholder
- The placeholder to use, without percent signsdefaultValue
- 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 onplaceholder
- The placeholder stat to setobj
- The object to set the stat to- Returns:
- The modified ItemStack, or null if it could not be modified
-