Moved lists from SkillType into only getters

This commit is contained in:
ile123ile 2014-08-24 10:49:00 -07:00
parent 5e83632004
commit 0700e4354c
2 changed files with 46 additions and 18 deletions

View File

@ -17,7 +17,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getSkills() { public static List<String> getSkills() {
return SkillType.skillNames; return SkillType.getSkillNames();
} }
/** /**
@ -29,7 +29,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getNonChildSkills() { public static List<String> getNonChildSkills() {
return getStringListFromSkillList(SkillType.nonChildSkills); return getStringListFromSkillList(SkillType.getNonChildSkills());
} }
/** /**
@ -41,7 +41,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getChildSkills() { public static List<String> getChildSkills() {
return getStringListFromSkillList(SkillType.childSkills); return getStringListFromSkillList(SkillType.getChildSkills());
} }
/** /**
@ -53,7 +53,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getCombatSkills() { public static List<String> getCombatSkills() {
return getStringListFromSkillList(SkillType.combatSkills); return getStringListFromSkillList(SkillType.getCombatSkills());
} }
/** /**
@ -65,7 +65,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getGatheringSkills() { public static List<String> getGatheringSkills() {
return getStringListFromSkillList(SkillType.gatheringSkills); return getStringListFromSkillList(SkillType.getGatheringSkills());
} }
/** /**
@ -77,7 +77,7 @@ public final class SkillAPI {
* @return a list of strings with valid skill names * @return a list of strings with valid skill names
*/ */
public static List<String> getMiscSkills() { public static List<String> getMiscSkills() {
return getStringListFromSkillList(SkillType.miscSkills); return getStringListFromSkillList(SkillType.getMiscSkills());
} }
private static List<String> getStringListFromSkillList(List<SkillType> skillsTypes) { private static List<String> getStringListFromSkillList(List<SkillType> skillsTypes) {

View File

@ -101,25 +101,25 @@ public class SkillType {
public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, AbilityType ability, ToolType tool, List<SecondaryAbility> secondaryAbilities) { public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, AbilityType ability, ToolType tool, List<SecondaryAbility> secondaryAbilities) {
SkillType skill = new SkillType(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, ability, tool, secondaryAbilities); SkillType skill = new SkillType(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, ability, tool, secondaryAbilities);
skillList.add(skill); getSkillList().add(skill);
if(skill.isChild) { if(skill.isChild) {
childSkills.add(skill); getChildSkills().add(skill);
} }
else { else {
nonChildSkills.add(skill); getNonChildSkills().add(skill);
} }
switch(skill.skillUseType) { switch(skill.skillUseType) {
case COMBAT: case COMBAT:
combatSkills.add(skill); getCombatSkills().add(skill);
break; break;
case GATHERING: case GATHERING:
gatheringSkills.add(skill); getGatheringSkills().add(skill);
break; break;
default: default:
miscSkills.add(skill); getMiscSkills().add(skill);
break; break;
} }
skillNames.add(skill.name); getSkillNames().add(skill.name);
return skill; return skill;
} }
@ -202,7 +202,7 @@ public class SkillType {
public static SkillType getSkillFromLocalized(String skillName) { public static SkillType getSkillFromLocalized(String skillName) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) { if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
for (SkillType type : skillList) { for (SkillType type : getSkillList()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name) + ".SkillName"))) { if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name) + ".SkillName"))) {
return type; return type;
} }
@ -213,7 +213,7 @@ public class SkillType {
} }
public static SkillType getSkill(String skillName) { public static SkillType getSkill(String skillName) {
for (SkillType type : skillList) { for (SkillType type : getSkillList()) {
if (type.name.equalsIgnoreCase(skillName)) { if (type.name.equalsIgnoreCase(skillName)) {
return type; return type;
} }
@ -231,7 +231,7 @@ public class SkillType {
} }
public static SkillType bySecondaryAbility(SecondaryAbility skillAbility) { public static SkillType bySecondaryAbility(SecondaryAbility skillAbility) {
for (SkillType type : skillList) { for (SkillType type : getSkillList()) {
if (type.getSkillAbilities().contains(skillAbility)) { if (type.getSkillAbilities().contains(skillAbility)) {
return type; return type;
} }
@ -240,7 +240,7 @@ public class SkillType {
} }
public static SkillType byAbility(AbilityType ability) { public static SkillType byAbility(AbilityType ability) {
for (SkillType type : skillList) { for (SkillType type : getSkillList()) {
if (type.getAbility() == ability) { if (type.getAbility() == ability) {
return type; return type;
} }
@ -278,6 +278,34 @@ public class SkillType {
public static void setUpSkillTypes() public static void setUpSkillTypes()
{ {
Collections.sort(skillNames); Collections.sort(getSkillNames());
} }
public static List<String> getSkillNames() {
return skillNames;
}
public static List<SkillType> getSkillList() {
return skillList;
}
public static List<SkillType> getChildSkills() {
return childSkills;
}
public static List<SkillType> getNonChildSkills() {
return nonChildSkills;
}
public static List<SkillType> getCombatSkills() {
return combatSkills;
}
public static List<SkillType> getGatheringSkills() {
return gatheringSkills;
}
public static List<SkillType> getMiscSkills() {
return miscSkills;
}
} }