warn and cancel on datapack setEnchantAsAll enchantment not found

This commit is contained in:
alexcrea 2026-08-12 06:52:41 +02:00
parent b2567f9176
commit f4202e2521
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C

View file

@ -223,7 +223,11 @@ object DataPackDependency {
private fun setEnchantAsAll(ench: String) {
// We assume current is not null and of type CABukkitEnchantment
val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as CABukkitEnchantment
val current = EnchantmentApi.getByKey(NamespacedKey.fromString(ench)!!) as? CABukkitEnchantment
if(current == null) {
CustomAnvil.instance.logger.warning("Could not find enchant $ench")
return
}
// We need to replace current wrapped enchantment with the all conflict wrapper
EnchantmentApi.unregisterEnchantment(current)