Fixed KEY_V

This commit is contained in:
Auxilor 2020-10-31 18:35:55 +00:00
parent 1442874493
commit 1572328146
2 changed files with 10 additions and 3 deletions

View File

@ -135,6 +135,10 @@ public final class EnchantDisplay {
}
} catch(NullPointerException ignored) { }
if(meta.getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) {
meta.getPersistentDataContainer().remove(KEY_V);
}
meta.getPersistentDataContainer().remove(KEY);
itemLore.removeIf((s) -> s.startsWith(PREFIX));
@ -163,9 +167,9 @@ public final class EnchantDisplay {
if(item == null || item.getItemMeta() == null || !EnchantmentTarget.ALL.getMaterials().contains(item.getType()))
return item;
if(hideEnchants && item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) {
hideEnchants = false;
item.getItemMeta().getPersistentDataContainer().remove(KEY_V);
if(item.getItemMeta().getPersistentDataContainer().has(KEY_V, PersistentDataType.INTEGER)) {
if(hideEnchants)
hideEnchants = false;
}
item = revertDisplay(item);

View File

@ -5,6 +5,7 @@ import com.comphenix.protocol.events.PacketContainer;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.AbstractPacketAdapter;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
@ -35,6 +36,8 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
fResult.setAccessible(true);
ItemStack result = EnchantDisplay.displayEnchantments(merchantRecipe.getResult());
result = EnchantDisplay.addV(result);
if(!EnchantmentTarget.ALL.getMaterials().contains(result.getType()))
return;
fResult.set(merchantRecipe, result);
// Get NMS MerchantRecipe from CraftMerchantRecipe