Skip to content

Commit

Permalink
Test a possible fix for duplicated ItemStacks not merging until serve…
Browse files Browse the repository at this point in the history
…r restart or play reload
  • Loading branch information
Burchard36 committed Dec 11, 2021
1 parent 1952180 commit 9c7530a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/burchard36/inventory/ItemWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.burchard36.ApiLib;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
Expand All @@ -22,6 +23,7 @@ public class ItemWrapper {
private ItemMeta itemMeta;
private String displayName = null;
private List<String> lore = null;
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().build();

public ItemWrapper(final ItemStack stack) {
this.itemStack = stack;
Expand All @@ -47,7 +49,7 @@ public final List<String> getLore() {
public final ItemWrapper setDisplayName(final String displayName) {
if (this.itemMeta == null) return this;
this.displayName = displayName;
this.itemMeta.displayName(Component.text(convert(displayName)));
this.itemMeta.displayName(serializer.deserialize(convert(this.displayName)));
this.itemStack.setItemMeta(this.itemMeta);
return this;
}
Expand All @@ -57,9 +59,10 @@ public final ItemWrapper setItemLore(final List<String> itemLore) {
this.lore = itemLore;
final List<Component> colored = new ArrayList<>();
itemLore.forEach((loreItem) -> {
colored.add(Component.text(convert(loreItem)));
colored.add(serializer.deserialize(convert(loreItem)));
});
this.itemMeta.lore(colored);

this.itemStack.setItemMeta(this.itemMeta);
return this;
}
Expand Down

0 comments on commit 9c7530a

Please sign in to comment.