use of de.Keyle.MyPet.api.skill.skilltree.levelrule.StaticLevelRule in project MyPet by xXKeyleXx.
the class SkillTreeLoaderJSON method loadLevelRule.
private static LevelRule loadLevelRule(String levelRuleString) {
LevelRule levelRule;
if (levelRuleString.contains("%")) {
int modulo = 1;
int min = 0;
int max = 0;
Matcher matcher = LEVEL_RULE_REGEX.matcher(levelRuleString);
while (matcher.find()) {
if (matcher.group(0).startsWith("%")) {
modulo = Math.max(1, Integer.parseInt(matcher.group(1)));
} else if (matcher.group(0).startsWith(">")) {
min = Integer.parseInt(matcher.group(3));
} else if (matcher.group(0).startsWith("<")) {
max = Integer.parseInt(matcher.group(2));
}
}
levelRule = new DynamicLevelRule(modulo, min, max);
} else {
String[] levelStrings = levelRuleString.split(",");
List<Integer> levels = new ArrayList<>();
for (String levelString : levelStrings) {
if (Util.isInt(levelString.trim())) {
levels.add(Integer.parseInt(levelString.trim()));
}
}
levelRule = new StaticLevelRule(levels);
}
return levelRule;
}
Aggregations