Fixed villager items having duplicate lore

This commit is contained in:
Auxilor 2020-09-13 11:24:44 +01:00
parent e42f166032
commit 6e460e2ac7
2 changed files with 8 additions and 6 deletions

View File

@ -4,6 +4,8 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.inventory.MerchantRecipe;
import java.util.Arrays;

View File

@ -39,7 +39,7 @@ public class EnchantDisplay {
*/
public static final NamespacedKey keySkip = new NamespacedKey(EcoEnchantsPlugin.getInstance(), "ecoenchantlore-skip");
private static final String prefix = ChatColor.COLOR_CHAR + "w";
private static final String prefix = "§w";
private static String normalColor;
private static String curseColor;
@ -97,6 +97,8 @@ public class EnchantDisplay {
if(meta.hasLore())
itemLore = meta.getLore();
if(itemLore == null) itemLore = new ArrayList<>();
try {
if (meta.getPersistentDataContainer().has(key, PersistentDataType.INTEGER)) {
int enchantLoreLength = meta.getPersistentDataContainer().get(key, PersistentDataType.INTEGER);
@ -137,15 +139,13 @@ public class EnchantDisplay {
if(!EnchantmentTarget.ALL.contains(item.getType()))
return oldItem;
item = revertDisplay(item);
ItemMeta meta = item.getItemMeta();
List<String> itemLore = new ArrayList<>();
int loreStart = 0;
if(meta == null) return oldItem;
item = revertDisplay(item);
if(meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER))
return oldItem;
@ -255,7 +255,7 @@ public class EnchantDisplay {
enchantLore.addAll(combinedLore);
}
itemLore.addAll(loreStart, enchantLore);
itemLore.addAll(0, enchantLore);
if (meta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta metaBook = (EnchantmentStorageMeta) meta;