mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
add bypass level check permission and update README.md
This commit is contained in:
parent
181dbbb1e4
commit
737d955e9f
5 changed files with 22 additions and 9 deletions
|
|
@ -2,6 +2,7 @@ package io.delilaheve.util
|
|||
|
||||
import io.delilaheve.UnsafeEnchants
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.entity.HumanEntity
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
|
@ -20,7 +21,7 @@ object EnchantmentUtil {
|
|||
* Combine 2 sets of enchantments according to our configuration
|
||||
*/
|
||||
fun Map<Enchantment, Int>.combineWith(
|
||||
other: Map<Enchantment, Int>
|
||||
other: Map<Enchantment, Int>, player: HumanEntity
|
||||
) = mutableMapOf<Enchantment, Int>().apply {
|
||||
putAll(this@combineWith)
|
||||
other.forEach { (enchantment, level) ->
|
||||
|
|
@ -44,7 +45,11 @@ object EnchantmentUtil {
|
|||
else -> {
|
||||
// try to increase the enchantment level by 1
|
||||
var newLevel = this[enchantment]?.plus(1) ?: 0
|
||||
val maxLevel = ConfigOptions.enchantLimit(enchantment)
|
||||
val maxLevel = if(player.hasPermission(UnsafeEnchants.bypassLevelPermission)){
|
||||
255
|
||||
}else{
|
||||
ConfigOptions.enchantLimit(enchantment)
|
||||
}
|
||||
newLevel = min(newLevel, maxLevel)
|
||||
if (newLevel > 0) { this[enchantment] = newLevel }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue