From 09b0bf62e2392b148426f05f520e335a1f43d07a Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Wed, 16 Jul 2014 20:07:23 +0200 Subject: [PATCH] Added SkillAPI used to get a list of skill names This prevents having to rely on the SkillType enum --- Changelog.txt | 1 + .../java/com/gmail/nossr50/api/SkillAPI.java | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/api/SkillAPI.java diff --git a/Changelog.txt b/Changelog.txt index 1625179dc..9bbcf4109 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.5.01-dev + Added API to check if an entity is bleeding + Added options to tools.yml and armor.yml config files to set a pretty repair material name + Added full support for repairables in tools.yml and armor.yml config files + + Added new API class SkillAPI used to get a list of valid skill names = Fixed bug where pistons would mess with the block tracking = Fixed bug where the Updater was running on the main thread. = Fixed bug when players would use /ptp without being in a party diff --git a/src/main/java/com/gmail/nossr50/api/SkillAPI.java b/src/main/java/com/gmail/nossr50/api/SkillAPI.java new file mode 100644 index 000000000..6565a7cb1 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/SkillAPI.java @@ -0,0 +1,93 @@ +package com.gmail.nossr50.api; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.gmail.nossr50.datatypes.skills.SkillType; + +public final class SkillAPI { + private SkillAPI() {} + + /** + * Returns a list of strings with mcMMO's skills + * This includes parent and child skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getSkills() { + return getListFromEnum(Arrays.asList(SkillType.values())); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes parent skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getNonChildSkills() { + return getListFromEnum(SkillType.NON_CHILD_SKILLS); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes child skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getChildSkills() { + return getListFromEnum(SkillType.CHILD_SKILLS); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes combat skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getCombatSkills() { + return getListFromEnum(SkillType.COMBAT_SKILLS); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes gathering skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getGatheringSkills() { + return getListFromEnum(SkillType.GATHERING_SKILLS); + } + + /** + * Returns a list of strings with mcMMO's skills + * This only includes misc skills + *
+ * This function is designed for API usage. + * + * @return a list of strings with valid skill names + */ + public static List getMiscSkills() { + return getListFromEnum(SkillType.MISC_SKILLS); + } + + private static List getListFromEnum(List skillsTypes) { + List skills = new ArrayList(); + + for (SkillType skillType : skillsTypes) { + skills.add(skillType.name()); + } + + return skills; + } +}