Skip to content

Commit

Permalink
Fix lore not showing for keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Apr 28, 2024
1 parent 203203c commit 7d20f7a
Showing 1 changed file with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class ItemBuilder {
// Display
private String displayName = "";
private List<String> displayLore = new ArrayList<>();
private List<Component> componentLore = new ArrayList<>();
private int itemDamage = 0;

// Model Data
Expand Down Expand Up @@ -747,7 +748,24 @@ public ItemBuilder removeNamePlaceholder(String placeholder) {
public ItemBuilder setLore(List<String> lore) {
if (lore != null) {
this.displayLore.clear();
this.displayLore.addAll(lore);

lore.forEach(this::addLore);
}

return this;
}

/**
* Set the lore of the item in the builder. This will auto force color in all the lores that contains color code. (<green>, <red>, <gray>, etc...)
*
* @param lore the lore of the item in the builder.
* @return the ItemBuilder with updated info.
*/
public ItemBuilder setComponentLore(List<Component> lore) {
if (lore != null) {
this.componentLore.clear();

lore.forEach(this::addLore);
}

return this;
Expand Down Expand Up @@ -784,6 +802,18 @@ public ItemBuilder addLore(String line) {
return this;
}

/**
* Add a line to the current lore of the item. This will auto force color in the lore that contains color code. (<green>, <red>, <gray>, etc...)
*
* @param line the new line you wish to add.
* @return the ItemBuilder with updated info.
*/
public ItemBuilder addLore(Component line) {
if (line != null) this.componentLore.add(line);

return this;
}

/**
* Set the placeholders that are in the lore of the item.
*
Expand Down Expand Up @@ -815,6 +845,10 @@ public ItemBuilder addLorePlaceholder(String placeholder, String argument) {
* @return the lore with all placeholders in it.
*/
public List<Component> getUpdatedLore() {
if (!this.componentLore.isEmpty()) {
return this.componentLore;
}

List<Component> newLore = new ArrayList<>();

for (String item : this.displayLore) {
Expand Down Expand Up @@ -1077,11 +1111,11 @@ public ItemBuilder setGlow(boolean glow) {
* @return the ItemStack as an ItemBuilder with all the info from the item.
*/
public static ItemBuilder convertItemStack(ItemStack item) {
return new ItemBuilder(item).setAmount(item.getAmount()).addEnchantments(new HashMap<>(item.getEnchantments()), true);
return new ItemBuilder(item).setComponentLore(item.lore()).setAmount(item.getAmount()).addEnchantments(new HashMap<>(item.getEnchantments()), true);
}

public static ItemBuilder convertItemStack(ItemStack item, Player player) {
return new ItemBuilder(item).setTarget(player).setAmount(item.getAmount()).addEnchantments(new HashMap<>(item.getEnchantments()), true);
return new ItemBuilder(item).setTarget(player).setComponentLore(item.lore()).setAmount(item.getAmount()).addEnchantments(new HashMap<>(item.getEnchantments()), true);
}

/**
Expand Down

0 comments on commit 7d20f7a

Please sign in to comment.