mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
歇一歇
This commit is contained in:
@@ -25,14 +25,14 @@ public class BlockBehaviors {
|
||||
|
||||
public static BlockBehavior fromMap(CustomBlock block, @Nullable Map<String, Object> map) {
|
||||
if (map == null) return EmptyBlockBehavior.INSTANCE;
|
||||
String type = (String) map.getOrDefault("type", "empty");
|
||||
Object type = map.get("type");
|
||||
if (type == null) {
|
||||
throw new NullPointerException("behavior type cannot be null");
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.missing_type", new NullPointerException("behavior type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
|
||||
BlockBehaviorFactory factory = BuiltInRegistries.BLOCK_BEHAVIOR_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", new IllegalArgumentException("Unknown block behavior type: " + type), type);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.invalid_type", new IllegalArgumentException("Unknown block behavior type: " + type), type.toString());
|
||||
}
|
||||
return factory.create(block, map);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Properties {
|
||||
public static Property<?> fromMap(String name, Map<String, Object> map) {
|
||||
Object type = map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.property.lack_type", new NullPointerException("'type' cannot be null for block state property"), name);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.property.missing_type", new NullPointerException("'type' cannot be null for block state property"), name);
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
|
||||
PropertyFactory factory = BuiltInRegistries.PROPERTY_FACTORY.getValue(key);
|
||||
|
||||
@@ -357,16 +357,16 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (emojis.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.duplicated", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.duplicate", path, id);
|
||||
}
|
||||
String permission = (String) section.get("permission");
|
||||
Object keywordsRaw = section.get("keywords");
|
||||
if (keywordsRaw == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.lack_keywords", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.missing_keywords", path, id);
|
||||
}
|
||||
List<String> keywords = MiscUtils.getAsStringList(keywordsRaw);
|
||||
if (keywords.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.lack_keywords", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.emoji.missing_keywords", path, id);
|
||||
}
|
||||
String content = section.getOrDefault("content", "<arg:emoji>").toString();
|
||||
String image = null;
|
||||
@@ -418,22 +418,22 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (images.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.duplicated", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.duplicate", path, id);
|
||||
}
|
||||
|
||||
Object file = section.get("file");
|
||||
if (file == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.lack_file", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.missing_file", path, id);
|
||||
}
|
||||
|
||||
String resourceLocation = file.toString().replace("\\", "/");
|
||||
if (!ResourceLocation.isValid(resourceLocation)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_resource_location", path, id, resourceLocation);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_file_chars", path, id, resourceLocation);
|
||||
}
|
||||
|
||||
String fontName = (String) section.getOrDefault("font", "minecraft:default");
|
||||
if (!ResourceLocation.isValid(fontName)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_font_name", path, id, fontName);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_font_chars", path, id, fontName);
|
||||
}
|
||||
|
||||
Key fontKey = Key.withDefaultNamespace(fontName, id.namespace());
|
||||
@@ -444,7 +444,7 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
charsObj = section.get("char");
|
||||
}
|
||||
if (charsObj == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.lack_char", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.missing_char", path, id);
|
||||
}
|
||||
if (charsObj instanceof List<?> list) {
|
||||
chars = MiscUtils.getAsStringList(list).stream().map(it -> {
|
||||
@@ -474,7 +474,7 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
for (int codepoint : codepoints) {
|
||||
if (font.isCodepointInUse(codepoint)) {
|
||||
BitmapImage image = font.bitmapImageByCodepoint(codepoint);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.codepoint_in_use", path, id,
|
||||
throw new LocalizedResourceConfigException("warning.config.image.codepoint_conflict", path, id,
|
||||
fontKey.toString(),
|
||||
CharacterUtils.encodeCharsToUnicode(Character.toChars(codepoint)),
|
||||
new String(Character.toChars(codepoint)),
|
||||
@@ -482,7 +482,7 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
}
|
||||
}
|
||||
if (codepoints.length == 0) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.lack_char", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.missing_char", path, id);
|
||||
}
|
||||
codepointGrid[i] = codepoints;
|
||||
if (size == -1) size = codepoints.length;
|
||||
@@ -502,7 +502,7 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
.resolve(namespacedPath.value());
|
||||
|
||||
if (!Files.exists(targetImagePath)) {
|
||||
TranslationManager.instance().log("warning.config.image.file_not_exist", path.toString(), id.toString(), targetImagePath.toString());
|
||||
TranslationManager.instance().log("warning.config.image.file_not_found", path.toString(), id.toString(), targetImagePath.toString());
|
||||
// DO NOT RETURN, JUST GIVE WARNINGS
|
||||
} else if (heightObj == null) {
|
||||
try (InputStream in = Files.newInputStream(targetImagePath)) {
|
||||
@@ -515,13 +515,13 @@ public abstract class AbstractFontManager implements FontManager {
|
||||
}
|
||||
|
||||
if (heightObj == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.lack_height", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.missing_height", path, id);
|
||||
}
|
||||
|
||||
int height = ResourceConfigUtils.getAsInt(heightObj, "height");
|
||||
int ascent = ResourceConfigUtils.getAsInt(section.getOrDefault("ascent", height - 1), "ascent");
|
||||
if (height < ascent) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.height_smaller_than_ascent", path, id, String.valueOf(height), String.valueOf(ascent));
|
||||
throw new LocalizedResourceConfigException("warning.config.image.height_ascent_conflict", path, id, String.valueOf(height), String.valueOf(ascent));
|
||||
}
|
||||
|
||||
BitmapImage bitmapImage = new BitmapImage(id, fontKey, height, ascent, resourceLocation, codepointGrid);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ItemBehaviors {
|
||||
public static ItemBehavior fromMap(Pack pack, Path path, Key id, Map<String, Object> map) {
|
||||
Object type = map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.lack_type", new NullPointerException("behavior type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.behavior.missing_type", new NullPointerException("behavior type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type.toString(), "craftengine");
|
||||
ItemBehaviorFactory factory = BuiltInRegistries.ITEM_BEHAVIOR_FACTORY.getValue(key);
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractRecipeFactory<T> implements RecipeFactory<T> {
|
||||
ingredient = arguments.get("ingredients");
|
||||
}
|
||||
if (ingredient == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.lack_ingredient", new NullPointerException("'ingredient' should not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.missing_ingredient", new NullPointerException("'ingredient' should not be null"));
|
||||
}
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (!Config.enableRecipeSystem()) return;
|
||||
if (AbstractRecipeManager.this.byId.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.duplicated", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.duplicate", path, id);
|
||||
}
|
||||
Recipe<T> recipe = RecipeTypes.fromMap(id, section);
|
||||
try {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class CustomShapedRecipe<T> extends CustomCraftingTableRecipe<T> {
|
||||
public Recipe<A> create(Key id, Map<String, Object> arguments) {
|
||||
List<String> pattern = MiscUtils.getAsStringList(arguments.get("pattern"));
|
||||
if (pattern.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.lack_pattern", new NullPointerException("'pattern' cannot be empty"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.missing_pattern", new NullPointerException("'pattern' cannot be empty"));
|
||||
}
|
||||
if (!validatePattern(pattern)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.shaped.invalid_pattern", new IllegalArgumentException("Invalid pattern: " + pattern), pattern.toString());
|
||||
|
||||
@@ -182,7 +182,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
|
||||
public static ItemDataProcessor fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.lack_type", new NullPointerException("Missing required parameter 'type' for post processor"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.missing_type", new NullPointerException("Missing required parameter 'type' for post processor"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
ItemDataProcessor.Factory factory = BuiltInRegistries.SMITHING_RESULT_PROCESSOR_FACTORY.getValue(key);
|
||||
@@ -237,7 +237,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
|
||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_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());
|
||||
@@ -274,7 +274,7 @@ public class CustomSmithingTransformRecipe<T> implements Recipe<T> {
|
||||
public ItemDataProcessor create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.smithing_transform.post_processor.keep_component.missing_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());
|
||||
|
||||
@@ -16,11 +16,11 @@ public interface RecipeFactory<T> {
|
||||
default CustomRecipeResult<T> parseResult(Map<String, Object> arguments) {
|
||||
Map<String, Object> resultMap = MiscUtils.castToMap(arguments.get("result"), true);
|
||||
if (resultMap == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.lack_result", new IllegalArgumentException("result cannot be empty for recipe"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.missing_result", new IllegalArgumentException("result cannot be empty for recipe"));
|
||||
}
|
||||
String id = (String) resultMap.get("id");
|
||||
if (id == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.result.lack_id", new IllegalArgumentException("id cannot be empty for result"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.result.missing_id", new IllegalArgumentException("id cannot be empty for result"));
|
||||
}
|
||||
int count = ResourceConfigUtils.getAsInt(resultMap.getOrDefault("count", 1), "count");
|
||||
return new CustomRecipeResult(
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RecipeTypes {
|
||||
public static <T> Recipe<T> fromMap(Key id, Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.lack_type", new NullPointerException("'type' cannot be null for recipe"));
|
||||
throw new LocalizedResourceConfigException("warning.config.recipe.missing_type", new NullPointerException("'type' cannot be null for recipe"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
RecipeFactory<T> factory = (RecipeFactory<T>) BuiltInRegistries.RECIPE_FACTORY.getValue(key);
|
||||
|
||||
@@ -42,10 +42,10 @@ public class LootTable<T> {
|
||||
if (map == null || map.isEmpty()) return null;
|
||||
Object pools = map.get("pools");
|
||||
if (pools == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.lack_pools");
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.missing_pools");
|
||||
}
|
||||
if (!(pools instanceof List<?> list) || list.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.wrong_pools_type", pools.getClass().getSimpleName());
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.invalid_pools_type", pools.getClass().getSimpleName());
|
||||
}
|
||||
List<Object> poolList = (List<Object>) map.get("pools");
|
||||
List<LootPool<T>> lootPools = new ArrayList<>();
|
||||
@@ -56,15 +56,15 @@ public class LootTable<T> {
|
||||
NumberProvider bonus_rolls = NumberProviders.fromObject(pool.getOrDefault("bonus_rolls", 0));
|
||||
List<LootCondition> conditions = Optional.ofNullable(pool.get("conditions"))
|
||||
.map(it -> LootConditions.fromMapList(castToMapListOrThrow(it,
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.wrong_conditions_type", new RuntimeException("'conditions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName()))))
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_conditions_type", new RuntimeException("'conditions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName()))))
|
||||
.orElse(Lists.newArrayList());
|
||||
List<LootEntryContainer<T>> containers = Optional.ofNullable(pool.get("entries"))
|
||||
.map(it -> (List<LootEntryContainer<T>>) new ArrayList<LootEntryContainer<T>>(LootEntryContainers.fromMapList(castToMapListOrThrow(it,
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.wrong_entries_type", new RuntimeException("'entries' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_entries_type", new RuntimeException("'entries' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
.orElse(Lists.newArrayList());
|
||||
List<LootFunction<T>> functions = Optional.ofNullable(pool.get("functions"))
|
||||
.map(it -> (List<LootFunction<T>>) new ArrayList<LootFunction<T>>(LootFunctions.fromMapList(castToMapListOrThrow(it,
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.wrong_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
.orElse(Lists.newArrayList());
|
||||
lootPools.add(new LootPool<>(containers, conditions, functions, rolls, bonus_rolls));
|
||||
} else if (rawPool instanceof String string) {
|
||||
@@ -76,7 +76,7 @@ public class LootTable<T> {
|
||||
return new LootTable<>(lootPools,
|
||||
Optional.ofNullable(map.get("functions"))
|
||||
.map(it -> (List<LootFunction<T>>) new ArrayList<LootFunction<T>>(LootFunctions.fromMapList(castToMapListOrThrow(it,
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.wrong_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
() -> new LocalizedResourceConfigException("warning.config.loot_table.invalid_functions_type", new RuntimeException("'functions' should be a map list, current type: " + it.getClass().getSimpleName()), it.getClass().getSimpleName())))))
|
||||
.orElse(Lists.newArrayList())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class LootConditions {
|
||||
public static LootCondition fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.lack_type", new NullPointerException("condition type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.missing_type", new NullPointerException("condition type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootConditionFactory factory = BuiltInRegistries.LOOT_CONDITION_FACTORY.getValue(key);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TableBonusCondition implements LootCondition {
|
||||
public LootCondition create(Map<String, Object> arguments) {
|
||||
Object enchantmentObj = arguments.get("enchantment");
|
||||
if (enchantmentObj == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.table_bonus.lack_enchantment", new NullPointerException("'enchantment' should not be null for table bonus"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.table_bonus.missing_enchantment");
|
||||
}
|
||||
Key enchantmentType = Key.of(enchantmentObj.toString());
|
||||
Object chances = arguments.get("chances");
|
||||
@@ -57,7 +57,7 @@ public class TableBonusCondition implements LootCondition {
|
||||
return new TableBonusCondition(enchantmentType, values);
|
||||
}
|
||||
}
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.table_bonus.lack_chances", new NullPointerException("'chances' should not be null for table bonus"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.table_bonus.missing_chances");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ExpLootEntryContainer<T> extends AbstractLootEntryContainer<T> {
|
||||
public LootEntryContainer<A> create(Map<String, Object> arguments) {
|
||||
Object value = arguments.get("count");
|
||||
if (value == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.exp.lack_count", new IllegalArgumentException("'count' is required for exp entry"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.exp.missing_count", new IllegalArgumentException("'count' is required for exp entry"));
|
||||
}
|
||||
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
|
||||
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))
|
||||
|
||||
@@ -42,7 +42,7 @@ public class LootEntryContainers {
|
||||
public static <T> LootEntryContainer<T> fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.lack_type", new NullPointerException("loot entry type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.missing_type", new NullPointerException("loot entry type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootEntryContainerFactory<T> factory = (LootEntryContainerFactory<T>) BuiltInRegistries.LOOT_ENTRY_CONTAINER_FACTORY.getValue(key);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SingleItemLootEntryContainer<T> extends AbstractSingleLootEntryCont
|
||||
public LootEntryContainer<A> create(Map<String, Object> arguments) {
|
||||
Object itemObj = arguments.get("item");
|
||||
if (itemObj == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.item.lack_item", new IllegalArgumentException("'item' is required for item entry"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.item.missing_item", new IllegalArgumentException("'item' is required for item entry"));
|
||||
}
|
||||
Key item = Key.from(itemObj.toString());
|
||||
int weight = (int) arguments.getOrDefault("weight", 1);
|
||||
|
||||
@@ -51,11 +51,11 @@ public class ApplyBonusCountFunction<T> extends AbstractLootConditionalFunction<
|
||||
public LootFunction<T> create(Map<String, Object> arguments) {
|
||||
String enchantment = (String) arguments.get("enchantment");
|
||||
if (enchantment == null || enchantment.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.lack_enchantment", new IllegalArgumentException("'enchantment' is required for apply_bonus function"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_enchantment", new IllegalArgumentException("'enchantment' is required for apply_bonus function"));
|
||||
}
|
||||
Map<String, Object> formulaMap = MiscUtils.castToMap(arguments.get("formula"), true);
|
||||
if (formulaMap == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.lack_formula", new IllegalArgumentException("formula is required"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.apply_bonus.missing_formula", new IllegalArgumentException("formula is required"));
|
||||
}
|
||||
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
|
||||
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DropExpFunction<T> extends AbstractLootConditionalFunction<T> {
|
||||
public LootFunction<T> create(Map<String, Object> arguments) {
|
||||
Object value = arguments.get("count");
|
||||
if (value == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.drop_exp.lack_count", new IllegalArgumentException("'count' is required for drop_exp function"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.drop_exp.missing_count", new IllegalArgumentException("'count' is required for drop_exp function"));
|
||||
}
|
||||
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
|
||||
.map(it -> LootConditions.fromMapList((List<Map<String, Object>>) it))
|
||||
|
||||
@@ -70,7 +70,7 @@ public class LootFunctions {
|
||||
public static <T> LootFunction<T> fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.lack_type", new NullPointerException("function type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.missing_type", new NullPointerException("function type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootFunctionFactory<T> factory = (LootFunctionFactory<T>) BuiltInRegistries.LOOT_FUNCTION_FACTORY.getValue(key);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SetCountFunction<T> extends AbstractLootConditionalFunction<T> {
|
||||
public LootFunction<A> create(Map<String, Object> arguments) {
|
||||
Object value = arguments.get("count");
|
||||
if (value == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.set_count.lack_count", new IllegalArgumentException("'count' is required for set_count function"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.set_count.missing_count", new IllegalArgumentException("'count' is required for set_count function"));
|
||||
}
|
||||
boolean add = (boolean) arguments.getOrDefault("add", false);
|
||||
List<LootCondition> conditions = Optional.ofNullable(arguments.get("conditions"))
|
||||
|
||||
@@ -39,7 +39,7 @@ public class NumberProviders {
|
||||
public static NumberProvider fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.number.lack_type", new NullPointerException("number type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.number.missing_type", new NullPointerException("number type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
NumberProviderFactory factory = BuiltInRegistries.NUMBER_PROVIDER_FACTORY.getValue(key);
|
||||
|
||||
@@ -460,7 +460,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
parser.parseSection(cached.pack(), cached.filePath(), id, plugin.templateManager().applyTemplates(configSection1));
|
||||
}
|
||||
} else {
|
||||
TranslationManager.instance().log("warning.config.not_a_section", cached.filePath().toString(), cached.prefix() + "." + key, configEntry.getValue().getClass().getSimpleName());
|
||||
TranslationManager.instance().log("warning.config.structure.not_section", cached.filePath().toString(), cached.prefix() + "." + key, configEntry.getValue().getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
} catch (LocalizedException e) {
|
||||
|
||||
@@ -29,11 +29,11 @@ public class ExactPathMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String path = (String) arguments.get("path");
|
||||
Object path = arguments.get("path");
|
||||
if (path == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.exact.lack_path", new IllegalArgumentException("The 'path' argument must not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.exact.missing_path", new IllegalArgumentException("The 'path' argument must not be null"));
|
||||
}
|
||||
return new ExactPathMatcher(path);
|
||||
return new ExactPathMatcher(path.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ public class FilenameMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String name = (String) arguments.get("name");
|
||||
Object name = arguments.get("name");
|
||||
if (name == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.filename.lack_name", new IllegalArgumentException("The 'name' argument must not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.filename.missing_name", new IllegalArgumentException("The 'name' argument must not be null"));
|
||||
}
|
||||
return new FilenameMatcher(name);
|
||||
return new FilenameMatcher(name.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ public class ParentPathPrefixMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String prefix = (String) arguments.get("prefix");
|
||||
Object prefix = arguments.get("prefix");
|
||||
if (prefix == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_path_prefix.lack_prefix", new IllegalArgumentException("The prefix argument must not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_prefix.missing_prefix", new IllegalArgumentException("The prefix argument must not be null"));
|
||||
}
|
||||
return new ParentPathPrefixMatcher(prefix);
|
||||
return new ParentPathPrefixMatcher(prefix.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ public class ParentPathSuffixMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String suffix = (String) arguments.get("suffix");
|
||||
Object suffix = arguments.get("suffix");
|
||||
if (suffix == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_path_suffix.lack_suffix", new IllegalArgumentException("The suffix argument must not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.parent_suffix.missing_suffix");
|
||||
}
|
||||
return new ParentPathSuffixMatcher(suffix);
|
||||
return new ParentPathSuffixMatcher(suffix.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ public class PathContainsMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String path = (String) arguments.get("path");
|
||||
Object path = arguments.get("path");
|
||||
if (path == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.contains.lack_path", new NullPointerException("path should not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.contains.missing_path", new NullPointerException("path should not be null"));
|
||||
}
|
||||
return new PathContainsMatcher(path);
|
||||
return new PathContainsMatcher(path.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PathMatchers {
|
||||
public static PathMatcher fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.getOrDefault("type", "empty");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.lack_type", new NullPointerException("path matcher type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.missing_type", new NullPointerException("path matcher type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
PathMatcherFactory factory = BuiltInRegistries.PATH_MATCHER_FACTORY.getValue(key);
|
||||
|
||||
@@ -29,11 +29,11 @@ public class PathPatternMatcher implements PathMatcher {
|
||||
|
||||
@Override
|
||||
public PathMatcher create(Map<String, Object> arguments) {
|
||||
String pattern = (String) arguments.get("pattern");
|
||||
Object pattern = arguments.get("pattern");
|
||||
if (pattern == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.pattern.lack_pattern", new IllegalArgumentException("The pattern argument must not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_matcher.pattern.missing_pattern", new IllegalArgumentException("The pattern argument must not be null"));
|
||||
}
|
||||
return new PathPatternMatcher(pattern);
|
||||
return new PathPatternMatcher(pattern.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ public class Resolutions {
|
||||
public static Resolution fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.getOrDefault("type", "empty");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_resolution.lack_type", new NullPointerException("path matcher type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_resolution.missing_type");
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
ResolutionFactory factory = BuiltInRegistries.RESOLUTION_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_resolution.invalid_type", new IllegalArgumentException("Unknown matcher type: " + type), type);
|
||||
throw new LocalizedResourceConfigException("warning.config.conflict_resolution.invalid_type", type);
|
||||
}
|
||||
return factory.create(map);
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ public interface ResourcePackHostFactory {
|
||||
if (proxySetting != null) {
|
||||
Object hostObj = proxySetting.get("host");
|
||||
if (hostObj == null) {
|
||||
throw new LocalizedException("warning.config.host.proxy.lack_host", new NullPointerException("'host' should not be null for proxy setting"));
|
||||
throw new LocalizedException("warning.config.host.proxy.missing_host", new NullPointerException("'host' should not be null for proxy setting"));
|
||||
}
|
||||
String proxyHost = hostObj.toString();
|
||||
Object portObj = proxySetting.get("port");
|
||||
if (portObj == null) {
|
||||
throw new LocalizedException("warning.config.host.proxy.lack_port", new NullPointerException("'port' should not be null for proxy setting"));
|
||||
throw new LocalizedException("warning.config.host.proxy.missing_port", new NullPointerException("'port' should not be null for proxy setting"));
|
||||
}
|
||||
int proxyPort = ResourceConfigUtils.getAsInt(portObj, "port");
|
||||
if (proxyHost == null || proxyHost.isEmpty() || proxyPort <= 0 || proxyPort > 65535) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ResourcePackHosts {
|
||||
public static ResourcePackHost fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedException("warning.config.host.external.lack_url");
|
||||
throw new LocalizedException("warning.config.host.missing_type");
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
ResourcePackHostFactory factory = BuiltInRegistries.RESOURCE_PACK_HOST_FACTORY.getValue(key);
|
||||
|
||||
@@ -294,22 +294,22 @@ public class AlistHost implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String apiUrl = (String) arguments.get("api-url");
|
||||
if (apiUrl == null || apiUrl.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.alist.lack_api_url");
|
||||
throw new LocalizedException("warning.config.host.alist.missing_api_url");
|
||||
}
|
||||
String userName = useEnv ? System.getenv("CE_ALIST_USERNAME") : (String) arguments.get("username");
|
||||
if (userName == null || userName.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.alist.lack_username");
|
||||
throw new LocalizedException("warning.config.host.alist.missing_username");
|
||||
}
|
||||
String password = useEnv ? System.getenv("CE_ALIST_PASSWORD") : (String) arguments.get("password");
|
||||
if (password == null || password.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.alist.lack_password");
|
||||
throw new LocalizedException("warning.config.host.alist.missing_password");
|
||||
}
|
||||
String filePassword = useEnv ? System.getenv("CE_ALIST_FILE_PASSWORD") : (String) arguments.getOrDefault("file-password", "");
|
||||
String otpCode = (String) arguments.get("otp-code");
|
||||
Duration jwtTokenExpiration = Duration.ofHours((int) arguments.getOrDefault("jwt-token-expiration", 48));
|
||||
String uploadPath = (String) arguments.get("upload-path");
|
||||
if (uploadPath == null || uploadPath.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.alist.lack_upload_path");
|
||||
throw new LocalizedException("warning.config.host.alist.missing_upload_path");
|
||||
}
|
||||
boolean disableUpload = (boolean) arguments.getOrDefault("disable-upload", false);
|
||||
ProxySelector proxy = getProxySelector(MiscUtils.castToMap(arguments.get("proxy"), true));
|
||||
|
||||
@@ -269,19 +269,19 @@ public class DropboxHost implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String appKey = useEnv ? System.getenv("CE_DROPBOX_APP_KEY") : (String) arguments.get("app-key");
|
||||
if (appKey == null || appKey.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.dropbox.lack_app_key");
|
||||
throw new LocalizedException("warning.config.host.dropbox.missing_app_key");
|
||||
}
|
||||
String appSecret = useEnv ? System.getenv("CE_DROPBOX_APP_SECRET") : (String) arguments.get("app-secret");
|
||||
if (appSecret == null || appSecret.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.dropbox.lack_app_secret");
|
||||
throw new LocalizedException("warning.config.host.dropbox.missing_app_secret");
|
||||
}
|
||||
String refreshToken = useEnv ? System.getenv("CE_DROPBOX_REFRESH_TOKEN") : (String) arguments.get("refresh-token");
|
||||
if (refreshToken == null || refreshToken.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.dropbox.lack_refresh_token");
|
||||
throw new LocalizedException("warning.config.host.dropbox.missing_refresh_token");
|
||||
}
|
||||
String uploadPath = (String) arguments.get("upload-path");
|
||||
if (uploadPath == null || uploadPath.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.dropbox.lack_upload_path");
|
||||
throw new LocalizedException("warning.config.host.dropbox.missing_upload_path");
|
||||
}
|
||||
ProxySelector proxy = getProxySelector(MiscUtils.castToMap(arguments.get("proxy"), true));
|
||||
return new DropboxHost(appKey, appSecret, refreshToken, "/" + uploadPath, proxy);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ExternalHost implements ResourcePackHost {
|
||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
||||
String url = (String) arguments.get("url");
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.external.lack_url");
|
||||
throw new LocalizedException("warning.config.host.external.missing_url");
|
||||
}
|
||||
String uuid = (String) arguments.get("uuid");
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
|
||||
@@ -179,18 +179,18 @@ public class GitLabHost implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String gitlabUrl = (String) arguments.get("gitlab-url");
|
||||
if (gitlabUrl == null || gitlabUrl.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.gitlab.lack_url");
|
||||
throw new LocalizedException("warning.config.host.gitlab.missing_url");
|
||||
}
|
||||
if (gitlabUrl.endsWith("/")) {
|
||||
gitlabUrl = gitlabUrl.substring(0, gitlabUrl.length() - 1);
|
||||
}
|
||||
String accessToken = useEnv ? System.getenv("CE_GITLAB_ACCESS_TOKEN") : (String) arguments.get("access-token");
|
||||
if (accessToken == null || accessToken.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.gitlab.lack_access_token");
|
||||
throw new LocalizedException("warning.config.host.gitlab.missing_token");
|
||||
}
|
||||
String projectId = (String) arguments.get("project-id");
|
||||
if (projectId == null || projectId.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.gitlab.lack_project_id");
|
||||
throw new LocalizedException("warning.config.host.gitlab.missing_project");
|
||||
}
|
||||
projectId = URLEncoder.encode(projectId, StandardCharsets.UTF_8).replace("/", "%2F");
|
||||
ProxySelector proxy = getProxySelector(MiscUtils.castToMap(arguments.get("proxy"), true));
|
||||
|
||||
@@ -274,7 +274,7 @@ public class LobFileHost implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String apiKey = useEnv ? System.getenv("CE_LOBFILE_API_KEY") : (String) arguments.get("api-key");
|
||||
if (apiKey == null || apiKey.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.lobfile.lack_api_key");
|
||||
throw new LocalizedException("warning.config.host.lobfile.missing_api_key");
|
||||
}
|
||||
ProxySelector proxy = getProxySelector(MiscUtils.castToMap(arguments.get("proxy"), true));
|
||||
return new LobFileHost(apiKey, proxy);
|
||||
|
||||
@@ -234,19 +234,19 @@ public class OneDriveHost implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String clientId = useEnv ? System.getenv("CE_ONEDRIVE_CLIENT_ID") : (String) arguments.get("client-id");
|
||||
if (clientId == null || clientId.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.onedrive.lack_client_id");
|
||||
throw new LocalizedException("warning.config.host.onedrive.missing_client_id");
|
||||
}
|
||||
String clientSecret = useEnv ? System.getenv("CE_ONEDRIVE_CLIENT_SECRET") : (String) arguments.get("client-secret");
|
||||
if (clientSecret == null || clientSecret.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.onedrive.lack_client_secret");
|
||||
throw new LocalizedException("warning.config.host.onedrive.missing_client_secret");
|
||||
}
|
||||
String refreshToken = useEnv ? System.getenv("CE_ONEDRIVE_REFRESH_TOKEN") : (String) arguments.get("refresh-token");
|
||||
if (refreshToken == null || refreshToken.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.onedrive.lack_refresh_token");
|
||||
throw new LocalizedException("warning.config.host.onedrive.missing_refresh_token");
|
||||
}
|
||||
String uploadPath = (String) arguments.getOrDefault("upload-path", "resource_pack.zip");
|
||||
if (uploadPath == null || uploadPath.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.onedrive.lack_upload_path");
|
||||
throw new LocalizedException("warning.config.host.onedrive.missing_upload_path");
|
||||
}
|
||||
ProxySelector proxy = getProxySelector(MiscUtils.castToMap(arguments.get("proxy"), true));
|
||||
return new OneDriveHost(clientId, clientSecret, refreshToken, uploadPath, proxy);
|
||||
|
||||
@@ -160,26 +160,26 @@ public class S3Host implements ResourcePackHost {
|
||||
boolean useEnv = (boolean) arguments.getOrDefault("use-environment-variables", false);
|
||||
String endpoint = (String) arguments.get("endpoint");
|
||||
if (endpoint == null || endpoint.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.s3.lack_endpoint");
|
||||
throw new LocalizedException("warning.config.host.s3.missing_endpoint");
|
||||
}
|
||||
String protocol = (String) arguments.getOrDefault("protocol", "https");
|
||||
boolean usePathStyle = (boolean) arguments.getOrDefault("path-style", false);
|
||||
String bucket = (String) arguments.get("bucket");
|
||||
if (bucket == null || bucket.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.s3.lack_bucket");
|
||||
throw new LocalizedException("warning.config.host.s3.missing_bucket");
|
||||
}
|
||||
String region = (String) arguments.getOrDefault("region", "auto");
|
||||
String accessKeyId = useEnv ? System.getenv("CE_S3_ACCESS_KEY_ID") : (String) arguments.get("access-key-id");
|
||||
if (accessKeyId == null || accessKeyId.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.s3.lack_access_key_id");
|
||||
throw new LocalizedException("warning.config.host.s3.missing_access_key");
|
||||
}
|
||||
String accessKeySecret = useEnv ? System.getenv("CE_S3_ACCESS_KEY_SECRET") : (String) arguments.get("access-key-secret");
|
||||
if (accessKeySecret == null || accessKeySecret.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.s3.lack_access_key_secret");
|
||||
throw new LocalizedException("warning.config.host.s3.missing_secret");
|
||||
}
|
||||
String uploadPath = (String) arguments.getOrDefault("upload-path", "craftengine/resource_pack.zip");
|
||||
if (uploadPath == null || uploadPath.isEmpty()) {
|
||||
throw new LocalizedException("warning.config.host.s3.lack_upload_path");
|
||||
throw new LocalizedException("warning.config.host.s3.missing_upload_path");
|
||||
}
|
||||
boolean useLegacySignature = (boolean) arguments.getOrDefault("use-legacy-signature", true);
|
||||
Duration validity = Duration.ofSeconds((int) arguments.getOrDefault("validity", 10));
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SelfHost implements ResourcePackHost {
|
||||
SelfHostHttpServer selfHostHttpServer = SelfHostHttpServer.instance();
|
||||
String ip = (String) arguments.get("ip");
|
||||
if (ip == null) {
|
||||
throw new LocalizedException("warning.config.host.self.lack_ip");
|
||||
throw new LocalizedException("warning.config.host.self.missing_ip");
|
||||
}
|
||||
int port = ResourceConfigUtils.getAsInt(arguments.getOrDefault("port", 8163), "port");
|
||||
if (port < 0 || port > 65535) {
|
||||
|
||||
@@ -71,11 +71,11 @@ public class BaseItemModel implements ItemModel {
|
||||
public ItemModel create(Map<String, Object> arguments) {
|
||||
Object path = arguments.get("path");
|
||||
if (path == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.base.lack_path", new NullPointerException("'path' is required for 'minecraft:model'"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.base.missing_path", new NullPointerException("'path' is required for 'minecraft:model'"));
|
||||
}
|
||||
String modelPath = path.toString();
|
||||
if (!ResourceLocation.isValid(modelPath)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_resource_location", new IllegalArgumentException("Invalid resource location: " + modelPath), modelPath);
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.base.invalid_path", new IllegalArgumentException("Invalid resource location: " + modelPath), modelPath);
|
||||
}
|
||||
Map<String, Object> generation = MiscUtils.castToMap(arguments.get("generation"), true);
|
||||
ModelGeneration modelGeneration = null;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class CompositeItemModel implements ItemModel {
|
||||
if (m instanceof List<?> list) {
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) list;
|
||||
if (models.isEmpty()) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.composite.lack_models", new IllegalArgumentException("'models' list should not be empty for 'minecraft:composite'"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models", new IllegalArgumentException("'models' list should not be empty for 'minecraft:composite'"));
|
||||
}
|
||||
List<ItemModel> modelList = new ArrayList<>();
|
||||
for (Map<String, Object> model : models) {
|
||||
@@ -68,7 +68,7 @@ public class CompositeItemModel implements ItemModel {
|
||||
} else if (m instanceof Map<?, ?> map) {
|
||||
return new CompositeItemModel(List.of(ItemModels.fromMap(MiscUtils.castToMap(map, false))));
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.composite.lack_models", new NullPointerException("'models' argument is required for 'minecraft:composite'"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.composite.missing_models", new NullPointerException("'models' argument is required for 'minecraft:composite'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +68,13 @@ public class ConditionItemModel implements ItemModel {
|
||||
if (arguments.get("on-true") instanceof Map<?,?> map1) {
|
||||
onTrue = ItemModels.fromMap(MiscUtils.castToMap(map1, false));
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.lack_on_true", new NullPointerException("'on-true' is required for condition"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_true", new NullPointerException("'on-true' is required for condition"));
|
||||
}
|
||||
ItemModel onFalse;
|
||||
if (arguments.get("on-false") instanceof Map<?,?> map2) {
|
||||
onFalse = ItemModels.fromMap(MiscUtils.castToMap(map2, false));
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.lack_on_false", new NullPointerException("'on-false' is required for condition"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_on_false", new NullPointerException("'on-false' is required for condition"));
|
||||
}
|
||||
return new ConditionItemModel(property, onTrue, onFalse);
|
||||
}
|
||||
|
||||
@@ -109,16 +109,16 @@ public class RangeDispatchItemModel implements ItemModel {
|
||||
float threshold = ResourceConfigUtils.getAsFloat(entry.getOrDefault("threshold", 1), "threshold");
|
||||
Object model = entry.getOrDefault("model", fallback);
|
||||
if (model == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.entry.lack_model", new NullPointerException("'model' is required for range_dispatch entry"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.entry.missing_model", new NullPointerException("'model' is required for range_dispatch entry"));
|
||||
}
|
||||
entryMap.put(threshold, ItemModels.fromMap(MiscUtils.castToMap(model, false)));
|
||||
}
|
||||
return new RangeDispatchItemModel(property, scale, fallback == null ? null : ItemModels.fromMap(fallback), entryMap);
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.lack_entries", new IllegalArgumentException("No entries found for range_dispatch"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries", new IllegalArgumentException("No entries found for range_dispatch"));
|
||||
}
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.lack_entries", new NullPointerException("'entries' is required for the range_dispatch model"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_entries", new NullPointerException("'entries' is required for the range_dispatch model"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SelectItemModel implements ItemModel {
|
||||
for (Map<String, Object> c : cases) {
|
||||
Object when = c.get("when");
|
||||
if (when == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.lack_when", new NullPointerException("'when' should not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_when", new NullPointerException("'when' should not be null"));
|
||||
}
|
||||
Either<String, List<String>> either;
|
||||
if (when instanceof List<?> whenList) {
|
||||
@@ -120,16 +120,16 @@ public class SelectItemModel implements ItemModel {
|
||||
}
|
||||
Object model = c.get("model");
|
||||
if (model == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.lack_model", new NullPointerException("'model' should not be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.case.missing_model", new NullPointerException("'model' should not be null"));
|
||||
}
|
||||
whenMap.put(either, ItemModels.fromMap(MiscUtils.castToMap(model, false)));
|
||||
}
|
||||
return new SelectItemModel(property, whenMap, fallback == null ? null : ItemModels.fromMap(fallback));
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.lack_cases", new NullPointerException("'cases' is required for the select model"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases", new NullPointerException("'cases' is required for the select model"));
|
||||
}
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.lack_cases", new NullPointerException("'cases' is required for the select model"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_cases", new NullPointerException("'cases' is required for the select model"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ConditionProperties {
|
||||
public static ConditionProperty fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("property");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.lack_property", new NullPointerException("property type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.missing_property", new NullPointerException("property type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
ConditionPropertyFactory factory = BuiltInRegistries.CONDITION_PROPERTY_FACTORY.getValue(key);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HasComponentConditionProperty implements ConditionProperty {
|
||||
boolean ignoreDefault = (boolean) arguments.getOrDefault("ignore-default", false);
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.has_component.missing_component", new NullPointerException("component should not be null"));
|
||||
}
|
||||
String component = componentObj.toString();
|
||||
return new HasComponentConditionProperty(component, ignoreDefault);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class KeyBindDownConditionProperty implements ConditionProperty {
|
||||
public ConditionProperty create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.condition.keybind.missing", new NullPointerException("keybind should not be null"));
|
||||
}
|
||||
String keybind = keybindObj.toString();
|
||||
return new KeyBindDownConditionProperty(keybind);
|
||||
|
||||
@@ -2,10 +2,9 @@ package net.momirealms.craftengine.core.pack.model.generation;
|
||||
|
||||
import net.momirealms.craftengine.core.pack.ResourceLocation;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -28,21 +27,20 @@ public abstract class AbstractModelGenerator implements ModelGenerator {
|
||||
this.modelsToGenerate.clear();
|
||||
}
|
||||
|
||||
public void prepareModelGeneration(Path path, Key id, ModelGeneration model) {
|
||||
public void prepareModelGeneration(ModelGeneration model) {
|
||||
ModelGeneration conflict = this.modelsToGenerate.get(model.path());
|
||||
if (conflict != null) {
|
||||
if (conflict.equals(model)) {
|
||||
return;
|
||||
}
|
||||
TranslationManager.instance().log("warning.config.model.generation.conflict", path.toString(), id.toString(), model.path().toString());
|
||||
return;
|
||||
throw new LocalizedResourceConfigException("warning.config.model.generation.conflict", model.path().toString());
|
||||
}
|
||||
if (!ResourceLocation.isValid(model.parentModelPath())) {
|
||||
TranslationManager.instance().log("warning.config.model.generation.parent.invalid_resource_location", path.toString(), id.toString(), model.parentModelPath());
|
||||
throw new LocalizedResourceConfigException("warning.config.model.generation.parent.invalid", model.parentModelPath());
|
||||
}
|
||||
for (Map.Entry<String, String> texture : model.texturesOverride().entrySet()) {
|
||||
if (!ResourceLocation.isValid(texture.getValue())) {
|
||||
TranslationManager.instance().log("warning.config.model.generation.texture.invalid_resource_location", path.toString(), id.toString(), texture.getKey(), texture.getValue());
|
||||
throw new LocalizedResourceConfigException("warning.config.model.generation.texture.invalid", texture.getKey(), texture.getValue());
|
||||
}
|
||||
}
|
||||
this.modelsToGenerate.put(model.path(), model);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ModelGeneration {
|
||||
this.path = path;
|
||||
Object parent = map.get("parent");
|
||||
if (parent == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.model.generation.lack_parent", new NullPointerException("'parent' argument is required for generation"));
|
||||
throw new LocalizedResourceConfigException("warning.config.model.generation.missing_parent", new NullPointerException("'parent' argument is required for generation"));
|
||||
}
|
||||
this.parentModelPath = parent.toString();
|
||||
Map<String, Object> texturesMap = MiscUtils.castToMap(map.get("textures"), true);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CompassRangeDispatchProperty implements RangeDispatchProperty {
|
||||
public RangeDispatchProperty create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.compass.missing_target", new NullPointerException("target should not be null"));
|
||||
}
|
||||
String target = targetObj.toString();
|
||||
return new CompassRangeDispatchProperty(target);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class RangeDispatchProperties {
|
||||
public static RangeDispatchProperty fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("property");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.lack_property", new NullPointerException("property type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.missing_property", new NullPointerException("property type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
RangeDispatchPropertyFactory factory = BuiltInRegistries.RANGE_DISPATCH_PROPERTY_FACTORY.getValue(key);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TimeRangeDispatchProperty implements RangeDispatchProperty {
|
||||
public RangeDispatchProperty create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.range_dispatch.time.missing_source", new NullPointerException("source should not be null"));
|
||||
}
|
||||
String source = sourceObj.toString();
|
||||
boolean wobble = (boolean) arguments.getOrDefault("wobble", true);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class BlockStateSelectProperty implements SelectProperty {
|
||||
public SelectProperty create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.block_state.missing_property", new NullPointerException("block-state-property should not be null"));
|
||||
}
|
||||
String blockStateProperty = property.toString();
|
||||
return new BlockStateSelectProperty(blockStateProperty);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LocalTimeSelectProperty implements SelectProperty {
|
||||
public SelectProperty create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new IllegalArgumentException("warning.config.item.model.select.local_time.missing_pattern", new NullPointerException("pattern should not be null"));
|
||||
}
|
||||
String pattern = patternObj.toString();
|
||||
String locale = (String) arguments.get("locale");
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SelectProperties {
|
||||
public static SelectProperty fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("property");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.lack_property", new NullPointerException("property type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.select.missing_property", new NullPointerException("property type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
SelectPropertyFactory factory = BuiltInRegistries.SELECT_PROPERTY_FACTORY.getValue(key);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SpecialModels {
|
||||
public static SpecialModel fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.special.lack_type", new NullPointerException("special model type cannot be null"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.special.missing_type", new NullPointerException("special model type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
SpecialModelFactory factory = BuiltInRegistries.SPECIAL_MODEL_FACTORY.getValue(key);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ConstantTint implements Tint {
|
||||
public Tint create(Map<String, Object> arguments) {
|
||||
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"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.constant.missing_value", new NullPointerException("value should not be null"));
|
||||
}
|
||||
return new ConstantTint(parseTintValue(value));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GrassTint implements Tint {
|
||||
float temperature = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("temperature", 0), "temperature");
|
||||
float downfall = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("downfall", 0), "downfall");
|
||||
if (temperature > 1 || temperature < 0) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_temperature", new IllegalArgumentException("Invalid temperature: " + temperature + ". Valid range 0~1"), String.valueOf(temperature));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_temp", new IllegalArgumentException("Invalid temperature: " + temperature + ". Valid range 0~1"), String.valueOf(temperature));
|
||||
}
|
||||
if (downfall > 1 || downfall < 0) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.grass.invalid_downfall", new IllegalArgumentException("Invalid downfall: " + downfall + ". Valid range 0~1"), String.valueOf(downfall));
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Tints {
|
||||
public static Tint fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.lack_type", new NullPointerException("'type' cannot be null for tint"));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.model.tint.missing_type", new NullPointerException("'type' cannot be null for tint"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "minecraft");
|
||||
TintFactory factory = BuiltInRegistries.TINT_FACTORY.getValue(key);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SelfIncreaseIntTemplateArgument implements TemplateArgument {
|
||||
public TemplateArgument create(Map<String, Object> arguments) {
|
||||
int from = ResourceConfigUtils.getAsInt(arguments.get("from"), "from");
|
||||
int to = ResourceConfigUtils.getAsInt(arguments.get("to"), "to");
|
||||
if (from > to) throw new LocalizedResourceConfigException("warning.config.template.from_larger_than_to", String.valueOf(from), String.valueOf(to));
|
||||
if (from > to) throw new LocalizedResourceConfigException("warning.config.template.argument.self_increase_int.invalid_range", String.valueOf(from), String.valueOf(to));
|
||||
return new SelfIncreaseIntTemplateArgument(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class TemplateManagerImpl implements TemplateManager {
|
||||
@Override
|
||||
public void addTemplate(Pack pack, Path path, Key id, Object obj) {
|
||||
if (this.templates.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.template.duplicated", path.toString(), id.toString());
|
||||
throw new LocalizedResourceConfigException("warning.config.template.duplicate", path.toString(), id.toString());
|
||||
}
|
||||
this.templates.put(id, obj);
|
||||
}
|
||||
|
||||
@@ -75,16 +75,16 @@ public abstract class AbstractSoundManager implements SoundManager {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (AbstractSoundManager.this.songs.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.jukebox_song.duplicated", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.jukebox_song.duplicate", path, id);
|
||||
}
|
||||
String sound = (String) section.get("sound");
|
||||
Object sound = section.get("sound");
|
||||
if (sound == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.jukebox_song.lack_sound", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.jukebox_song.missing_sound", path, id);
|
||||
}
|
||||
Component description = AdventureHelper.miniMessage().deserialize(section.getOrDefault("description", "").toString());
|
||||
float length = ResourceConfigUtils.getAsFloat(section.get("length"), "length");
|
||||
int comparatorOutput = ResourceConfigUtils.getAsInt(section.getOrDefault("comparator-output", 15), "comparator-output");
|
||||
JukeboxSong song = new JukeboxSong(Key.of(sound), description, length, comparatorOutput, ResourceConfigUtils.getAsFloat(section.getOrDefault("range", 32f), "range"));
|
||||
JukeboxSong song = new JukeboxSong(Key.of(sound.toString()), description, length, comparatorOutput, ResourceConfigUtils.getAsFloat(section.getOrDefault("range", 32f), "range"));
|
||||
AbstractSoundManager.this.songs.put(id, song);
|
||||
}
|
||||
}
|
||||
@@ -105,13 +105,13 @@ public abstract class AbstractSoundManager implements SoundManager {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (AbstractSoundManager.this.byId.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.sound.duplicated", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.sound.duplicate", path, id);
|
||||
}
|
||||
boolean replace = (boolean) section.getOrDefault("replace", false);
|
||||
String subtitle = (String) section.get("subtitle");
|
||||
List<?> soundList = (List<?>) section.get("sounds");
|
||||
if (soundList == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.sound.lack_sounds", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.sound.missing_sounds", path, id);
|
||||
}
|
||||
List<Sound> sounds = new ArrayList<>();
|
||||
for (Object sound : soundList) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface Sound extends Supplier<JsonElement> {
|
||||
|
||||
public static SoundFile fromMap(Map<String, Object> map) {
|
||||
Object name = map.get("name");
|
||||
if (name == null) throw new LocalizedResourceConfigException("warning.config.sound.lack_name", new NullPointerException("Missing required property 'name'"));
|
||||
if (name == null) throw new LocalizedResourceConfigException("warning.config.sound.missing_name", new NullPointerException("Missing required property 'name'"));
|
||||
Builder builder = file(name.toString());
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
Optional.ofNullable(Builder.MODIFIERS.get(entry.getKey())).ifPresent(modifier -> modifier.apply(builder, entry.getValue()));
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CharacterUtils {
|
||||
chars[i] = (char) codePoint;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_hex", e, hex);
|
||||
throw new LocalizedResourceConfigException("warning.config.image.invalid_hex_value", e, hex);
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MiscUtils {
|
||||
} else if (split.length == 1) {
|
||||
return new Vector3f(Float.parseFloat(split[0]));
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_vector3f", new RuntimeException("Cannot convert " + o + " to Vector3f"), stringFormat, option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.vector3f", new RuntimeException("Cannot convert " + o + " to Vector3f"), stringFormat, option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MiscUtils {
|
||||
} else if (split.length == 1) {
|
||||
return QuaternionUtils.toQuaternionf(0, Math.toRadians(Float.parseFloat(split[0])), 0);
|
||||
} else {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_quaternionf", new RuntimeException("Cannot convert " + o + " to Quaternionf"), stringFormat, option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.quaternionf", new RuntimeException("Cannot convert " + o + " to Quaternionf"), stringFormat, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ public final class ResourceConfigUtils {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_int", e, s, option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.int", e, s, option);
|
||||
}
|
||||
}
|
||||
case Boolean b -> {
|
||||
return b ? 1 : 0;
|
||||
}
|
||||
default -> throw new LocalizedResourceConfigException("warning.config.cast_int", o.toString(), option);
|
||||
default -> throw new LocalizedResourceConfigException("warning.config.type.int", o.toString(), option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ public final class ResourceConfigUtils {
|
||||
try {
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_double", e, s, option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.double", e, s, option);
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_double", o.toString(), option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.double", o.toString(), option);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,14 +69,14 @@ public final class ResourceConfigUtils {
|
||||
try {
|
||||
return Float.parseFloat(s);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_float", e, s, option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.float", e, s, option);
|
||||
}
|
||||
}
|
||||
case Number number -> {
|
||||
return number.floatValue();
|
||||
}
|
||||
default -> {
|
||||
throw new LocalizedResourceConfigException("warning.config.cast_float", o.toString(), option);
|
||||
throw new LocalizedResourceConfigException("warning.config.type.float", o.toString(), option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user