Gets a stat in String form from the lore of an item @param item The item to check the stat on @param placeholder The placeholder to use, without percent signs. @return The String stat found, or null if none was found
(ItemStack item, String placeholder)
| 83 | * @return The String stat found, or null if none was found |
| 84 | */ |
| 85 | public String getStat(ItemStack item, String placeholder) { |
| 86 | if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasLore()) { |
| 87 | return null; |
| 88 | } |
| 89 | LorePlaceholder lp = placeholders.get(placeholder); |
| 90 | List<String> lore = item.getItemMeta().getLore(); |
| 91 | int line = getLine(item, lp, placeholder); |
| 92 | if (line == -1) { |
| 93 | return null; |
| 94 | } |
| 95 | String str = lore.get(line); |
| 96 | return str.substring(lp.getPosStart(), str.length() - lp.getPosFromEnd()); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Gets an int stat from lore |
no test coverage detected