Skip to content

Commit

Permalink
ditem.remove_enchantments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 21, 2017
1 parent c0d1eef commit 1956c49
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@ public String getPropertyId() {
@Override
public void adjust(Mechanism mechanism) {

// <--[mechanism]
// @object dItem
// @name remove_enchantments
// @input None
// @description
// Removes all the item's enchantments.
// @tags
// <i@item.enchantments>
// <i@item.enchantments.levels>
// <i@item.enchantments.with_levels>
// -->
if (mechanism.matches("remove_enchantments")) {
if (item.getItemStack().getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemStack().getItemMeta();
for (Enchantment ench : meta.getStoredEnchants().keySet()) {
meta.removeStoredEnchant(ench);
}
item.getItemStack().setItemMeta(meta);
}
else {
for (Enchantment ench : item.getItemStack().getEnchantments().keySet()) {
item.getItemStack().removeEnchantment(ench);
}
}
}

// <--[mechanism]
// @object dItem
// @name enchantments
Expand Down

0 comments on commit 1956c49

Please sign in to comment.