mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
progress on using namespaced key instead of material
This commit is contained in:
parent
1a71086327
commit
7612eac765
32 changed files with 297 additions and 124 deletions
|
|
@ -348,7 +348,7 @@ object ConfigOptions {
|
|||
*
|
||||
* @return the current enchantment limit. -1 if none
|
||||
*/
|
||||
fun getEnchantCountLimit(type: Material): Int? {
|
||||
fun getEnchantCountLimit(type: NamespacedKey): Int? {
|
||||
val limit = materialEnchantCountLimit(type)
|
||||
|
||||
if(limit != null) return limit
|
||||
|
|
@ -362,8 +362,8 @@ object ConfigOptions {
|
|||
*
|
||||
* @return The current enchantment limit. -1 if none
|
||||
*/
|
||||
private fun materialEnchantCountLimit(type: Material): Int? {
|
||||
val path = "$ENCHANT_COUNT_LIMIT_ITEMS.${type.key.key.lowercase()}"
|
||||
private fun materialEnchantCountLimit(type: NamespacedKey): Int? {
|
||||
val path = "$ENCHANT_COUNT_LIMIT_ITEMS.${type.key.lowercase()}"
|
||||
if(!ConfigHolder.DEFAULT_CONFIG.config.isInt(path))
|
||||
return null
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemStack
|
|||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.group.ConflictType
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ object EnchantmentUtil {
|
|||
val bypassFuse = player.hasPermission(CustomAnvil.bypassFusePermission)
|
||||
val bypassLevel = player.hasPermission(CustomAnvil.bypassLevelPermission)
|
||||
|
||||
var maxEnchantCount = ConfigOptions.getEnchantCountLimit(item.type)
|
||||
var maxEnchantCount = ConfigOptions.getEnchantCountLimit(item.customType)
|
||||
if(maxEnchantCount == null || maxEnchantCount < 0) maxEnchantCount = Int.MAX_VALUE
|
||||
|
||||
val allowed = other.filter { (enchantment, _) -> enchantment.isAllowed(player) }
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.bukkit.Material.ENCHANTED_BOOK
|
|||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.meta.Damageable
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
|
@ -90,5 +91,5 @@ object ItemUtil {
|
|||
*/
|
||||
fun ItemStack.canMergeWith(
|
||||
other: ItemStack?
|
||||
) = (other != null) && (type == other.type || (other.isEnchantedBook()))
|
||||
) = (other != null) && (customType == other.customType || (other.isEnchantedBook()))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue