Fix Custom Recipe not being registered.

Fix conflict from api not working.
Add remove api for custom recipe, material group and conflict.
This commit is contained in:
alexcrea 2024-07-09 20:21:36 +02:00
parent a40d2c6530
commit 6f1e53f68e
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
8 changed files with 93 additions and 10 deletions

View file

@ -5,7 +5,7 @@ import org.bukkit.Material
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
class EnchantConflictGroup(
private val name: String,
val name: String,
private val cantConflict: AbstractMaterialGroup,
var minBeforeBlock: Int
) {

View file

@ -52,12 +52,21 @@ class EnchantConflictManager {
val section = config.getConfigurationSection(key)!!
val conflict = createConflict(section, itemManager, key)
addConflictToEnchantments(conflict)
conflictList.add(conflict)
addConflict(conflict)
}
}
fun addConflict(conflict: EnchantConflictGroup){
addConflictToEnchantments(conflict)
conflictList.add(conflict)
}
fun removeConflict(conflict: EnchantConflictGroup){
removeConflictFromEnchantments(conflict)
conflictList.remove(conflict)
}
// Add the conflict to enchantments
private fun addConflictToEnchantments(conflict: EnchantConflictGroup) {
conflict.getEnchants().forEach { enchant ->
@ -65,6 +74,13 @@ class EnchantConflictManager {
}
}
// Remove the conflict from enchantments
private fun removeConflictFromEnchantments(conflict: EnchantConflictGroup) {
conflict.getEnchants().forEach { enchant ->
enchant.removeConflict(conflict)
}
}
// create and read a conflict from a yaml section
private fun createConflict(
section: ConfigurationSection,

View file

@ -7,7 +7,7 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant
class AnvilCustomRecipe(
private val name: String,
val name: String,
var exactCount: Boolean,
//var exactLeft: Boolean,
//var exactRight: Boolean,