9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-22 16:39:28 +00:00

更新报错

This commit is contained in:
XiaoMoMi
2025-04-28 05:55:20 +08:00
parent 6e5b923059
commit dd8997d1e3
44 changed files with 341 additions and 229 deletions

View File

@@ -75,11 +75,25 @@ warning.config.image.codepoint_in_use: "<yellow>Issue found in file <arg:0> - Th
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grind.</yellow>" warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grind.</yellow>"
warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file '<arg:2>' not found for image '<arg:1>'.</yellow>" warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file '<arg:2>' not found for image '<arg:1>'.</yellow>"
warning.config.recipe.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>" warning.config.recipe.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>"
warning.config.recipe.lack_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required argument 'type'.</yellow>"
warning.config.recipe.invalid_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid recipe type '<arg:2>'.</yellow>"
warning.config.recipe.invalid_item: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid item '<arg:2>'.</yellow>"
warning.config.recipe.lack_ingredient: "<yellow>Issue found in file <arg:0> - The cooking recipe '<arg:1>' is missing the required 'ingredient' argument.</yellow>"
warning.config.recipe.lack_result: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required argument 'result'.</yellow>"
warning.config.recipe.result.lack_id: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required argument 'id' for recipe result.</yellow>"
warning.config.recipe.shaped.lack_pattern: "<yellow>Issue found in file <arg:0> - The shaped recipe '<arg:1>' is missing the required argument 'pattern'.</yellow>"
warning.config.recipe.shaped.invalid_pattern: "<yellow>Issue found in file <arg:0> - The shaped recipe '<arg:1>' is using an invalid pattern '<arg:2>'.</yellow>"
warning.config.recipe.shaped.invalid_symbol: "<yellow>Issue found in file <arg:0> - The shaped recipe '<arg:1>' is using an invalid symbol '<arg:2>' in pattern.</yellow>"
warning.config.recipe.smithing_transform.post_processor.lack_type: "<yellow>Issue found in file <arg:0> - The smithing transform recipe '<arg:1>' is missing the required argument 'type' for one of the post-processors.</yellow>"
warning.config.recipe.smithing_transform.post_processor.invalid_type: "<yellow>Issue found in file <arg:0> - The smithing transform recipe '<arg:1>' is using an invalid post processor type '<arg:2>'.</yellow>"
warning.config.recipe.smithing_transform.post_processor.keep_component.lack_components: "<yellow>Issue found in file <arg:0> - The smithing transform recipe '<arg:1>' is missing the required argument 'components' for post-processors 'keep_components'</yellow>"
warning.config.recipe.smithing_transform.post_processor.keep_component.lack_tags: "<yellow>Issue found in file <arg:0> - The smithing transform recipe '<arg:1>' is missing the required argument 'tags' for post-processors 'keep_tags'</yellow>"
warning.config.i18n.unknown_locale: "<yellow>Issue found in file <arg:0> - Unknown locale '<arg:1>'.</yellow>" warning.config.i18n.unknown_locale: "<yellow>Issue found in file <arg:0> - Unknown locale '<arg:1>'.</yellow>"
warning.config.template.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated template '<arg:1>'.</yellow>" warning.config.template.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated template '<arg:1>'.</yellow>"
warning.config.vanilla_loot.type_not_exist: "<yellow>Issue found in file <arg:0> - 'type' not set for vanilla loot '<arg:1>'.</yellow>" warning.config.vanilla_loot.type_not_exist: "<yellow>Issue found in file <arg:0> - 'type' not set for vanilla loot '<arg:1>'.</yellow>"
warning.config.vanilla_loot.block.invalid_target: "<yellow>Issue found in file <arg:0> - Invalid block target [<arg:2>] in vanilla loot '<arg:1>'.</yellow>" warning.config.vanilla_loot.block.invalid_target: "<yellow>Issue found in file <arg:0> - Invalid block target [<arg:2>] in vanilla loot '<arg:1>'.</yellow>"
warning.config.sound.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated sound '<arg:1>'.</yellow>" warning.config.sound.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated sound '<arg:1>'.</yellow>"
warning.config.sound.lack_sounds: "<yellow>Issue found in file <arg:0> - The sound '<arg:1>' is missing the required argument 'sounds'.</yellow>"
warning.config.jukebox_song.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated jukebox song '<arg:1>'.</yellow>" warning.config.jukebox_song.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated jukebox song '<arg:1>'.</yellow>"
warning.config.jukebox_song.lack_sound: "<yellow>Issue found in file <arg:0> - The jukebox song '<arg:1>' is missing the required 'sound' argument.</yellow>" warning.config.jukebox_song.lack_sound: "<yellow>Issue found in file <arg:0> - The jukebox song '<arg:1>' is missing the required 'sound' argument.</yellow>"
warning.config.furniture.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated furniture '<arg:1>'.</yellow>" warning.config.furniture.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated furniture '<arg:1>'.</yellow>"
@@ -89,6 +103,7 @@ warning.config.furniture.settings.unknown: "<yellow>Issue found in file <arg:0>
warning.config.furniture.hitbox.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid hitbox type '<arg:2>'.</yellow>" warning.config.furniture.hitbox.invalid_type: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an invalid hitbox type '<arg:2>'.</yellow>"
warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using a custom hitbox with invalid entity type '<arg:2>'.</yellow>" warning.config.furniture.hitbox.custom.invalid_entity: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using a custom hitbox with invalid entity type '<arg:2>'.</yellow>"
warning.config.item.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated item '<arg:1>'.</yellow>" warning.config.item.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated item '<arg:1>'.</yellow>"
warning.config.item.settings.unknown: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an unknown setting type '<arg:2>'.</yellow>"
warning.config.item.lack_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'material' argument.</yellow>" warning.config.item.lack_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'material' argument.</yellow>"
warning.config.item.invalid_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid material type '<arg:2>'.</yellow>" warning.config.item.invalid_material: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid material type '<arg:2>'.</yellow>"
warning.config.item.bad_custom_model_data_value: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data [<arg:2>] that is too large. It's recommended to use a value lower than 16,777,216.</yellow>" warning.config.item.bad_custom_model_data_value: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using a custom model data [<arg:2>] that is too large. It's recommended to use a value lower than 16,777,216.</yellow>"
@@ -100,16 +115,34 @@ warning.config.item.behavior.block.lack_block: "<yellow>Issue found in file <arg
warning.config.item.behavior.furniture.lack_furniture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'furniture' argument for 'furniture_item' behavior.</yellow>" warning.config.item.behavior.furniture.lack_furniture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'furniture' argument for 'furniture_item' behavior.</yellow>"
warning.config.item.behavior.liquid_collision_block.lack_block: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'block' argument for 'liquid_collision_block_item' behavior.</yellow>" warning.config.item.behavior.liquid_collision_block.lack_block: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'block' argument for 'liquid_collision_block_item' behavior.</yellow>"
warning.config.item.model.invalid_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid model type '<arg:2>'.</yellow>" warning.config.item.model.invalid_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid model type '<arg:2>'.</yellow>"
warning.config.item.model.tint.lack_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'type' argument for tint.</yellow>"
warning.config.item.model.tint.invalid_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid tint type '<arg:2>'.</yellow>"
warning.config.item.model.tint.constant.lack_value: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'value' argument for constant tint.</yellow>"
warning.config.item.model.tint.grass.invalid_temperature: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid temperature '<arg:2>' for grass tint, which is expected to be between 0 and 1.</yellow>"
warning.config.item.model.tint.grass.invalid_downfall: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid downfall '<arg:2>' for grass tint, which is expected to be between 0 and 1.</yellow>"
warning.config.item.model.tint.invalid_value: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid tint '<arg:2>'.</yellow>"
warning.config.item.model.base.lack_path: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'path' argument for 'minecraft:model'.</yellow>" warning.config.item.model.base.lack_path: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'path' argument for 'minecraft:model'.</yellow>"
warning.config.item.model.base.invalid_resource_location: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' has an invalid 'path' argument [<arg:2>] for 'minecraft:model' which contains legal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters.</yellow>" warning.config.item.model.base.invalid_resource_location: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' has an invalid 'path' argument [<arg:2>] for 'minecraft:model' which contains legal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters.</yellow>"
warning.config.item.model.condition.lack_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'property' argument for 'minecraft:condition'.</yellow>"
warning.config.item.model.condition.invalid_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid property '<arg:2>' for 'minecraft:condition'.</yellow>"
warning.config.item.model.condition.lack_on_true: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'on-true' argument for 'minecraft:condition'.</yellow>" warning.config.item.model.condition.lack_on_true: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'on-true' argument for 'minecraft:condition'.</yellow>"
warning.config.item.model.condition.lack_on_false: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'on-false' argument for 'minecraft:condition'.</yellow>" warning.config.item.model.condition.lack_on_false: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'on-false' argument for 'minecraft:condition'.</yellow>"
warning.config.item.model.condition.keybind_down.lack_keybind: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'keybind' argument for 'minecraft:keybind_down'.</yellow>"
warning.config.item.model.condition.has_component.lack_component: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'component' argument for 'minecraft:has_component'.</yellow>"
warning.config.item.model.composite.lack_models: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'models' argument for 'minecraft:composite'.</yellow>" warning.config.item.model.composite.lack_models: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'models' argument for 'minecraft:composite'.</yellow>"
warning.config.item.model.range_dispatch.lack_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'property' argument for 'minecraft:range_dispatch'.</yellow>"
warning.config.item.model.range_dispatch.invalid_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid property '<arg:2>' for 'minecraft:range_dispatch'.</yellow>"
warning.config.item.model.range_dispatch.lack_entries: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'entries' argument for 'minecraft:composite'.</yellow>" warning.config.item.model.range_dispatch.lack_entries: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'entries' argument for 'minecraft:composite'.</yellow>"
warning.config.item.model.range_dispatch.entry.lack_model: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'model' argument for one of the entries in 'minecraft:composite'.</yellow>" warning.config.item.model.range_dispatch.entry.lack_model: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'model' argument for one of the entries in 'minecraft:composite'.</yellow>"
warning.config.item.model.range_dispatch.compass.lack_target: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'target' argument for 'minecraft:compass'.</yellow>"
warning.config.item.model.range_dispatch.time.lack_source: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'source' argument for 'minecraft:time'.</yellow>"
warning.config.item.model.select.lack_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'property' argument for 'minecraft:select'.</yellow>"
warning.config.item.model.select.invalid_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid property '<arg:2>' for 'minecraft:select'.</yellow>"
warning.config.item.model.select.lack_cases: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'cases' argument for 'minecraft:select'.</yellow>" warning.config.item.model.select.lack_cases: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'cases' argument for 'minecraft:select'.</yellow>"
warning.config.item.model.select.case.lack_when: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'when' argument for one of the cases in 'minecraft:select'.</yellow>" warning.config.item.model.select.case.lack_when: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'when' argument for one of the cases in 'minecraft:select'.</yellow>"
warning.config.item.model.select.case.lack_model: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'model' argument for one of the cases in 'minecraft:select'.</yellow>" warning.config.item.model.select.case.lack_model: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'model' argument for one of the cases in 'minecraft:select'.</yellow>"
warning.config.item.model.select.block_state.lack_block_state_property: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'block-state-property' argument for 'minecraft:block_state'.</yellow>"
warning.config.item.model.select.local_time.lack_pattern: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'pattern' argument for 'minecraft:local_time'.</yellow>"
warning.config.block.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated block '<arg:1>'.</yellow>" warning.config.block.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated block '<arg:1>'.</yellow>"
warning.config.block.lack_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument.</yellow>" warning.config.block.lack_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument.</yellow>"
warning.config.block.state.lack_real_id: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'id' argument for 'state'.</yellow>" warning.config.block.state.lack_real_id: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'id' argument for 'state'.</yellow>"
@@ -149,6 +182,25 @@ warning.config.emoji.lack_keywords: "<yellow>Issue found in file <arg:0> - The e
warning.config.emoji.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated emoji '<arg:1>'.</yellow>" warning.config.emoji.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated emoji '<arg:1>'.</yellow>"
warning.config.emoji.invalid_image: "<yellow>Issue found in file <arg:0> - The emoji '<arg:1>' has an invalid 'image' argument '<arg:2>'.</yellow>" warning.config.emoji.invalid_image: "<yellow>Issue found in file <arg:0> - The emoji '<arg:1>' has an invalid 'image' argument '<arg:2>'.</yellow>"
warning.config.advancement.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'.</yellow>" warning.config.advancement.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'.</yellow>"
warning.config.loot_table.lack_pools: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table which is missing the required argument 'pools'.</yellow>"
warning.config.loot_table.wrong_pools_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'pools' should be a string/map list, current type: '<arg:2>'.</yellow>"
warning.config.loot_table.wrong_conditions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'conditions' should be a map list, current type: '<arg:2>'.</yellow>"
warning.config.loot_table.wrong_functions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'functions' should be a map list, current type: '<arg:2>'.</yellow>"
warning.config.loot_table.wrong_entries_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'entries' should be a map list, current type: '<arg:2>'.</yellow>"
warning.config.loot_table.function.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is missing the required argument 'type'.</yellow>"
warning.config.loot_table.function.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is using an invalid function type '<arg:2>'.</yellow>"
warning.config.loot_table.function.apply_bonus.lack_enchantment: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'enchantment'.</yellow>"
warning.config.loot_table.function.apply_bonus.lack_formula: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'formula'.</yellow>"
warning.config.loot_table.function.drop_exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'drop_exp' is missing the required argument 'count'.</yellow>"
warning.config.loot_table.function.set_count.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'set_count' is missing the required argument 'count'.</yellow>"
warning.config.loot_table.entry.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is missing the required argument 'type'.</yellow>"
warning.config.loot_table.entry.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is using an invalid entry type '<arg:2>'.</yellow>"
warning.config.loot_table.entry.exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'exp' is missing the required argument 'count'.</yellow>"
warning.config.loot_table.entry.item.lack_item: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'item' is missing the required argument 'item'.</yellow>"
warning.config.loot_table.condition.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is missing the required argument 'type'.</yellow>"
warning.config.loot_table.condition.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is using an invalid condition type '<arg:2>'.</yellow>"
warning.config.loot_table.number.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is missing the required argument 'type'.</yellow>"
warning.config.loot_table.number.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is using an invalid number type '<arg:2>'.</yellow>"
warning.config.host.lack_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'type' for host.</yellow>" warning.config.host.lack_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'type' for host.</yellow>"
warning.config.host.invalid_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Host 'type' [<arg:0>] is invalid. Please read https://mo-mi.gitbook.io/xiaomomi-plugins/craftengine/plugin-wiki/craftengine/resource-pack/host</yellow>" warning.config.host.invalid_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Host 'type' [<arg:0>] is invalid. Please read https://mo-mi.gitbook.io/xiaomomi-plugins/craftengine/plugin-wiki/craftengine/resource-pack/host</yellow>"
warning.config.host.external.lack_url: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'url' for external host.</yellow>" warning.config.host.external.lack_url: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'url' for external host.</yellow>"
@@ -175,22 +227,13 @@ warning.config.host.self.invalid_port: "<yellow>Issue found in config.yml at 're
warning.config.host.gitlab.lack_url: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'gitlab-url' for gitlab host.</yellow>" warning.config.host.gitlab.lack_url: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'gitlab-url' for gitlab host.</yellow>"
warning.config.host.gitlab.lack_access_token: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'access-token' for gitlab host.</yellow>" warning.config.host.gitlab.lack_access_token: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'access-token' for gitlab host.</yellow>"
warning.config.host.gitlab.lack_project_id: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'project-id' for gitlab host.</yellow>" warning.config.host.gitlab.lack_project_id: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing required argument 'project-id' for gitlab host.</yellow>"
warning.config.loot_table.lack_pools: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table which is missing the required argument 'pools'.</yellow>" warning.config.conflict_matcher.lack_type: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'type' for one of the handlers.</yellow>"
warning.config.loot_table.wrong_pools_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'pools' should be a string/map list, current type: '<arg:2>'.</yellow>" warning.config.conflict_matcher.invalid_type: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - One of the terms is using the invalid type '<arg:0>'.</yellow>"
warning.config.loot_table.wrong_conditions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'conditions' should be a map list, current type: '<arg:2>'.</yellow>" warning.config.conflict_matcher.exact.lack_path: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'path' for 'exact' matcher.</yellow>"
warning.config.loot_table.wrong_functions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'functions' should be a map list, current type: '<arg:2>'.</yellow>" warning.config.conflict_matcher.contains.lack_path: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'path' for 'contains' matcher.</yellow>"
warning.config.loot_table.wrong_entries_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'entries' should be a map list, current type: '<arg:2>'.</yellow>" warning.config.conflict_matcher.filename.lack_name: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'path' for 'filename' matcher.</yellow>"
warning.config.loot_table.function.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is missing the required argument 'type'.</yellow>" warning.config.conflict_matcher.pattern.lack_pattern: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'pattern' for 'pattern' matcher.</yellow>"
warning.config.loot_table.function.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is using an invalid function type '<arg:2>'.</yellow>" warning.config.conflict_matcher.parent_path_prefix.lack_prefix: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'prefix' for 'parent_path_prefix' matcher.</yellow>"
warning.config.loot_table.function.apply_bonus.lack_enchantment: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'enchantment'.</yellow>" warning.config.conflict_matcher.parent_path_suffix.lack_suffix: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'suffix' for 'parent_path_suffix' matcher.</yellow>"
warning.config.loot_table.function.apply_bonus.lack_formula: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'formula'.</yellow>" warning.config.conflict_resolution.lack_type: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - Missing required argument 'type' for one of the resolutions.</yellow>"
warning.config.loot_table.function.drop_exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'drop_exp' is missing the required argument 'count'.</yellow>" warning.config.conflict_resolution.invalid_type: "<yellow>Issue found in config.yml at 'resource-pack.duplicated-files-handler' - One of the resolutions is using the invalid type '<arg:0>'.</yellow>"
warning.config.loot_table.function.set_count.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'set_count' is missing the required argument 'count'.</yellow>"
warning.config.loot_table.entry.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is missing the required argument 'type'.</yellow>"
warning.config.loot_table.entry.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is using an invalid entry type '<arg:2>'.</yellow>"
warning.config.loot_table.entry.exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'exp' is missing the required argument 'count'.</yellow>"
warning.config.loot_table.entry.item.lack_item: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'item' is missing the required argument 'item'.</yellow>"
warning.config.loot_table.condition.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is missing the required argument 'type'.</yellow>"
warning.config.loot_table.condition.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is using an invalid condition type '<arg:2>'.</yellow>"
warning.config.loot_table.number.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is missing the required argument 'type'.</yellow>"
warning.config.loot_table.number.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the numbers is using an invalid number type '<arg:2>'.</yellow>"

View File

@@ -340,12 +340,14 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
} }
ItemSettings itemSettings; ItemSettings itemSettings;
if (section.containsKey("settings")) { try {
Map<String, Object> settings = MiscUtils.castToMap(section.get("settings"), false); itemSettings = ItemSettings.fromMap(MiscUtils.castToMap(section.get("settings"), true));
itemSettings = ItemSettings.fromMap(settings); } catch (LocalizedResourceConfigException e) {
} else { e.setPath(path);
itemSettings = ItemSettings.of(); e.setId(id);
throw e;
} }
if (isVanillaItem) { if (isVanillaItem) {
itemSettings.canPlaceRelatedVanillaBlock(true); itemSettings.canPlaceRelatedVanillaBlock(true);
} }
@@ -389,6 +391,15 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
return; return;
} }
ItemModel model;
try {
model = ItemModels.fromMap(modelSection);
} catch (LocalizedResourceConfigException e) {
e.setPath(path);
e.setId(id);
throw e;
}
boolean hasModel = false; boolean hasModel = false;
if (customModelData != 0) { if (customModelData != 0) {
hasModel= true; hasModel= true;
@@ -406,7 +417,6 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
conflict.put(customModelData, id); conflict.put(customModelData, id);
// Parse models // Parse models
ItemModel model = ItemModels.fromMap(modelSection);
for (ModelGeneration generation : model.modelsToGenerate()) { for (ModelGeneration generation : model.modelsToGenerate()) {
prepareModelGeneration(path, id, generation); prepareModelGeneration(path, id, generation);
} }
@@ -425,8 +435,6 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
} }
if (itemModelKey != null) { if (itemModelKey != null) {
hasModel = true; hasModel = true;
// use components
ItemModel model = ItemModels.fromMap(modelSection);
for (ModelGeneration generation : model.modelsToGenerate()) { for (ModelGeneration generation : model.modelsToGenerate()) {
prepareModelGeneration(path, id, generation); prepareModelGeneration(path, id, generation);
} }

View File

@@ -3,6 +3,7 @@ package net.momirealms.craftengine.core.item;
import net.momirealms.craftengine.core.item.modifier.EquippableModifier; import net.momirealms.craftengine.core.item.modifier.EquippableModifier;
import net.momirealms.craftengine.core.item.modifier.ItemDataModifier; import net.momirealms.craftengine.core.item.modifier.ItemDataModifier;
import net.momirealms.craftengine.core.pack.misc.EquipmentGeneration; import net.momirealms.craftengine.core.pack.misc.EquipmentGeneration;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import net.momirealms.craftengine.core.util.VersionHelper; import net.momirealms.craftengine.core.util.VersionHelper;
@@ -35,6 +36,7 @@ public class ItemSettings {
} }
public static ItemSettings fromMap(Map<String, Object> map) { public static ItemSettings fromMap(Map<String, Object> map) {
if (map == null) return ItemSettings.of();
return applyModifiers(ItemSettings.of(), map); return applyModifiers(ItemSettings.of(), map);
} }
@@ -56,7 +58,7 @@ public class ItemSettings {
if (factory != null) { if (factory != null) {
factory.createModifier(entry.getValue()).apply(settings); factory.createModifier(entry.getValue()).apply(settings);
} else { } else {
throw new IllegalArgumentException("Unknown item settings key: " + entry.getKey()); throw new LocalizedResourceConfigException("warning.config.item.settings.unknown", new IllegalArgumentException("Unknown item settings key: " + entry.getKey()), entry.getKey());
} }
} }
return settings; return settings;

View File

@@ -0,0 +1,48 @@
package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public abstract class AbstractRecipeFactory<T> implements RecipeFactory<T> {
protected List<String> ingredients(Map<String, Object> arguments) {
return MiscUtils.getAsStringList(getIngredientOrThrow(arguments));
}
protected Map<String, Object> ingredientMap(Map<String, Object> arguments) {
return MiscUtils.castToMap(getIngredientOrThrow(arguments), true);
}
protected Set<Holder<Key>> ingredientHolders(Map<String, Object> arguments) {
Set<Holder<Key>> holders = new HashSet<>();
for (String item : ingredients(arguments)) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
}
}
return holders;
}
protected Object getIngredientOrThrow(Map<String, Object> arguments) {
Object ingredient = arguments.get("ingredient");
if (ingredient == null) {
ingredient = arguments.get("ingredients");
}
if (ingredient == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.lack_ingredient", new NullPointerException("'ingredient' should not be null"));
}
return ingredient;
}
}

View File

@@ -162,9 +162,10 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
Recipe<T> recipe; Recipe<T> recipe;
try { try {
recipe = RecipeTypes.fromMap(id, section); recipe = RecipeTypes.fromMap(id, section);
} catch (Exception e) { } catch (LocalizedResourceConfigException e) {
CraftEngine.instance().logger().warn(path, "Failed to create recipe: " + id, e); e.setPath(path);
return; e.setId(id);
throw e;
} }
try { try {
markAsCustomRecipe(id); markAsCustomRecipe(id);

View File

@@ -1,13 +1,13 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class CustomBlastingRecipe<T> extends CustomCookingRecipe<T> { public class CustomBlastingRecipe<T> extends CustomCookingRecipe<T> {
public static final Factory<?> FACTORY = new Factory<>(); public static final Factory<?> FACTORY = new Factory<>();
@@ -21,7 +21,7 @@ public class CustomBlastingRecipe<T> extends CustomCookingRecipe<T> {
return RecipeTypes.BLASTING; return RecipeTypes.BLASTING;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
@@ -30,24 +30,8 @@ public class CustomBlastingRecipe<T> extends CustomCookingRecipe<T> {
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80)); int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80));
float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f)); float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f));
List<String> items = MiscUtils.getAsStringList(arguments.get("ingredient")); Set<Holder<Key>> holders = ingredientHolders(arguments);
Set<Holder<Key>> holders = new HashSet<>(); return new CustomBlastingRecipe(id, recipeCategory, group, Ingredient.of(holders), cookingTime, experience, parseResult(arguments));
for (String item : items) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item)));
}
}
return new CustomBlastingRecipe(
id,
recipeCategory,
group,
Ingredient.of(holders),
cookingTime,
experience,
parseResult(arguments)
);
} }
} }
} }

View File

@@ -1,13 +1,13 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class CustomCampfireRecipe<T> extends CustomCookingRecipe<T> { public class CustomCampfireRecipe<T> extends CustomCookingRecipe<T> {
public static final Factory<?> FACTORY = new Factory<>(); public static final Factory<?> FACTORY = new Factory<>();
@@ -21,7 +21,7 @@ public class CustomCampfireRecipe<T> extends CustomCookingRecipe<T> {
return RecipeTypes.CAMPFIRE_COOKING; return RecipeTypes.CAMPFIRE_COOKING;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
@@ -30,24 +30,8 @@ public class CustomCampfireRecipe<T> extends CustomCookingRecipe<T> {
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80)); int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80));
float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f)); float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f));
List<String> items = MiscUtils.getAsStringList(arguments.get("ingredient")); Set<Holder<Key>> holders = ingredientHolders(arguments);
Set<Holder<Key>> holders = new HashSet<>(); return new CustomCampfireRecipe(id, recipeCategory, group, Ingredient.of(holders), cookingTime, experience, parseResult(arguments));
for (String item : items) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item)));
}
}
return new CustomCampfireRecipe(
id,
recipeCategory,
group,
Ingredient.of(holders),
cookingTime,
experience,
parseResult(arguments)
);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.item.recipe.input.CraftingInput; import net.momirealms.craftengine.core.item.recipe.input.CraftingInput;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput; import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
@@ -133,29 +134,26 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
} }
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
public Recipe<A> create(Key id, Map<String, Object> arguments) { public Recipe<A> create(Key id, Map<String, Object> arguments) {
List<String> pattern = MiscUtils.getAsStringList(arguments.get("pattern")); List<String> pattern = MiscUtils.getAsStringList(arguments.get("pattern"));
if (pattern.isEmpty()) { if (pattern.isEmpty()) {
throw new IllegalArgumentException("pattern cannot be empty"); throw new LocalizedResourceConfigException("warning.config.recipe.shaped.lack_pattern", new NullPointerException("'pattern' cannot be empty"));
} }
if (!validatePattern(pattern)) { if (!validatePattern(pattern)) {
throw new IllegalArgumentException("Invalid pattern: " + pattern); throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_pattern", new IllegalArgumentException("Invalid pattern: " + pattern), pattern.toString());
}
Map<String, Object> ingredientMap = MiscUtils.castToMap(arguments.get("ingredients"), true);
if (ingredientMap == null) {
throw new IllegalArgumentException("ingredients cannot be empty");
} }
Object ingredientObj = getIngredientOrThrow(arguments);
CraftingRecipeCategory recipeCategory = arguments.containsKey("category") ? CraftingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null; CraftingRecipeCategory recipeCategory = arguments.containsKey("category") ? CraftingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null;
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
Map<Character, Ingredient<A>> ingredients = new HashMap<>(); Map<Character, Ingredient<A>> ingredients = new HashMap<>();
for (Map.Entry<String, Object> entry : ingredientMap.entrySet()) { for (Map.Entry<String, Object> entry : MiscUtils.castToMap(ingredientObj, false).entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (key.length() != 1) { if (key.length() != 1) {
throw new IllegalArgumentException("Invalid key: " + key); throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_symbol", new IllegalArgumentException("Invalid symbol: " + key), key);
} }
char ch = key.charAt(0); char ch = key.charAt(0);
List<String> items = MiscUtils.getAsStringList(entry.getValue()); List<String> items = MiscUtils.getAsStringList(entry.getValue());
@@ -164,7 +162,8 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
if (item.charAt(0) == '#') { if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1)))); holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else { } else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item))); holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
} }
} }
ingredients.put(ch, Ingredient.of(holders)); ingredients.put(ch, Ingredient.of(holders));

View File

@@ -3,6 +3,7 @@ package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.item.recipe.input.CraftingInput; import net.momirealms.craftengine.core.item.recipe.input.CraftingInput;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput; import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
@@ -52,37 +53,66 @@ public class CustomShapelessRecipe<T> extends CustomCraftingTableRecipe<T> {
return RecipeTypes.SHAPELESS; return RecipeTypes.SHAPELESS;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
public Recipe<A> create(Key id, Map<String, Object> arguments) { public Recipe<A> create(Key id, Map<String, Object> arguments) {
Map<String, Object> ingredientMap = MiscUtils.castToMap(arguments.get("ingredients"), true);
if (ingredientMap == null) {
throw new IllegalArgumentException("ingredients cannot be empty");
}
CraftingRecipeCategory recipeCategory = arguments.containsKey("category") ? CraftingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null; CraftingRecipeCategory recipeCategory = arguments.containsKey("category") ? CraftingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null;
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
List<Ingredient<A>> ingredients = new ArrayList<>(); List<Ingredient<A>> ingredients = new ArrayList<>();
for (Map.Entry<String, Object> entry : ingredientMap.entrySet()) { Object ingredientsObject = getIngredientOrThrow(arguments);
if (ingredientsObject instanceof Map<?,?> map) {
for (Map.Entry<String, Object> entry : (MiscUtils.castToMap(map, false)).entrySet()) {
List<String> items = MiscUtils.getAsStringList(entry.getValue()); List<String> items = MiscUtils.getAsStringList(entry.getValue());
Set<Holder<Key>> holders = new HashSet<>(); Set<Holder<Key>> holders = new HashSet<>();
for (String item : items) { for (String item : items) {
if (item.charAt(0) == '#') { if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1)))); holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else { } else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item))); holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
} }
} }
ingredients.add(Ingredient.of(holders)); ingredients.add(Ingredient.of(holders));
} }
return new CustomShapelessRecipe( } else if (ingredientsObject instanceof List<?> list) {
id, for (Object obj : list) {
recipeCategory, if (obj instanceof List<?> inner) {
group, Set<Holder<Key>> holders = new HashSet<>();
ingredients, for (String item : MiscUtils.getAsStringList(inner)) {
parseResult(arguments) if (item.charAt(0) == '#') {
); holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
}
}
ingredients.add(Ingredient.of(holders));
} else {
String item = obj.toString();
Set<Holder<Key>> holders = new HashSet<>();
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
}
ingredients.add(Ingredient.of(holders));
}
}
} else {
String item = ingredientsObject.toString();
Set<Holder<Key>> holders = new HashSet<>();
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
}
ingredients.add(Ingredient.of(holders));
}
return new CustomShapelessRecipe(id, recipeCategory, group, ingredients, parseResult(arguments));
} }
} }
} }

View File

@@ -1,13 +1,13 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class CustomSmeltingRecipe<T> extends CustomCookingRecipe<T> { public class CustomSmeltingRecipe<T> extends CustomCookingRecipe<T> {
public static final Factory<?> FACTORY = new Factory<>(); public static final Factory<?> FACTORY = new Factory<>();
@@ -21,7 +21,7 @@ public class CustomSmeltingRecipe<T> extends CustomCookingRecipe<T> {
return RecipeTypes.SMELTING; return RecipeTypes.SMELTING;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
@@ -30,24 +30,8 @@ public class CustomSmeltingRecipe<T> extends CustomCookingRecipe<T> {
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80)); int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80));
float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f)); float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f));
List<String> items = MiscUtils.getAsStringList(arguments.get("ingredient")); Set<Holder<Key>> holders = ingredientHolders(arguments);
Set<Holder<Key>> holders = new HashSet<>(); return new CustomSmeltingRecipe(id, recipeCategory, group, Ingredient.of(holders), cookingTime, experience, parseResult(arguments));
for (String item : items) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item)));
}
}
return new CustomSmeltingRecipe(
id,
recipeCategory,
group,
Ingredient.of(holders),
cookingTime,
experience,
parseResult(arguments)
);
} }
} }
} }

View File

@@ -5,6 +5,7 @@ import net.momirealms.craftengine.core.item.ItemBuildContext;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput; import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.item.recipe.input.SmithingInput; import net.momirealms.craftengine.core.item.recipe.input.SmithingInput;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -149,7 +150,8 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
if (item.charAt(0) == '#') { if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1)))); holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else { } else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item))); holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Invalid vanilla/custom item: " + item), item)));
} }
} }
return holders.isEmpty() ? null : Ingredient.of(holders); return holders.isEmpty() ? null : Ingredient.of(holders);
@@ -180,12 +182,12 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
public static ItemDataProcessor fromMap(Map<String, Object> map) { public static ItemDataProcessor fromMap(Map<String, Object> map) {
String type = (String) map.get("type"); String type = (String) map.get("type");
if (type == null) { if (type == null) {
throw new NullPointerException("processor type cannot be null"); throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.lack_type", new NullPointerException("Missing required parameter 'type' for post processor"));
} }
Key key = Key.withDefaultNamespace(type, "craftengine"); Key key = Key.withDefaultNamespace(type, "craftengine");
ItemDataProcessor.Factory factory = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_FACTORY.getValue(key); ItemDataProcessor.Factory factory = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown processor type: " + type); throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.invalid_type", new IllegalArgumentException("Unknown processor type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }
@@ -233,7 +235,11 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
@Override @Override
public ItemDataProcessor create(Map<String, Object> arguments) { public ItemDataProcessor create(Map<String, Object> arguments) {
List<String> components = MiscUtils.getAsStringList(arguments.get("components")); Object componentsObj = arguments.get("components");
if (componentsObj == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.lack_components", new NullPointerException("Missing required parameter 'components' for post processor"));
}
List<String> components = MiscUtils.getAsStringList(componentsObj);
return new KeepComponents(components.stream().map(Key::of).toList()); return new KeepComponents(components.stream().map(Key::of).toList());
} }
} }
@@ -266,7 +272,11 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
@Override @Override
public ItemDataProcessor create(Map<String, Object> arguments) { public ItemDataProcessor create(Map<String, Object> arguments) {
List<String> tags = MiscUtils.getAsStringList(arguments.get("tags")); Object tagsObj = arguments.get("tags");
if (tagsObj == null) {
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.lack_tags", new NullPointerException("Missing required parameter 'tags' for post processor"));
}
List<String> tags = MiscUtils.getAsStringList(tagsObj);
return new KeepTags(tags.stream().map(it -> it.split("\\.")).toList()); return new KeepTags(tags.stream().map(it -> it.split("\\.")).toList());
} }
} }

View File

@@ -1,13 +1,13 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class CustomSmokingRecipe<T> extends CustomCookingRecipe<T> { public class CustomSmokingRecipe<T> extends CustomCookingRecipe<T> {
public static final Factory<?> FACTORY = new Factory<>(); public static final Factory<?> FACTORY = new Factory<>();
@@ -21,7 +21,7 @@ public class CustomSmokingRecipe<T> extends CustomCookingRecipe<T> {
return RecipeTypes.SMOKING; return RecipeTypes.SMOKING;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "rawtypes", "DuplicatedCode"})
@Override @Override
@@ -30,24 +30,8 @@ public class CustomSmokingRecipe<T> extends CustomCookingRecipe<T> {
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80)); int cookingTime = MiscUtils.getAsInt(arguments.getOrDefault("time", 80));
float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f)); float experience = MiscUtils.getAsFloat(arguments.getOrDefault("experience", 0.0f));
List<String> items = MiscUtils.getAsStringList(arguments.get("ingredient")); Set<Holder<Key>> holders = ingredientHolders(arguments);
Set<Holder<Key>> holders = new HashSet<>(); return new CustomSmokingRecipe(id, recipeCategory, group, Ingredient.of(holders), cookingTime, experience, parseResult(arguments));
for (String item : items) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item)));
}
}
return new CustomSmokingRecipe(
id,
recipeCategory,
group,
Ingredient.of(holders),
cookingTime,
experience,
parseResult(arguments)
);
} }
} }
} }

View File

@@ -2,14 +2,10 @@ package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.item.recipe.input.RecipeInput; import net.momirealms.craftengine.core.item.recipe.input.RecipeInput;
import net.momirealms.craftengine.core.item.recipe.input.SingleItemInput; import net.momirealms.craftengine.core.item.recipe.input.SingleItemInput;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -43,27 +39,14 @@ public class CustomStoneCuttingRecipe<T> extends AbstractGroupedRecipe<T> {
return ingredient; return ingredient;
} }
public static class Factory<A> implements RecipeFactory<A> { public static class Factory<A> extends AbstractRecipeFactory<A> {
@SuppressWarnings({"DuplicatedCode"}) @SuppressWarnings({"DuplicatedCode"})
@Override @Override
public Recipe<A> create(Key id, Map<String, Object> arguments) { public Recipe<A> create(Key id, Map<String, Object> arguments) {
String group = arguments.containsKey("group") ? arguments.get("group").toString() : null; String group = arguments.containsKey("group") ? arguments.get("group").toString() : null;
List<String> items = MiscUtils.getAsStringList(arguments.get("ingredient")); Set<Holder<Key>> holders = ingredientHolders(arguments);
Set<Holder<Key>> holders = new HashSet<>(); return new CustomStoneCuttingRecipe<>(id, group, Ingredient.of(holders), parseResult(arguments));
for (String item : items) {
if (item.charAt(0) == '#') {
holders.addAll(CraftEngine.instance().itemManager().tagToItems(Key.of(item.substring(1))));
} else {
holders.add(BuiltInRegistries.OPTIMIZED_ITEM_ID.get(Key.of(item)).orElseThrow(() -> new IllegalArgumentException("Invalid vanilla/custom item: " + item)));
}
}
return new CustomStoneCuttingRecipe<>(
id,
group,
Ingredient.of(holders),
parseResult(arguments)
);
} }
} }
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
@@ -14,15 +15,16 @@ public interface RecipeFactory<T> {
default CustomRecipeResult<T> parseResult(Map<String, Object> arguments) { default CustomRecipeResult<T> parseResult(Map<String, Object> arguments) {
Map<String, Object> resultMap = MiscUtils.castToMap(arguments.get("result"), true); Map<String, Object> resultMap = MiscUtils.castToMap(arguments.get("result"), true);
if (resultMap == null) { if (resultMap == null) {
throw new IllegalArgumentException("result cannot be empty"); throw new LocalizedResourceConfigException("warning.config.recipe.lack_result", new IllegalArgumentException("result cannot be empty for recipe"));
} }
String id = (String) resultMap.get("id"); String id = (String) resultMap.get("id");
if (id == null) { if (id == null) {
throw new IllegalArgumentException("result.id cannot be empty"); throw new LocalizedResourceConfigException("warning.config.recipe.result.lack_id", new IllegalArgumentException("id cannot be empty for result"));
} }
int count = MiscUtils.getAsInt(resultMap.getOrDefault("count", 1)); int count = MiscUtils.getAsInt(resultMap.getOrDefault("count", 1));
return new CustomRecipeResult( return new CustomRecipeResult(
CraftEngine.instance().itemManager().getBuildableItem(Key.of(id)).orElseThrow(() -> new IllegalArgumentException("Unknown recipe result item id: " + id)), CraftEngine.instance().itemManager().getBuildableItem(Key.of(id)).orElseThrow(
() -> new LocalizedResourceConfigException("warning.config.recipe.invalid_item", new IllegalArgumentException("Unknown recipe result item id: " + id), id)),
count count
); );
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.item.recipe; package net.momirealms.craftengine.core.item.recipe;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -41,12 +42,12 @@ public class RecipeTypes {
public static <T> Recipe<T> fromMap(Key id, Map<String, Object> map) { public static <T> Recipe<T> fromMap(Key id, Map<String, Object> map) {
String type = (String) map.get("type"); String type = (String) map.get("type");
if (type == null) { if (type == null) {
throw new NullPointerException("recipe type cannot be null"); throw new LocalizedResourceConfigException("warning.config.recipe.lack_type", new NullPointerException("recipe type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "minecraft"); Key key = Key.withDefaultNamespace(type, "minecraft");
RecipeFactory<T> factory = (RecipeFactory<T>) BuiltInRegistries.RECIPE_FACTORY.getValue(key); RecipeFactory<T> factory = (RecipeFactory<T>) BuiltInRegistries.RECIPE_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown recipe type: " + type); throw new LocalizedResourceConfigException("warning.config.recipe.invalid_type", new IllegalArgumentException("Unknown recipe type: " + type), type);
} }
return factory.create(id, map); return factory.create(id, map);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -30,7 +31,7 @@ public class ExactPathMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String path = (String) arguments.get("path"); String path = (String) arguments.get("path");
if (path == null) { if (path == null) {
throw new IllegalArgumentException("The 'path' argument must not be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.exact.lack_path", new IllegalArgumentException("The 'path' argument must not be null"));
} }
return new ExactPathMatcher(path); return new ExactPathMatcher(path);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -30,7 +31,7 @@ public class FilenameMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String name = (String) arguments.get("name"); String name = (String) arguments.get("name");
if (name == null) { if (name == null) {
throw new IllegalArgumentException("The 'name' argument must not be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.filename.lack_name", new IllegalArgumentException("The 'name' argument must not be null"));
} }
return new FilenameMatcher(name); return new FilenameMatcher(name);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -32,7 +33,7 @@ public class ParentPathPrefixMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String prefix = (String) arguments.get("prefix"); String prefix = (String) arguments.get("prefix");
if (prefix == null) { if (prefix == null) {
throw new IllegalArgumentException("The prefix argument must not be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_path_prefix.lack_prefix", new IllegalArgumentException("The prefix argument must not be null"));
} }
return new ParentPathPrefixMatcher(prefix); return new ParentPathPrefixMatcher(prefix);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -32,7 +33,7 @@ public class ParentPathSuffixMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String suffix = (String) arguments.get("suffix"); String suffix = (String) arguments.get("suffix");
if (suffix == null) { if (suffix == null) {
throw new IllegalArgumentException("The suffix argument must not be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_path_suffix.lack_suffix", new IllegalArgumentException("The suffix argument must not be null"));
} }
return new ParentPathSuffixMatcher(suffix); return new ParentPathSuffixMatcher(suffix);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -29,6 +30,9 @@ public class PathContainsMatcher implements PathMatcher {
@Override @Override
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String path = (String) arguments.get("path"); String path = (String) arguments.get("path");
if (path == null) {
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.contains.lack_path", new NullPointerException("path should not be null"));
}
return new PathContainsMatcher(path); return new PathContainsMatcher(path);
} }
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -50,12 +51,12 @@ public class PathMatchers {
public static PathMatcher fromMap(Map<String, Object> map) { public static PathMatcher fromMap(Map<String, Object> map) {
String type = (String) map.getOrDefault("type", "empty"); String type = (String) map.getOrDefault("type", "empty");
if (type == null) { if (type == null) {
throw new NullPointerException("path matcher type cannot be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.lack_type", new NullPointerException("path matcher type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "craftengine"); Key key = Key.withDefaultNamespace(type, "craftengine");
PathMatcherFactory factory = BuiltInRegistries.PATH_MATCHER_FACTORY.getValue(key); PathMatcherFactory factory = BuiltInRegistries.PATH_MATCHER_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown matcher type: " + type); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.invalid_type", new IllegalArgumentException("Unknown matcher type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.matcher; package net.momirealms.craftengine.core.pack.conflict.matcher;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.nio.file.Path; import java.nio.file.Path;
@@ -30,7 +31,7 @@ public class PathPatternMatcher implements PathMatcher {
public PathMatcher create(Map<String, Object> arguments) { public PathMatcher create(Map<String, Object> arguments) {
String pattern = (String) arguments.get("pattern"); String pattern = (String) arguments.get("pattern");
if (pattern == null) { if (pattern == null) {
throw new IllegalArgumentException("The pattern argument must not be null"); throw new LocalizedResourceConfigException("warning.config.conflict_matcher.pattern.lack_pattern", new IllegalArgumentException("The pattern argument must not be null"));
} }
return new PathPatternMatcher(pattern); return new PathPatternMatcher(pattern);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.conflict.resolution; package net.momirealms.craftengine.core.pack.conflict.resolution;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -32,12 +33,12 @@ public class Resolutions {
public static Resolution fromMap(Map<String, Object> map) { public static Resolution fromMap(Map<String, Object> map) {
String type = (String) map.getOrDefault("type", "empty"); String type = (String) map.getOrDefault("type", "empty");
if (type == null) { if (type == null) {
throw new NullPointerException("path matcher type cannot be null"); throw new LocalizedResourceConfigException("warning.config.conflict_resolution.lack_type", new NullPointerException("path matcher type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "craftengine"); Key key = Key.withDefaultNamespace(type, "craftengine");
ResolutionFactory factory = BuiltInRegistries.RESOLUTION_FACTORY.getValue(key); ResolutionFactory factory = BuiltInRegistries.RESOLUTION_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown matcher type: " + type); throw new LocalizedResourceConfigException("warning.config.conflict_resolution.invalid_type", new IllegalArgumentException("Unknown matcher type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -14,7 +14,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class BaseItemModel implements ItemModel { public class BaseItemModel implements ItemModel {
public static final Factory FACTORY = new Factory(); public static final Factory FACTORY = new Factory();

View File

@@ -3,7 +3,6 @@ package net.momirealms.craftengine.core.pack.model;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration; import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration;
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException; import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;

View File

@@ -11,7 +11,6 @@ import net.momirealms.craftengine.core.util.MiscUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public class ConditionItemModel implements ItemModel { public class ConditionItemModel implements ItemModel {
public static final Factory FACTORY = new Factory(); public static final Factory FACTORY = new Factory();

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.model.condition; package net.momirealms.craftengine.core.pack.model.condition;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -47,12 +48,12 @@ public class ConditionProperties {
public static ConditionProperty fromMap(Map<String, Object> map) { public static ConditionProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property"); String type = (String) map.get("property");
if (type == null) { if (type == null) {
throw new NullPointerException("property type cannot be null"); throw new LocalizedResourceConfigException("warning.config.item.model.condition.lack_property", new NullPointerException("property type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "minecraft"); Key key = Key.withDefaultNamespace(type, "minecraft");
ConditionPropertyFactory factory = BuiltInRegistries.CONDITION_PROPERTY_FACTORY.getValue(key); ConditionPropertyFactory factory = BuiltInRegistries.CONDITION_PROPERTY_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown property type: " + type); throw new LocalizedResourceConfigException("warning.config.item.model.condition.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.condition; package net.momirealms.craftengine.core.pack.model.condition;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.util.Map; import java.util.Map;
@@ -35,7 +36,11 @@ public class HasComponentConditionProperty implements ConditionProperty {
@Override @Override
public ConditionProperty create(Map<String, Object> arguments) { public ConditionProperty create(Map<String, Object> arguments) {
boolean ignoreDefault = (boolean) arguments.getOrDefault("ignore-default", false); boolean ignoreDefault = (boolean) arguments.getOrDefault("ignore-default", false);
String component = Objects.requireNonNull(arguments.get("component"), "component").toString(); Object componentObj = arguments.get("component");
if (componentObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.has_component.lack_component", new NullPointerException("component should not be null"));
}
String component = componentObj.toString();
return new HasComponentConditionProperty(component, ignoreDefault); return new HasComponentConditionProperty(component, ignoreDefault);
} }
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.condition; package net.momirealms.craftengine.core.pack.model.condition;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.util.Map; import java.util.Map;
@@ -29,7 +30,11 @@ public class KeyBindDownConditionProperty implements ConditionProperty {
@Override @Override
public ConditionProperty create(Map<String, Object> arguments) { public ConditionProperty create(Map<String, Object> arguments) {
String keybind = Objects.requireNonNull(arguments.get("keybind"), "keybind").toString(); Object keybindObj = arguments.get("keybind");
if (keybindObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.condition.keybind_down.lack_keybind", new NullPointerException("keybind should not be null"));
}
String keybind = keybindObj.toString();
return new KeyBindDownConditionProperty(keybind); return new KeyBindDownConditionProperty(keybind);
} }
} }

View File

@@ -1,13 +1,9 @@
package net.momirealms.craftengine.core.pack.model.generation; package net.momirealms.craftengine.core.pack.model.generation;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import dev.dejvokep.boostedyaml.block.implementation.Section;
import net.momirealms.craftengine.core.pack.ResourceLocation;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException; import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import software.amazon.awssdk.services.s3.endpoints.internal.Value;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.rangedisptach; package net.momirealms.craftengine.core.pack.model.rangedisptach;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.util.Map; import java.util.Map;
@@ -29,7 +30,11 @@ public class CompassRangeDispatchProperty implements RangeDispatchProperty {
@Override @Override
public RangeDispatchProperty create(Map<String, Object> arguments) { public RangeDispatchProperty create(Map<String, Object> arguments) {
String target = Objects.requireNonNull(arguments.get("target")).toString(); Object targetObj = arguments.get("target");
if (targetObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.compass.lack_target", new NullPointerException("target should not be null"));
}
String target = targetObj.toString();
return new CompassRangeDispatchProperty(target); return new CompassRangeDispatchProperty(target);
} }
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.model.rangedisptach; package net.momirealms.craftengine.core.pack.model.rangedisptach;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -43,12 +44,12 @@ public class RangeDispatchProperties {
public static RangeDispatchProperty fromMap(Map<String, Object> map) { public static RangeDispatchProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property"); String type = (String) map.get("property");
if (type == null) { if (type == null) {
throw new NullPointerException("property type cannot be null"); throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.lack_property", new NullPointerException("property type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "minecraft"); Key key = Key.withDefaultNamespace(type, "minecraft");
RangeDispatchPropertyFactory factory = BuiltInRegistries.RANGE_DISPATCH_PROPERTY_FACTORY.getValue(key); RangeDispatchPropertyFactory factory = BuiltInRegistries.RANGE_DISPATCH_PROPERTY_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown property type: " + type); throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.rangedisptach; package net.momirealms.craftengine.core.pack.model.rangedisptach;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.util.Map; import java.util.Map;
@@ -34,7 +35,11 @@ public class TimeRangeDispatchProperty implements RangeDispatchProperty {
@Override @Override
public RangeDispatchProperty create(Map<String, Object> arguments) { public RangeDispatchProperty create(Map<String, Object> arguments) {
String source = Objects.requireNonNull(arguments.get("source")).toString(); Object sourceObj = arguments.get("source");
if (sourceObj == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.time.lack_source", new NullPointerException("source should not be null"));
}
String source = sourceObj.toString();
boolean wobble = (boolean) arguments.getOrDefault("wobble", true); boolean wobble = (boolean) arguments.getOrDefault("wobble", true);
return new TimeRangeDispatchProperty(source, wobble); return new TimeRangeDispatchProperty(source, wobble);
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.select; package net.momirealms.craftengine.core.pack.model.select;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import java.util.Map; import java.util.Map;
@@ -29,7 +30,11 @@ public class BlockStateSelectProperty implements SelectProperty {
@Override @Override
public SelectProperty create(Map<String, Object> arguments) { public SelectProperty create(Map<String, Object> arguments) {
String blockStateProperty = Objects.requireNonNull(arguments.get("block-state-property")).toString(); Object property = arguments.get("block-state-property");
if (property == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.select.block_state.lack_block_state_property", new NullPointerException("block-state-property should not be null"));
}
String blockStateProperty = property.toString();
return new BlockStateSelectProperty(blockStateProperty); return new BlockStateSelectProperty(blockStateProperty);
} }
} }

View File

@@ -43,7 +43,11 @@ public class LocalTimeSelectProperty implements SelectProperty {
@Override @Override
public SelectProperty create(Map<String, Object> arguments) { public SelectProperty create(Map<String, Object> arguments) {
String pattern = Objects.requireNonNull(arguments.get("pattern")).toString(); Object patternObj = arguments.get("pattern");
if (patternObj == null) {
throw new IllegalArgumentException("warning.config.item.model.select.local_time.lack_pattern", new NullPointerException("pattern should not be null"));
}
String pattern = patternObj.toString();
String locale = (String) arguments.get("locale"); String locale = (String) arguments.get("locale");
String timeZone = (String) arguments.get("time-zone"); String timeZone = (String) arguments.get("time-zone");
return new LocalTimeSelectProperty(pattern, locale, timeZone); return new LocalTimeSelectProperty(pattern, locale, timeZone);

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.model.select; package net.momirealms.craftengine.core.pack.model.select;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -41,12 +42,12 @@ public class SelectProperties {
public static SelectProperty fromMap(Map<String, Object> map) { public static SelectProperty fromMap(Map<String, Object> map) {
String type = (String) map.get("property"); String type = (String) map.get("property");
if (type == null) { if (type == null) {
throw new NullPointerException("property type cannot be null"); throw new LocalizedResourceConfigException("warning.config.item.model.select.lack_property", new NullPointerException("property type cannot be null"));
} }
Key key = Key.withDefaultNamespace(type, "minecraft"); Key key = Key.withDefaultNamespace(type, "minecraft");
SelectPropertyFactory factory = BuiltInRegistries.SELECT_PROPERTY_FACTORY.getValue(key); SelectPropertyFactory factory = BuiltInRegistries.SELECT_PROPERTY_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown property type: " + type); throw new LocalizedResourceConfigException("warning.config.item.model.select.invalid_property", new IllegalArgumentException("Unknown property type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.tint; package net.momirealms.craftengine.core.pack.model.tint;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import org.incendo.cloud.type.Either; import org.incendo.cloud.type.Either;
@@ -33,6 +34,9 @@ public class ConstantTint implements Tint {
@Override @Override
public Tint create(Map<String, Object> arguments) { public Tint create(Map<String, Object> arguments) {
Object value = arguments.get("value"); Object value = arguments.get("value");
if (value == null) {
throw new LocalizedResourceConfigException("warning.config.item.model.tint.constant.lack_value", new NullPointerException("value should not be null"));
}
return new ConstantTint(parseTintValue(value)); return new ConstantTint(parseTintValue(value));
} }
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.tint; package net.momirealms.craftengine.core.pack.model.tint;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
import org.incendo.cloud.type.Either; import org.incendo.cloud.type.Either;
@@ -37,7 +38,7 @@ public class CustomModelDataTint implements Tint {
@Override @Override
public Tint create(Map<String, Object> arguments) { public Tint create(Map<String, Object> arguments) {
Object value = arguments.get("default"); Object value = arguments.getOrDefault("default", 0);
int index = MiscUtils.getAsInt(arguments.getOrDefault("index", 0)); int index = MiscUtils.getAsInt(arguments.getOrDefault("index", 0));
return new CustomModelDataTint(parseTintValue(value), index); return new CustomModelDataTint(parseTintValue(value), index);
} }

View File

@@ -1,6 +1,7 @@
package net.momirealms.craftengine.core.pack.model.tint; package net.momirealms.craftengine.core.pack.model.tint;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.MiscUtils;
@@ -37,10 +38,10 @@ public class GrassTint implements Tint {
float temperature = MiscUtils.getAsFloat(arguments.getOrDefault("temperature", 0)); float temperature = MiscUtils.getAsFloat(arguments.getOrDefault("temperature", 0));
float downfall = MiscUtils.getAsFloat(arguments.getOrDefault("downfall", 0)); float downfall = MiscUtils.getAsFloat(arguments.getOrDefault("downfall", 0));
if (temperature > 1 || temperature < 0) { if (temperature > 1 || temperature < 0) {
throw new IllegalArgumentException("Invalid temperature: " + temperature + ". Valid range 0~1"); throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_temperature", new IllegalArgumentException("Invalid temperature: " + temperature + ". Valid range 0~1"), String.valueOf(temperature));
} }
if (downfall > 1 || downfall < 0) { if (downfall > 1 || downfall < 0) {
throw new IllegalArgumentException("Invalid downfall: " + downfall + ". Valid range 0~1"); throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_downfall", new IllegalArgumentException("Invalid downfall: " + downfall + ". Valid range 0~1"), String.valueOf(downfall));
} }
return new GrassTint(temperature, downfall); return new GrassTint(temperature, downfall);
} }

View File

@@ -34,7 +34,7 @@ public class SimpleDefaultTint implements Tint {
@Override @Override
public Tint create(Map<String, Object> arguments) { public Tint create(Map<String, Object> arguments) {
Object value = arguments.get("default"); Object value = arguments.getOrDefault("default", 0);
Key type = Key.of(arguments.get("type").toString()); Key type = Key.of(arguments.get("type").toString());
return new SimpleDefaultTint(parseTintValue(value), type); return new SimpleDefaultTint(parseTintValue(value), type);
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.model.tint; package net.momirealms.craftengine.core.pack.model.tint;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import org.incendo.cloud.type.Either; import org.incendo.cloud.type.Either;
import java.util.ArrayList; import java.util.ArrayList;
@@ -14,25 +15,23 @@ public interface TintFactory {
if (value instanceof Number i) { if (value instanceof Number i) {
return Either.ofPrimary(i.intValue()); return Either.ofPrimary(i.intValue());
} else if (value instanceof List<?> list) { } else if (value instanceof List<?> list) {
if (list.size() != 3) { if (list.size() == 3) {
throw new IllegalArgumentException("Invalid tint value list size: " + list.size() + " which is expected to be 3");
}
List<Integer> intList = new ArrayList<>(); List<Integer> intList = new ArrayList<>();
for (Object o : list) { for (Object o : list) {
intList.add(Integer.parseInt(o.toString())); intList.add(Integer.parseInt(o.toString()));
} }
return Either.ofFallback(intList); return Either.ofFallback(intList);
}
} else if (value instanceof String s) { } else if (value instanceof String s) {
String[] split = s.split(","); String[] split = s.split(",");
if (split.length != 3) { if (split.length == 3) {
throw new IllegalArgumentException("Invalid tint value list size: " + split.length + " which is expected to be 3");
}
List<Integer> intList = new ArrayList<>(); List<Integer> intList = new ArrayList<>();
for (String string : split) { for (String string : split) {
intList.add(Integer.parseInt(string)); intList.add(Integer.parseInt(string));
} }
return Either.ofFallback(intList); return Either.ofFallback(intList);
} }
throw new IllegalArgumentException("Invalid tint value: " + value); }
throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_value", new IllegalArgumentException("Invalid tint value: " + value), value.toString());
} }
} }

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.core.pack.model.tint; package net.momirealms.craftengine.core.pack.model.tint;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.registry.BuiltInRegistries; import net.momirealms.craftengine.core.registry.BuiltInRegistries;
import net.momirealms.craftengine.core.registry.Holder; import net.momirealms.craftengine.core.registry.Holder;
import net.momirealms.craftengine.core.registry.Registries; import net.momirealms.craftengine.core.registry.Registries;
@@ -39,12 +40,12 @@ public class Tints {
public static Tint fromMap(Map<String, Object> map) { public static Tint fromMap(Map<String, Object> map) {
String type = (String) map.get("type"); String type = (String) map.get("type");
if (type == null) { if (type == null) {
throw new NullPointerException("tint type cannot be null"); throw new LocalizedResourceConfigException("warning.config.item.model.tint.lack_type", new NullPointerException("'type' cannot be null for tint"));
} }
Key key = Key.withDefaultNamespace(type, "minecraft"); Key key = Key.withDefaultNamespace(type, "minecraft");
TintFactory factory = BuiltInRegistries.TINT_FACTORY.getValue(key); TintFactory factory = BuiltInRegistries.TINT_FACTORY.getValue(key);
if (factory == null) { if (factory == null) {
throw new IllegalArgumentException("Unknown tint type: " + type); throw new LocalizedResourceConfigException("warning.config.item.model.tint.invalid_type", new IllegalArgumentException("Unknown tint type: " + type), type);
} }
return factory.create(map); return factory.create(map);
} }

View File

@@ -16,6 +16,7 @@ import net.momirealms.craftengine.core.entity.furniture.ColliderType;
import net.momirealms.craftengine.core.pack.conflict.resolution.ConditionalResolution; import net.momirealms.craftengine.core.pack.conflict.resolution.ConditionalResolution;
import net.momirealms.craftengine.core.plugin.CraftEngine; import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.PluginProperties; import net.momirealms.craftengine.core.plugin.PluginProperties;
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
import net.momirealms.craftengine.core.plugin.locale.TranslationManager; import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
import net.momirealms.craftengine.core.plugin.logger.filter.DisconnectLogFilter; import net.momirealms.craftengine.core.plugin.logger.filter.DisconnectLogFilter;
import net.momirealms.craftengine.core.util.AdventureHelper; import net.momirealms.craftengine.core.util.AdventureHelper;
@@ -245,8 +246,11 @@ public class Config {
Map<String, Object> args = MiscUtils.castToMap(it, false); Map<String, Object> args = MiscUtils.castToMap(it, false);
return ConditionalResolution.FACTORY.create(args); return ConditionalResolution.FACTORY.create(args);
}).toList(); }).toList();
} catch (LocalizedResourceConfigException e) {
TranslationManager.instance().log(e.node(), e.arguments());
resource_pack$duplicated_files_handler = List.of();
} catch (Exception e) { } catch (Exception e) {
this.plugin.logger().warn("Failed to load resource pack duplicated files handler", e); this.plugin.logger().warn("Failed to load resource-pack.duplicated-files-handler", e);
resource_pack$duplicated_files_handler = List.of(); resource_pack$duplicated_files_handler = List.of();
} }

View File

@@ -113,6 +113,9 @@ public abstract class AbstractSoundManager implements SoundManager {
boolean replace = (boolean) section.getOrDefault("replace", false); boolean replace = (boolean) section.getOrDefault("replace", false);
String subtitle = (String) section.get("subtitle"); String subtitle = (String) section.get("subtitle");
List<?> soundList = (List<?>) section.get("sounds"); List<?> soundList = (List<?>) section.get("sounds");
if (soundList == null) {
throw new LocalizedResourceConfigException("warning.config.sound.lack_sounds", path, id);
}
List<Sound> sounds = new ArrayList<>(); List<Sound> sounds = new ArrayList<>();
for (Object sound : soundList) { for (Object sound : soundList) {
if (sound instanceof String soundPath) { if (sound instanceof String soundPath) {