SPIGOT-6921, #957: Add methods to remove all enchantments on an ItemStack

By: Nothixal <nothixal@gmail.com>
This commit is contained in:
Bukkit/Spigot 2024-01-16 07:38:51 +11:00
parent 2803610916
commit 7b30278054
2 changed files with 16 additions and 0 deletions

View file

@ -449,6 +449,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
return level;
}
/**
* Removes all enchantments on this ItemStack.
*/
public void removeEnchantments() {
if (meta == null) {
return;
}
meta.removeEnchantments();
}
@Override
@NotNull
@Utility

View file

@ -187,6 +187,11 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean removeEnchant(@NotNull Enchantment ench);
/**
* Removes all enchantments from this item meta.
*/
void removeEnchantments();
/**
* Checks if the specified enchantment conflicts with any enchantments in
* this ItemMeta.