Skip to content

Commit

Permalink
获取规则的名称、描述翻译键
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Sep 17, 2024
1 parent 4f92ceb commit 5b92eb2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/dev/anvilcraft/rg/api/RGRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,24 @@ public void setFieldValue(T value) {
throw new RGRuleException("Illegal value: %s", value);
}
}

/**
* 获取规则的名称翻译键
*
* @return 返回格式化的名称翻译键字符串,包括命名空间和序列化字段
*/
public @NotNull String getNameTranslationKey() {
// 使用formatted方法格式化名称翻译键
return "%s.rolling_gate.rule.%s".formatted(this.namespace, this.serialize);
}

/**
* 获取规则的描述翻译键
*
* @return 返回格式化的描述翻译键字符串,包括命名空间和序列化字段
*/
public @NotNull String getDescriptionTranslationKey() {
// 使用String.format方法构建描述翻译键,包含命名空间和序列化值
return "%s.rolling_gate.rule.%s.desc".formatted(this.namespace, this.serialize);
}
}

0 comments on commit 5b92eb2

Please sign in to comment.