9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 03:19:14 +00:00

差不多了

This commit is contained in:
XiaoMoMi
2025-04-29 19:37:20 +08:00
parent 1f50f7dcb4
commit 65c5cece93
4 changed files with 44 additions and 20 deletions

View File

@@ -71,7 +71,7 @@ warning.config.type.double: "<yellow>Issue found in file <arg:0> - Failed to loa
warning.config.type.quaternionf: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Quaternionf type for option '<arg:3>'.</yellow>"
warning.config.type.vector3f: "<yellow>Issue found in file <arg:0> - Failed to load '<arg:1>': Cannot cast '<arg:2>' to Vector3f type for option '<arg:3>'.</yellow>"
warning.config.structure.not_section: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is expected to be a config section while it's actually a(n) '<arg:2>'.</yellow>"
warning.config.image.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated image '<arg:1>'.</yellow>"
warning.config.image.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated image '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.image.missing_height: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'height' argument.</yellow>"
warning.config.image.height_ascent_conflict: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' violates the bitmap image rule: 'height' argument '<arg:2>' should be no lower than 'ascent' argument '<arg:3>'.</yellow>"
warning.config.image.missing_file: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'file' argument.</yellow>"
@@ -82,15 +82,15 @@ warning.config.image.codepoint_conflict: "<yellow>Issue found in file <arg:0> -
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grid.</yellow>"
warning.config.image.file_not_found: "<yellow>Issue found in file <arg:0> - PNG file '<arg:2>' not found for image '<arg:1>'.</yellow>"
warning.config.image.invalid_hex_value: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a unicode character '<arg:2>' that is not a valid hexadecimal (radix 16) value.</yellow>"
warning.config.recipe.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>"
warning.config.recipe.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.recipe.missing_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required 'type' argument.</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.missing_ingredient: "<yellow>Issue found in file <arg:0> - The cooking recipe '<arg:1>' is missing the required 'ingredient' argument.</yellow>"
warning.config.recipe.missing_result: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required 'result' argument.</yellow>"
warning.config.recipe.result.missing_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.crafting.invalid_category: "<yellow>Issue found in file <arg:0> - The crafting recipe '<arg:1>' is using an invalid category '<arg:2>'. Allowed categories: [BUILDING, REDSTONE, EQUIPMENT, MISC].</yellow>"
warning.config.recipe.cooking.invalid_category: "<yellow>Issue found in file <arg:0> - The cooking recipe '<arg:1>' is using an invalid category '<arg:2>'. Allowed categories: [FOOD, BLOCKS, MISC].</yellow>"
warning.config.recipe.crafting.invalid_category: "<yellow>Issue found in file <arg:0> - The crafting recipe '<arg:1>' is using an invalid category '<arg:2>'. Allowed categories: [<arg:3>].</yellow>"
warning.config.recipe.cooking.invalid_category: "<yellow>Issue found in file <arg:0> - The cooking recipe '<arg:1>' is using an invalid category '<arg:2>'. Allowed categories: [<arg:3>].</yellow>"
warning.config.recipe.shaped.missing_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>"
@@ -99,23 +99,24 @@ warning.config.recipe.smithing_transform.post_processor.invalid_type: "<yellow>I
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_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.missing_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.template.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated template '<arg:1>'.</yellow>"
warning.config.template.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated template '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>Issue found in file <arg:0> - The template '<arg:1>' is using a 'from' '<arg:2>' larger than 'to' '<arg:3>' in 'self_increase_int' argument.</yellow>"
warning.config.template.argument.list.invalid_type: "<yellow>Issue found in file <arg:0> - The template '<arg:1>' is using a 'list' argument which expects a 'List' as argument while the input argument is a(n) '<arg:2>'.</yellow>"
warning.config.vanilla_loot.missing_type: "<yellow>Issue found in file <arg:0> - 'type' not set for vanilla loot '<arg:1>'.</yellow>"
warning.config.vanilla_loot.missing_type: "<yellow>Issue found in file <arg:0> - The vanilla loot '<arg:1>' is missing the required 'type' argument.</yellow>"
warning.config.vanilla_loot.invalid_type: "<yellow>Issue found in file <arg:0> - The vanilla loot '<arg:1>' is using an invalid type '<arg:2>'. Allowed types: [<arg:3>].</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.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated sound '<arg:1>'.</yellow>"
warning.config.sound.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated sound '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.sound.missing_sounds: "<yellow>Issue found in file <arg:0> - The sound '<arg:1>' is missing the required 'sounds' argument.</yellow>"
warning.config.sound.missing_name: "<yellow>Issue found in file <arg:0> - The sound '<arg:1>' is missing the required 'name' argument.</yellow>"
warning.config.jukebox_song.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated jukebox song '<arg:1>'.</yellow>"
warning.config.jukebox_song.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated jukebox song '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.jukebox_song.missing_sound: "<yellow>Issue found in file <arg:0> - The jukebox song '<arg:1>' is missing the required 'sound' argument.</yellow>"
warning.config.furniture.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated furniture '<arg:1>'.</yellow>"
warning.config.furniture.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated furniture '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.furniture.missing_placement: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'placement' argument.</yellow>"
warning.config.furniture.element.missing_item: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is missing the required 'item' argument for one of its elements.</yellow>"
warning.config.furniture.settings.unknown: "<yellow>Issue found in file <arg:0> - The furniture '<arg:1>' is using an unknown setting 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.item.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated item '<arg:1>'.</yellow>"
warning.config.item.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated item '<arg:1>'. Please check if there is the same configuration in other files.</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.missing_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>"
@@ -167,7 +168,7 @@ warning.config.item.model.special.shulker_box.missing_texture: "<yellow>Issue fo
warning.config.item.model.special.shulker_box.invalid_openness: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid 'openness' value '<arg:2>' for special model 'minecraft:shulker_box'. Valid range '0~1.'</yellow>"
warning.config.item.model.special.head.missing_kind: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'kind' argument for special model 'minecraft:head'.</yellow>"
warning.config.item.model.special.head.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:head'.</yellow>"
warning.config.block.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated block '<arg:1>'.</yellow>"
warning.config.block.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated block '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.block.missing_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument.</yellow>"
warning.config.block.state.property.missing_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'type' argument for property '<arg:2>'.</yellow>"
warning.config.block.state.property.invalid_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using the invalid type argument '<arg:2>' for property '<arg:3>'.</yellow>"
@@ -180,7 +181,7 @@ warning.config.block.state.missing_variants: "<yellow>Issue found in file <arg:0
warning.config.block.state.variant.missing_appearance: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'appearance' argument for variant '<arg:2>'.</yellow>"
warning.config.block.state.variant.invalid_appearance: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' has an error that the variant '<arg:2>' is using a non-existing appearance '<arg:3>'.</yellow>"
warning.config.block.state.invalid_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid vanilla block state '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an unavailable vanilla block state '<arg:2>'.</yellow>"
warning.config.block.state.unavailable_vanilla: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an unavailable vanilla block state '<arg:2>'. Please free that state in mappings.yml.</yellow>"
warning.config.block.state.invalid_vanilla_id: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using a vanilla block state '<arg:2>' that exceeds the available slot range '0~<arg:3>'.</yellow>"
warning.config.block.state.conflict: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using a vanilla block state '<arg:2>' that has been occupied by '<arg:3>'.</yellow>"
warning.config.block.state.bind_failed: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' failed to bind real block state for '<arg:2>' as the state has been occupied by '<arg:3>'.</yellow>"
@@ -204,9 +205,9 @@ warning.config.model.generation.conflict: "<yellow>Issue found in file <arg:0> -
warning.config.model.generation.texture.invalid: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' has a texture '<arg:2>' with path '<arg:3>' that contains illegal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters.</yellow>"
warning.config.model.generation.parent.invalid: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' has a parent argument '<arg:2>' that contains illegal characters. Please read https://minecraft.wiki/w/Resource_location#Legal_characters.</yellow>"
warning.config.emoji.missing_keywords: "<yellow>Issue found in file <arg:0> - The emoji '<arg:1>' is missing the required 'keywords' argument.</yellow>"
warning.config.emoji.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated emoji '<arg:1>'.</yellow>"
warning.config.emoji.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated emoji '<arg:1>'. Please check if there is the same configuration in other files.</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.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'.</yellow>"
warning.config.advancement.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
warning.config.loot_table.missing_pools: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table which is missing the required 'pools' argument.</yellow>"
warning.config.loot_table.invalid_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.invalid_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>"

View File

@@ -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<String, Object> 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<String> 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);

View File

@@ -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<T> implements RecipeFactory<T> {
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<T> implements RecipeFactory<T> {
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;
}

View File

@@ -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();
}
}