Finish global gui for group config.

This commit is contained in:
alexcrea 2024-04-18 16:59:11 +02:00
parent 2c6349735b
commit d5b7e5dbfd
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F
7 changed files with 56 additions and 27 deletions

View file

@ -5,11 +5,7 @@ import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.gui.config.global.BasicConfigGui
import xyz.alexcrea.cuanvil.gui.config.global.EnchantConflictGui
import xyz.alexcrea.cuanvil.gui.config.global.EnchantCostConfigGui
import xyz.alexcrea.cuanvil.gui.config.global.EnchantLimitConfigGui
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui
import xyz.alexcrea.cuanvil.gui.config.global.*
import xyz.alexcrea.cuanvil.util.MetricsUtil
class ReloadExecutor : CommandExecutor {
@ -43,7 +39,9 @@ class ReloadExecutor : CommandExecutor {
BasicConfigGui.INSTANCE.updateGuiValues()
EnchantCostConfigGui.INSTANCE.updateGuiValues()
EnchantLimitConfigGui.INSTANCE.updateGuiValues()
EnchantConflictGui.INSTANCE.reloadValues()
GroupConfigGui.INSTANCE.reloadValues()
UnitRepairConfigGui.INSTANCE.reloadValues()
// & update metric

View file

@ -9,13 +9,13 @@ class ItemGroupManager {
companion object {
// Path for group type
private const val GROUP_TYPE_PATH = "type"
const val GROUP_TYPE_PATH = "type"
// Path for included items list
private const val MATERIAL_LIST_PATH = "items"
const val MATERIAL_LIST_PATH = "items"
// Path for included groups list
private const val GROUP_LIST_PATH = "groups"
const val GROUP_LIST_PATH = "groups"
// Temporary list of elements in default config that are use in future
private val FUTURE_MATERIAL = setOf("PIGLIN_HEAD", "BRUSH")
@ -35,6 +35,15 @@ class ItemGroupManager {
}
}
// Create group with existing groups
fun createGroup(
config: ConfigurationSection,
name: String
): AbstractMaterialGroup{
return createGroup(config, groupMap.keys, name)
}
// Create group by key
private fun createGroup(
config: ConfigurationSection,
@ -46,7 +55,7 @@ class ItemGroupManager {
// Create Material group according to the group type
val group: AbstractMaterialGroup
if (GroupType.EXCLUDE.equal(groupType)) {
if (groupType != null && GroupType.EXCLUDE.equal(groupType)) {
group = ExcludeGroup(key)
} else {
group = IncludeGroup(key)
@ -124,7 +133,7 @@ class ItemGroupManager {
}
enum class GroupType(private val groupID: String) {
enum class GroupType(val groupID: String) {
INCLUDE("include"),
EXCLUDE("exclude")