mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +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>
|
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
|
// Read and prepare all conflict
|
||||||
fun prepareConflicts(config: ConfigurationSection, itemManager: ItemGroupManager) {
|
fun prepareConflicts(config: ConfigurationSection, itemManager: ItemGroupManager) {
|
||||||
conflictList = ArrayList()
|
conflictList = ArrayList()
|
||||||
|
|
@ -59,7 +64,11 @@ class EnchantConflictManager {
|
||||||
|
|
||||||
val keys = config.getKeys(false)
|
val keys = config.getKeys(false)
|
||||||
for (key in keys) {
|
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)
|
val conflict = createConflict(section, itemManager, key)
|
||||||
|
|
||||||
addConflict(conflict)
|
addConflict(conflict)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ class ItemGroupManager {
|
||||||
for (key in keys) {
|
for (key in keys) {
|
||||||
if (groupMap.containsKey(key))
|
if (groupMap.containsKey(key))
|
||||||
continue
|
continue
|
||||||
|
if (!config.isConfigurationSection(key))
|
||||||
|
continue
|
||||||
createGroup(config, keys, key)
|
createGroup(config, keys, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,6 +53,7 @@ class ItemGroupManager {
|
||||||
key: String
|
key: String
|
||||||
): AbstractMaterialGroup {
|
): AbstractMaterialGroup {
|
||||||
val groupSection = config.getConfigurationSection(key)!!
|
val groupSection = config.getConfigurationSection(key)!!
|
||||||
|
|
||||||
val groupType = groupSection.getString(GROUP_TYPE_PATH, null)
|
val groupType = groupSection.getString(GROUP_TYPE_PATH, null)
|
||||||
|
|
||||||
// Create Material group according to the group type
|
// Create Material group according to the group type
|
||||||
|
|
@ -105,11 +108,13 @@ class ItemGroupManager {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Get other group or create it if not yet created
|
// 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)
|
createGroup(config, keys, groupName)
|
||||||
} else {
|
|
||||||
groupMap[groupName]!!
|
|
||||||
}
|
}
|
||||||
|
else groupMap[groupName]!!
|
||||||
|
|
||||||
// Avoid self reference or it will create an infinite loop
|
// Avoid self reference or it will create an infinite loop
|
||||||
if (otherGroup.isReferencing(group)) {
|
if (otherGroup.isReferencing(group)) {
|
||||||
CustomAnvil.instance.logger.warning(
|
CustomAnvil.instance.logger.warning(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue