Add permission check for Enchantment² enchantments.

This commit is contained in:
alexcrea 2024-06-18 03:13:40 +02:00
parent b1ca8bd91c
commit 6553122819
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
3 changed files with 28 additions and 3 deletions

View file

@ -30,6 +30,8 @@ object EnchantmentUtil {
) = mutableMapOf<WrappedEnchantment, Int>().apply {
putAll(this@combineWith)
other.forEach { (enchantment, level) ->
if(!enchantment.isAllowed(player)) return@forEach
// Get max level or 255 if player can bypass
val maxLevel = if (player.hasPermission(CustomAnvil.bypassLevelPermission))
{ 255 } else
@ -53,7 +55,7 @@ object EnchantmentUtil {
}
// Enchantment already in result list
else {
val oldLevel = this[enchantment]!! // should be true, see the comment above
val oldLevel = this[enchantment]!! // <- should not be null. see the comment above
// ... and they are conflicting
val conflictType =