mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 01:49:30 +00:00
新增模板缺少参数提示
This commit is contained in:
@@ -2150,17 +2150,17 @@ templates#block_states:
|
||||
state: ${base_block}[type=top,waterlogged=false]
|
||||
model:
|
||||
path: ${model_top_path}
|
||||
generation: ${model_top_generation}
|
||||
generation: ${model_top_generation:-null}
|
||||
type=bottom,waterlogged=false:
|
||||
state: ${base_block}[type=bottom,waterlogged=false]
|
||||
model:
|
||||
path: ${model_bottom_path}
|
||||
generation: ${model_bottom_generation}
|
||||
generation: ${model_bottom_generation:-null}
|
||||
type=double,waterlogged=false:
|
||||
state: ${base_block}[type=double,waterlogged=false]
|
||||
model:
|
||||
path: ${model_double_path}
|
||||
generation: ${model_double_generation}
|
||||
generation: ${model_double_generation:-null}
|
||||
type=top,waterlogged=true:
|
||||
state: ${base_block}[type=top,waterlogged=true]
|
||||
model:
|
||||
|
||||
@@ -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.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.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.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>"
|
||||
|
||||
@@ -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.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.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.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>"
|
||||
|
||||
@@ -65,6 +65,7 @@ public interface TemplateManager extends Manageable {
|
||||
private final String placeholder;
|
||||
private final String rawText;
|
||||
private final Object defaultValue;
|
||||
private final boolean hasDefaultValue;
|
||||
|
||||
public Placeholder(String placeholderContent) {
|
||||
this.rawText = "${" + placeholderContent + "}";
|
||||
@@ -72,16 +73,17 @@ public interface TemplateManager extends Manageable {
|
||||
if (separatorIndex == -1) {
|
||||
this.placeholder = placeholderContent;
|
||||
this.defaultValue = null;
|
||||
this.hasDefaultValue = false;
|
||||
} else {
|
||||
this.placeholder = placeholderContent.substring(0, separatorIndex);
|
||||
String defaultValueString = placeholderContent.substring(separatorIndex + 2);
|
||||
try {
|
||||
// TODO 改进报错检测
|
||||
this.defaultValue = new SNBTReader(defaultValueString).deserializeAsJava();
|
||||
} catch (LocalizedResourceConfigException e) {
|
||||
e.appendTailArgument(this.placeholder);
|
||||
throw e;
|
||||
}
|
||||
this.hasDefaultValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +97,10 @@ public interface TemplateManager extends Manageable {
|
||||
if (replacement != null) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user