mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
add immutable list
This commit is contained in:
parent
b67d956e39
commit
f4ce267e44
2 changed files with 93 additions and 30 deletions
|
|
@ -2,6 +2,7 @@ package io.delilaheve.util
|
|||
|
||||
import io.delilaheve.CustomAnvil
|
||||
import io.delilaheve.util.EnchantmentUtil.enchantmentName
|
||||
import org.bukkit.NamespacedKey
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType
|
||||
import xyz.alexcrea.cuanvil.config.WorkPenaltyType.WorkPenaltyPart
|
||||
|
|
@ -51,6 +52,8 @@ object ConfigOptions {
|
|||
|
||||
const val DISABLE_MERGE_OVER_ROOT = "disable-merge-over"
|
||||
|
||||
const val IMMUTABLE_ENCHANTMENT_LIST = "immutable_enchantments"
|
||||
|
||||
// Keys for specific enchantment values
|
||||
private const val KEY_BOOK = "book"
|
||||
private const val KEY_ITEM = "item"
|
||||
|
|
@ -478,4 +481,17 @@ object ConfigOptions {
|
|||
.takeIf { it in ENCHANT_LIMIT_RANGE }
|
||||
}
|
||||
|
||||
fun isImmutable(key: NamespacedKey): Boolean {
|
||||
val immutables = ConfigHolder.DEFAULT_CONFIG.config.getStringList(IMMUTABLE_ENCHANTMENT_LIST)
|
||||
|
||||
// We need to ignore case so can't just check "contain"
|
||||
for (ench in immutables) {
|
||||
if (ench.equals(key.toString(), ignoreCase = true) ||
|
||||
ench.equals(key.key, ignoreCase = true)
|
||||
)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue