diff --git a/bukkit/loader/src/main/resources/translations/en.yml b/bukkit/loader/src/main/resources/translations/en.yml index a0a4f2de1..84171e524 100644 --- a/bukkit/loader/src/main/resources/translations/en.yml +++ b/bukkit/loader/src/main/resources/translations/en.yml @@ -71,7 +71,7 @@ warning.config.type.double: "Issue found in file - Failed to loa warning.config.type.quaternionf: "Issue found in file - Failed to load '': Cannot cast '' to Quaternionf type for option ''." warning.config.type.vector3f: "Issue found in file - Failed to load '': Cannot cast '' to Vector3f type for option ''." warning.config.structure.not_section: "Issue found in file - The config '' is expected to be a config section while it's actually a(n) ''." -warning.config.image.duplicate: "Issue found in file - Duplicated image ''." +warning.config.image.duplicate: "Issue found in file - Duplicated image ''. Please check if there is the same configuration in other files." warning.config.image.missing_height: "Issue found in file - The image '' is missing the required 'height' argument." warning.config.image.height_ascent_conflict: "Issue found in file - The image '' violates the bitmap image rule: 'height' argument '' should be no lower than 'ascent' argument ''." warning.config.image.missing_file: "Issue found in file - The image '' is missing the required 'file' argument." @@ -82,15 +82,15 @@ warning.config.image.codepoint_conflict: "Issue found in file - warning.config.image.invalid_codepoint_grid: "Issue found in file - Image '' has an invalid 'chars' codepoint grid." warning.config.image.file_not_found: "Issue found in file - PNG file '' not found for image ''." warning.config.image.invalid_hex_value: "Issue found in file - The image '' is using a unicode character '' that is not a valid hexadecimal (radix 16) value." -warning.config.recipe.duplicate: "Issue found in file - Duplicated recipe ''." +warning.config.recipe.duplicate: "Issue found in file - Duplicated recipe ''. Please check if there is the same configuration in other files." warning.config.recipe.missing_type: "Issue found in file - The recipe '' is missing the required 'type' argument." warning.config.recipe.invalid_type: "Issue found in file - The recipe '' is using an invalid recipe type ''." warning.config.recipe.invalid_item: "Issue found in file - The recipe '' is using an invalid item ''." warning.config.recipe.missing_ingredient: "Issue found in file - The cooking recipe '' is missing the required 'ingredient' argument." warning.config.recipe.missing_result: "Issue found in file - The recipe '' is missing the required 'result' argument." warning.config.recipe.result.missing_id: "Issue found in file - The recipe '' is missing the required argument 'id' for recipe result." -warning.config.recipe.crafting.invalid_category: "Issue found in file - The crafting recipe '' is using an invalid category ''. Allowed categories: [BUILDING, REDSTONE, EQUIPMENT, MISC]." -warning.config.recipe.cooking.invalid_category: "Issue found in file - The cooking recipe '' is using an invalid category ''. Allowed categories: [FOOD, BLOCKS, MISC]." +warning.config.recipe.crafting.invalid_category: "Issue found in file - The crafting recipe '' is using an invalid category ''. Allowed categories: []." +warning.config.recipe.cooking.invalid_category: "Issue found in file - The cooking recipe '' is using an invalid category ''. Allowed categories: []." warning.config.recipe.shaped.missing_pattern: "Issue found in file - The shaped recipe '' is missing the required argument 'pattern'." warning.config.recipe.shaped.invalid_pattern: "Issue found in file - The shaped recipe '' is using an invalid pattern ''." warning.config.recipe.shaped.invalid_symbol: "Issue found in file - The shaped recipe '' is using an invalid symbol '' in pattern." @@ -99,23 +99,24 @@ warning.config.recipe.smithing_transform.post_processor.invalid_type: "I warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components: "Issue found in file - The smithing transform recipe '' is missing the required argument 'components' for post-processors 'keep_components'." warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags: "Issue found in file - The smithing transform recipe '' is missing the required argument 'tags' for post-processors 'keep_tags'." warning.config.i18n.unknown_locale: "Issue found in file - Unknown locale ''." -warning.config.template.duplicate: "Issue found in file - Duplicated template ''." +warning.config.template.duplicate: "Issue found in file - Duplicated template ''. Please check if there is the same configuration in other files." warning.config.template.argument.self_increase_int.invalid_range: "Issue found in file - The template '' is using a 'from' '' larger than 'to' '' in 'self_increase_int' argument." warning.config.template.argument.list.invalid_type: "Issue found in file - The template '' is using a 'list' argument which expects a 'List' as argument while the input argument is a(n) ''." -warning.config.vanilla_loot.missing_type: "Issue found in file - 'type' not set for vanilla loot ''." +warning.config.vanilla_loot.missing_type: "Issue found in file - The vanilla loot '' is missing the required 'type' argument." +warning.config.vanilla_loot.invalid_type: "Issue found in file - The vanilla loot '' is using an invalid type ''. Allowed types: []." warning.config.vanilla_loot.block.invalid_target: "Issue found in file - Invalid block target '' in vanilla loot ''." -warning.config.sound.duplicate: "Issue found in file - Duplicated sound ''." +warning.config.sound.duplicate: "Issue found in file - Duplicated sound ''. Please check if there is the same configuration in other files." warning.config.sound.missing_sounds: "Issue found in file - The sound '' is missing the required 'sounds' argument." warning.config.sound.missing_name: "Issue found in file - The sound '' is missing the required 'name' argument." -warning.config.jukebox_song.duplicate: "Issue found in file - Duplicated jukebox song ''." +warning.config.jukebox_song.duplicate: "Issue found in file - Duplicated jukebox song ''. Please check if there is the same configuration in other files." warning.config.jukebox_song.missing_sound: "Issue found in file - The jukebox song '' is missing the required 'sound' argument." -warning.config.furniture.duplicate: "Issue found in file - Duplicated furniture ''." +warning.config.furniture.duplicate: "Issue found in file - Duplicated furniture ''. Please check if there is the same configuration in other files." warning.config.furniture.missing_placement: "Issue found in file - The furniture '' is missing the required 'placement' argument." warning.config.furniture.element.missing_item: "Issue found in file - The furniture '' is missing the required 'item' argument for one of its elements." warning.config.furniture.settings.unknown: "Issue found in file - The furniture '' is using an unknown setting type ''." warning.config.furniture.hitbox.invalid_type: "Issue found in file - The furniture '' is using an invalid hitbox type ''." warning.config.furniture.hitbox.custom.invalid_entity: "Issue found in file - The furniture '' is using a custom hitbox with invalid entity type ''." -warning.config.item.duplicate: "Issue found in file - Duplicated item ''." +warning.config.item.duplicate: "Issue found in file - Duplicated item ''. Please check if there is the same configuration in other files." warning.config.item.settings.unknown: "Issue found in file - The item '' is using an unknown setting type ''." warning.config.item.missing_material: "Issue found in file - The item '' is missing the required 'material' argument." warning.config.item.invalid_material: "Issue found in file - The item '' is using an invalid material type ''." @@ -167,7 +168,7 @@ warning.config.item.model.special.shulker_box.missing_texture: "Issue fo warning.config.item.model.special.shulker_box.invalid_openness: "Issue found in file - The item '' is using an invalid 'openness' value '' for special model 'minecraft:shulker_box'. Valid range '0~1.'" warning.config.item.model.special.head.missing_kind: "Issue found in file - The item '' is missing the required 'kind' argument for special model 'minecraft:head'." warning.config.item.model.special.head.missing_texture: "Issue found in file - The item '' is missing the required 'texture' argument for special model 'minecraft:head'." -warning.config.block.duplicate: "Issue found in file - Duplicated block ''." +warning.config.block.duplicate: "Issue found in file - Duplicated block ''. Please check if there is the same configuration in other files." warning.config.block.missing_state: "Issue found in file - The block '' is missing the required 'state' argument." warning.config.block.state.property.missing_type: "Issue found in file - The block '' is missing the required 'type' argument for property ''." warning.config.block.state.property.invalid_type: "Issue found in file - The block '' is using the invalid type argument '' for property ''." @@ -180,7 +181,7 @@ warning.config.block.state.missing_variants: "Issue found in file Issue found in file - The block '' is missing the required 'appearance' argument for variant ''." warning.config.block.state.variant.invalid_appearance: "Issue found in file - The block '' has an error that the variant '' is using a non-existing appearance ''." warning.config.block.state.invalid_vanilla: "Issue found in file - The block '' is using an invalid vanilla block state ''." -warning.config.block.state.unavailable_vanilla: "Issue found in file - The block '' is using an unavailable vanilla block state ''." +warning.config.block.state.unavailable_vanilla: "Issue found in file - The block '' is using an unavailable vanilla block state ''. Please free that state in mappings.yml." warning.config.block.state.invalid_vanilla_id: "Issue found in file - The block '' is using a vanilla block state '' that exceeds the available slot range '0~'." warning.config.block.state.conflict: "Issue found in file - The block '' is using a vanilla block state '' that has been occupied by ''." warning.config.block.state.bind_failed: "Issue found in file - The block '' failed to bind real block state for '' as the state has been occupied by ''." @@ -204,9 +205,9 @@ warning.config.model.generation.conflict: "Issue found in file - warning.config.model.generation.texture.invalid: "Issue found in file - The config '' has a texture '' with path '' that contains illegal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters." warning.config.model.generation.parent.invalid: "Issue found in file - The config '' has a parent argument '' that contains illegal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters." warning.config.emoji.missing_keywords: "Issue found in file - The emoji '' is missing the required 'keywords' argument." -warning.config.emoji.duplicate: "Issue found in file - Duplicated emoji ''." +warning.config.emoji.duplicate: "Issue found in file - Duplicated emoji ''. Please check if there is the same configuration in other files." warning.config.emoji.invalid_image: "Issue found in file - The emoji '' has an invalid 'image' argument ''." -warning.config.advancement.duplicate: "Issue found in file - Duplicated advancement ''." +warning.config.advancement.duplicate: "Issue found in file - Duplicated advancement ''. Please check if there is the same configuration in other files." warning.config.loot_table.missing_pools: "Issue found in file - '' has a misconfigured loot table which is missing the required 'pools' argument." warning.config.loot_table.invalid_pools_type: "Issue found in file - '' has a misconfigured loot table, 'pools' should be a string/map list, current type: ''." warning.config.loot_table.invalid_conditions_type: "Issue found in file - '' has a misconfigured loot table, 'conditions' should be a map list, current type: ''." diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/loot/BukkitVanillaLootManager.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/loot/BukkitVanillaLootManager.java index 0c22aa56c..ab266b204 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/loot/BukkitVanillaLootManager.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/loot/BukkitVanillaLootManager.java @@ -16,6 +16,7 @@ import net.momirealms.craftengine.core.pack.LoadingSequence; import net.momirealms.craftengine.core.pack.Pack; import net.momirealms.craftengine.core.plugin.config.ConfigSectionParser; import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException; +import net.momirealms.craftengine.core.util.EnumUtils; import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.MiscUtils; import net.momirealms.craftengine.core.util.VersionHelper; @@ -110,9 +111,14 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme public void parseSection(Pack pack, Path path, Key id, Map section) { String type = (String) section.get("type"); if (type == null) { - throw new LocalizedResourceConfigException("warning.config.vanilla_loot.missing_type", path, id); + throw new LocalizedResourceConfigException("warning.config.vanilla_loot.missing_type"); + } + VanillaLoot.Type typeEnum; + try { + typeEnum = VanillaLoot.Type.valueOf(type.toUpperCase(Locale.ENGLISH)); + } catch (IllegalArgumentException e) { + throw new LocalizedResourceConfigException("warning.config.vanilla_loot.invalid_type", type, EnumUtils.toString(VanillaLoot.Type.values())); } - VanillaLoot.Type typeEnum = VanillaLoot.Type.valueOf(type.toUpperCase(Locale.ENGLISH)); boolean override = (boolean) section.getOrDefault("override", false); List targets = MiscUtils.getAsStringList(section.getOrDefault("target", List.of())); LootTable lootTable = LootTable.fromMap(MiscUtils.castToMap(section.get("loot"), false)); @@ -122,14 +128,14 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme if (target.endsWith("]") && target.contains("[")) { java.lang.Object blockState = BlockStateUtils.blockDataToBlockState(Bukkit.createBlockData(target)); if (blockState == Reflections.instance$Blocks$AIR$defaultState) { - throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", path, id, target); + throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", target); } VanillaLoot vanillaLoot = blockLoots.computeIfAbsent(BlockStateUtils.blockStateToId(blockState), k -> new VanillaLoot(VanillaLoot.Type.BLOCK)); vanillaLoot.addLootTable(lootTable); } else { for (Object blockState : BlockStateUtils.getAllVanillaBlockStates(Key.of(target))) { if (blockState == Reflections.instance$Blocks$AIR$defaultState) { - throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", path, id, target); + throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", target); } VanillaLoot vanillaLoot = blockLoots.computeIfAbsent(BlockStateUtils.blockStateToId(blockState), k -> new VanillaLoot(VanillaLoot.Type.BLOCK)); if (override) vanillaLoot.override(true); diff --git a/core/src/main/java/net/momirealms/craftengine/core/item/recipe/AbstractRecipeFactory.java b/core/src/main/java/net/momirealms/craftengine/core/item/recipe/AbstractRecipeFactory.java index 6b1d5f017..e8ed1c12f 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/item/recipe/AbstractRecipeFactory.java +++ b/core/src/main/java/net/momirealms/craftengine/core/item/recipe/AbstractRecipeFactory.java @@ -4,6 +4,7 @@ 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.EnumUtils; import net.momirealms.craftengine.core.util.Key; import net.momirealms.craftengine.core.util.MiscUtils; @@ -48,7 +49,7 @@ public abstract class AbstractRecipeFactory implements RecipeFactory { try { recipeCategory = arguments.containsKey("category") ? CookingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null; } catch (IllegalArgumentException e) { - throw new LocalizedResourceConfigException("warning.config.recipe.cooking.invalid_category", e, arguments.get("category").toString()); + throw new LocalizedResourceConfigException("warning.config.recipe.cooking.invalid_category", e, arguments.get("category").toString(), EnumUtils.toString(CookingRecipeCategory.values())); } return recipeCategory; } @@ -58,7 +59,7 @@ public abstract class AbstractRecipeFactory implements RecipeFactory { try { recipeCategory = arguments.containsKey("category") ? CraftingRecipeCategory.valueOf(arguments.get("category").toString().toUpperCase(Locale.ENGLISH)) : null; } catch (IllegalArgumentException e) { - throw new LocalizedResourceConfigException("warning.config.recipe.crafting.invalid_category", e, arguments.get("category").toString()); + throw new LocalizedResourceConfigException("warning.config.recipe.crafting.invalid_category", e, arguments.get("category").toString(), EnumUtils.toString(CraftingRecipeCategory.values())); } return recipeCategory; } diff --git a/core/src/main/java/net/momirealms/craftengine/core/util/EnumUtils.java b/core/src/main/java/net/momirealms/craftengine/core/util/EnumUtils.java new file mode 100644 index 000000000..982542b51 --- /dev/null +++ b/core/src/main/java/net/momirealms/craftengine/core/util/EnumUtils.java @@ -0,0 +1,16 @@ +package net.momirealms.craftengine.core.util; + +import java.util.StringJoiner; + +public final class EnumUtils { + + private EnumUtils() {} + + public static String toString(Enum[] enums) { + StringJoiner joiner = new StringJoiner(", "); + for (Enum e : enums) { + joiner.add(e.name()); + } + return joiner.toString(); + } +}