mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
check section exist for group & conflict
This commit is contained in:
parent
1a71086327
commit
daa1c6171f
2 changed files with 18 additions and 4 deletions
|
|
@ -48,6 +48,11 @@ class EnchantConflictManager {
|
|||
|
||||
lateinit var conflictList: ArrayList<EnchantConflictGroup>
|
||||
|
||||
|
||||
private fun warnBadKey(key: String) {
|
||||
CustomAnvil.instance.logger.warning("Invalid key $key for conflict: is not a conflict")
|
||||
}
|
||||
|
||||
// Read and prepare all conflict
|
||||
fun prepareConflicts(config: ConfigurationSection, itemManager: ItemGroupManager) {
|
||||
conflictList = ArrayList()
|
||||
|
|
@ -59,7 +64,11 @@ class EnchantConflictManager {
|
|||
|
||||
val keys = config.getKeys(false)
|
||||
for (key in keys) {
|
||||
val section = config.getConfigurationSection(key)!!
|
||||
val section = config.getConfigurationSection(key)
|
||||
if(section == null) {
|
||||
warnBadKey(key)
|
||||
continue
|
||||
}
|
||||
val conflict = createConflict(section, itemManager, key)
|
||||
|
||||
addConflict(conflict)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class ItemGroupManager {
|
|||
for (key in keys) {
|
||||
if (groupMap.containsKey(key))
|
||||
continue
|
||||
if (!config.isConfigurationSection(key))
|
||||
continue
|
||||
createGroup(config, keys, key)
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +53,7 @@ class ItemGroupManager {
|
|||
key: String
|
||||
): AbstractMaterialGroup {
|
||||
val groupSection = config.getConfigurationSection(key)!!
|
||||
|
||||
val groupType = groupSection.getString(GROUP_TYPE_PATH, null)
|
||||
|
||||
// Create Material group according to the group type
|
||||
|
|
@ -105,11 +108,13 @@ class ItemGroupManager {
|
|||
continue
|
||||
}
|
||||
// Get other group or create it if not yet created
|
||||
val otherGroup = if (!groupMap.containsKey(groupName)) {
|
||||
val otherGroup =
|
||||
if (!groupMap.containsKey(groupName)) {
|
||||
if(!config.isConfigurationSection(groupName)) continue
|
||||
createGroup(config, keys, groupName)
|
||||
} else {
|
||||
groupMap[groupName]!!
|
||||
}
|
||||
else groupMap[groupName]!!
|
||||
|
||||
// Avoid self reference or it will create an infinite loop
|
||||
if (otherGroup.isReferencing(group)) {
|
||||
CustomAnvil.instance.logger.warning(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue