9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

新增模板缺少参数提示

This commit is contained in:
XiaoMoMi
2025-07-04 21:52:51 +08:00
parent 9209fdb33f
commit f7429eaed7
4 changed files with 12 additions and 5 deletions

View File

@@ -2150,17 +2150,17 @@ templates#block_states:
state: ${base_block}[type=top,waterlogged=false] state: ${base_block}[type=top,waterlogged=false]
model: model:
path: ${model_top_path} path: ${model_top_path}
generation: ${model_top_generation} generation: ${model_top_generation:-null}
type=bottom,waterlogged=false: type=bottom,waterlogged=false:
state: ${base_block}[type=bottom,waterlogged=false] state: ${base_block}[type=bottom,waterlogged=false]
model: model:
path: ${model_bottom_path} path: ${model_bottom_path}
generation: ${model_bottom_generation} generation: ${model_bottom_generation:-null}
type=double,waterlogged=false: type=double,waterlogged=false:
state: ${base_block}[type=double,waterlogged=false] state: ${base_block}[type=double,waterlogged=false]
model: model:
path: ${model_double_path} path: ${model_double_path}
generation: ${model_double_generation} generation: ${model_double_generation:-null}
type=top,waterlogged=true: type=top,waterlogged=true:
state: ${base_block}[type=top,waterlogged=true] state: ${base_block}[type=top,waterlogged=true]
model: model:

View File

@@ -139,6 +139,7 @@ warning.config.template.duplicate: "<yellow>Issue found in file <arg:0> - Duplic
warning.config.template.invalid: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid template '<arg:2>'.</yellow>" warning.config.template.invalid: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid template '<arg:2>'.</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.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.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.template.argument.missing_value: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the template argument for '<arg:2>'. Please use the arguments option to configure or set a default value for this parameter.</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.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.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.vanilla_loot.block.invalid_target: "<yellow>Issue found in file <arg:0> - Invalid block target '<arg:2>' in vanilla loot '<arg:1>'.</yellow>"

View File

@@ -139,6 +139,7 @@ warning.config.template.duplicate: "<yellow>在文件 <arg:0> 发现问题 - 重
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>在文件 <arg:0> 发现问题 - 模板 '<arg:1>' 在 'self_increase_int' 参数中使用了一个起始值 '<arg:2>' 大于终止值 '<arg:3>'</yellow>" warning.config.template.argument.self_increase_int.invalid_range: "<yellow>在文件 <arg:0> 发现问题 - 模板 '<arg:1>' 在 'self_increase_int' 参数中使用了一个起始值 '<arg:2>' 大于终止值 '<arg:3>'</yellow>"
warning.config.template.invalid: "<yellow>在文件 <arg:0> 发现问题 - 配置 '<arg:1>' 使用了无效的模板 '<arg:2>'.</yellow>" warning.config.template.invalid: "<yellow>在文件 <arg:0> 发现问题 - 配置 '<arg:1>' 使用了无效的模板 '<arg:2>'.</yellow>"
warning.config.template.argument.list.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 模板 '<arg:1>' 的 'list' 参数需要列表类型 但输入参数类型为 '<arg:2>'</yellow>" warning.config.template.argument.list.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 模板 '<arg:1>' 的 'list' 参数需要列表类型 但输入参数类型为 '<arg:2>'</yellow>"
warning.config.template.argument.missing_value: "<yellow>在文件 <arg:0> 发现问题 - 配置 '<arg:1>' 缺少了 '<arg:2>' 必要的模板参数值. 请使用 arguments 选项进行配置或为此参数设定默认值.</yellow>"
warning.config.vanilla_loot.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 缺少必需的 'type' 参数</yellow>" warning.config.vanilla_loot.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 缺少必需的 'type' 参数</yellow>"
warning.config.vanilla_loot.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 使用了无效类型 '<arg:2>' 允许的类型: [<arg:3>]</yellow>" warning.config.vanilla_loot.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 使用了无效类型 '<arg:2>' 允许的类型: [<arg:3>]</yellow>"
warning.config.vanilla_loot.block.invalid_target: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 中存在无效的方块目标 '<arg:2>'</yellow>" warning.config.vanilla_loot.block.invalid_target: "<yellow>在文件 <arg:0> 发现问题 - 原版战利品 '<arg:1>' 中存在无效的方块目标 '<arg:2>'</yellow>"

View File

@@ -65,6 +65,7 @@ public interface TemplateManager extends Manageable {
private final String placeholder; private final String placeholder;
private final String rawText; private final String rawText;
private final Object defaultValue; private final Object defaultValue;
private final boolean hasDefaultValue;
public Placeholder(String placeholderContent) { public Placeholder(String placeholderContent) {
this.rawText = "${" + placeholderContent + "}"; this.rawText = "${" + placeholderContent + "}";
@@ -72,16 +73,17 @@ public interface TemplateManager extends Manageable {
if (separatorIndex == -1) { if (separatorIndex == -1) {
this.placeholder = placeholderContent; this.placeholder = placeholderContent;
this.defaultValue = null; this.defaultValue = null;
this.hasDefaultValue = false;
} else { } else {
this.placeholder = placeholderContent.substring(0, separatorIndex); this.placeholder = placeholderContent.substring(0, separatorIndex);
String defaultValueString = placeholderContent.substring(separatorIndex + 2); String defaultValueString = placeholderContent.substring(separatorIndex + 2);
try { try {
// TODO 改进报错检测
this.defaultValue = new SNBTReader(defaultValueString).deserializeAsJava(); this.defaultValue = new SNBTReader(defaultValueString).deserializeAsJava();
} catch (LocalizedResourceConfigException e) { } catch (LocalizedResourceConfigException e) {
e.appendTailArgument(this.placeholder); e.appendTailArgument(this.placeholder);
throw e; throw e;
} }
this.hasDefaultValue = true;
} }
} }
@@ -95,7 +97,10 @@ public interface TemplateManager extends Manageable {
if (replacement != null) { if (replacement != null) {
return replacement.get(arguments); return replacement.get(arguments);
} }
return this.defaultValue; if (this.hasDefaultValue) {
return this.defaultValue;
}
throw new LocalizedResourceConfigException("warning.config.template.argument.missing_value", this.rawText);
} }
@Override @Override