Skip to content

Commit 9ccd77d

Browse files
committed
Improved enchantments
1 parent 40f6807 commit 9ccd77d

File tree

1 file changed

+9
-2
lines changed
  • core/common/src/main/kotlin/com/willfp/libreforge

1 file changed

+9
-2
lines changed

core/common/src/main/kotlin/com/willfp/libreforge/Utils.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.willfp.libreforge
22

33
import com.willfp.eco.core.items.Items
4+
import com.willfp.eco.util.namespacedKeyOf
45
import com.willfp.libreforge.proxy.Proxy
56
import com.willfp.libreforge.proxy.loadProxy
67
import org.bukkit.Bukkit
@@ -93,8 +94,14 @@ fun ItemStack.applyDamage(damage: Int, player: Player?): Boolean {
9394
}
9495

9596
// 1.21 compat
96-
fun getEnchantment(id: String): Enchantment? =
97-
Enchantment.getByKey(NamespacedKey.minecraft(id))
97+
fun getEnchantment(id: String): Enchantment? {
98+
if (id.contains(':')) {
99+
val key = namespacedKeyOf(id)
100+
return Enchantment.getByKey(key)
101+
} else {
102+
return Enchantment.getByKey(NamespacedKey.minecraft(id))
103+
}
104+
}
98105

99106
@Proxy("OpenInventoryAccessorImpl")
100107
interface OpenInventoryAccessor {

0 commit comments

Comments
 (0)