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

Method set

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

Sets the stat on the given item to the given object, which will be cast to a String @param item The item to set the stat on @param placeholder The placeholder stat to set @param obj The object to set the stat to @return The modified ItemStack, or null if it could not be modified

(ItemStack item, String placeholder, Object obj)

Source from the content-addressed store, hash-verified

161 * @return The modified ItemStack, or null if it could not be modified
162 */
163 public ItemStack set(ItemStack item, String placeholder, Object obj) {
164 if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasLore()) {
165 return null;
166 }
167 LorePlaceholder lp = placeholders.get(placeholder);
168 ItemMeta meta = item.getItemMeta();
169 List<String> lore = meta.getLore();
170 int line = getLine(item, lp, placeholder);
171 if (line == -1) {
172 return null;
173 }
174 String str = lore.get(line);
175 str = str.substring(0, lp.getPosStart()) + obj + str.substring(str.length() - lp.getPosFromEnd());
176 lore.set(line, str);
177 meta.setLore(lore);
178 item.setItemMeta(meta);
179 return item;
180 }
181
182 private static class LorePlaceholder {
183

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected