Skip to content

Commit 423420f

Browse files
committed
✨ Add loreTexts method for retrieving lore as Text objects
1 parent 8a17dec commit 423420f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • src/main/java/com/marcusslover/plus/lib/item

src/main/java/com/marcusslover/plus/lib/item/Item.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,26 @@ public boolean hasName() {
209209
return this.hasLore() ? ColorUtil.translateList(this.meta().getLore()) : new ArrayList<>();
210210
}
211211

212+
/**
213+
* Retrieves the lore text from the item's metadata if it exists.
214+
* The lore is a collection of additional text associated with the item.
215+
*
216+
* @return A list of {@link Text} objects representing the lore if present,
217+
* or null if the item has no metadata, no lore, or the lore is empty.
218+
* @since 4.4.0
219+
*/
220+
public @Nullable List<Text> loreTexts() {
221+
ItemMeta itemMeta = this.meta();
222+
if (itemMeta == null || !itemMeta.hasLore()) {
223+
return null;
224+
}
225+
List<Component> loreComponents = itemMeta.lore();
226+
if (loreComponents == null) {
227+
return null;
228+
}
229+
return loreComponents.stream().map(Text::of).toList();
230+
}
231+
212232
/**
213233
* Retrieves the lore components of the item.
214234
* If the item meta is null or does not contain lore, an empty list is returned.

0 commit comments

Comments
 (0)