[SPIGOT-6921] ItemStack removeAllEnchantments Created: 05/Feb/22  Updated: 15/Jan/24  Resolved: 15/Jan/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Photon Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Version: This server is running CraftBukkit version 3423-Spigot-7fbc6a1-8f361ec (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

If you want to remove all enchantments from an ItemStack, right now the only way to do so is looping over getEnchantments().keySet() and remove every single enchantment individually.

Not only is that unnecessarily verbose code, but a removeAllEnchantments() method could internally use the clear() method of maps to remove values more efficiently, depending on the implementation.

 

Use cases are: Setting the enchantments of an ItemStack, overwriting previous ones, any "unenchant" functionality, etc.



 Comments   
Comment by RyanTheLeach [ 06/Feb/22 ]

The only real use I see for this convenience method is to emulate vanilla grindstone behavior of removing all non-curse enchants.

Otherwise just loop.

Generated at Sat Dec 13 13:43:23 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.