MCPcopy Create free account
hub / github.com/boxbeam/RedLib / getStat

Method getStat

src/redempt/redlib/itemutils/LoreStats.java:85–97  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

getIntMethod · 0.95
getDoubleMethod · 0.95

Calls 6

getLineMethod · 0.95
getPosStartMethod · 0.95
getPosFromEndMethod · 0.95
getLoreMethod · 0.80
getMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected