Skip to content

Commit

Permalink
1.1.7: added hide flags for webstore items
Browse files Browse the repository at this point in the history
  • Loading branch information
benfiratkaya committed Dec 17, 2024
1 parent c0c4b2a commit 1ebb7a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bukkit/src/main/java/net/leaderos/plugin/helpers/ItemUtil.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.leaderos.plugin.helpers;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XItemFlag;
import com.cryptomorin.xseries.XMaterial;
import org.apache.commons.lang3.text.WordUtils;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
Expand Down Expand Up @@ -136,6 +136,7 @@ public static int getDurability(ItemStack item, int maxDurability) {
/**
* Check for material and
* get item with a material and model id.
* for WebStore
* @param material of item
* @param name of item
* @param lore of item
Expand All @@ -148,6 +149,9 @@ public static int getDurability(ItemStack item, int maxDurability) {
ItemMeta meta = result.getItemMeta();
meta.setLore(lore);
meta.setDisplayName(name);
meta.addItemFlags(XItemFlag.HIDE_ENCHANTS.get());
meta.addItemFlags(XItemFlag.HIDE_ATTRIBUTES.get());
meta.addItemFlags(XItemFlag.HIDE_ADDITIONAL_TOOLTIP.get());
if (XMaterial.supports(14) && modelId > 0) {
meta.setCustomModelData(modelId);
}
Expand All @@ -158,6 +162,7 @@ public static int getDurability(ItemStack item, int maxDurability) {
/**
* Check for material and
* get item with a material.
* for Voucher item
* @param material of item
* @param name of item
* @param lore of item
Expand All @@ -168,9 +173,10 @@ public static int getDurability(ItemStack item, int maxDurability) {
ItemStack result = getItem(material, name, lore);
ItemMeta meta = result.getItemMeta();
if (glow) {
assert XEnchantment.UNBREAKING.getEnchant() != null;
meta.addEnchant(XEnchantment.UNBREAKING.getEnchant(), 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
assert XEnchantment.UNBREAKING.get() != null;
assert meta != null;
meta.addEnchant(XEnchantment.UNBREAKING.get(), 1, true);
meta.addItemFlags(XItemFlag.HIDE_ENCHANTS.get());
}
result.setItemMeta(meta);
return result;
Expand Down

0 comments on commit 1ebb7a7

Please sign in to comment.