1)ftl
package com.elex.service.conf.helper.buffattribute.enums;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;
/**
* 永久属性类型枚举(41xxx)
* 这个类是自动生成的,不要在里面写逻辑,写了也会被覆盖掉!!!
*/
@Slf4j
public enum EBuffAttributeType {
NULL(0, false), // 无效值
<#list results as r>
${r.en}(${r.attributeType?c}, <#if r.fightType==1>true<#else>false#if>, <#if r.needCache==1>true<#else>false#if>), // ${r.comment}
#list>
;
/*** 属性类型*/
@Getter
private int attributeType;
/*** 是否是战斗属性*/
@Getter
private boolean fightType = false;
/*** 标记为true的可以通过UserEffectAndAttributeManager的getAttributeCacheValue方法从缓存中获取属性, 只有参数中类型全是1的才能标记为true,标记错误起服时就检查会抛出异常*/
@Getter
private boolean needCache = false;
EBuffAttributeType(int attributeType, boolean fightType) {
this.attributeType = attributeType;
this.fightType = fightType;
}
EBuffAttributeType(int attributeType, boolean fightType, boolean needCache) {
this(attributeType, fightType);
this.needCache = needCache;
}
// 检索
private static final Map typeMap;
static {
Map map = new HashMap<>();
for (EBuffAttributeType type : values()) {
if (map.putIfAbsent(type.attributeType, type) != null) {
log.error("重复的attributeType={}", type.attributeType);
}
}
typeMap = map;
}
public static EBuffAttributeType find(int attributeType) {
return typeMap.get(attributeType);
}
}
注意:
?c是生成的数字不要带','
2)代码
public boolean genAttributeCode() throws Exception {
Collection list = ConfigServiceImpl.getInstant().getConfig(Attribute_formulaConfig.class).getAll();
List
笔记:
System.getProperty获取当前工程路径。
Path.of用于处理路径的连接。