From a0bbc5b2da5e8f79eec78482a4207f53690cfcd1 Mon Sep 17 00:00:00 2001 From: Vincent Bolta Date: Tue, 19 Jan 2021 16:36:37 +0100 Subject: [PATCH] Add support for AureliumSkills. --- pom.xml | 12 ++ .../utils/pluginlibrary/Library.java | 3 +- .../hooks/AureliumSkillsHook.java | 107 ++++++++++++++++++ 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 src/me/staartvin/utils/pluginlibrary/hooks/AureliumSkillsHook.java diff --git a/pom.xml b/pom.xml index f35a207..9c0269b 100644 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,11 @@ https://maven.enginehub.org/repo/ + + jitpack.io + https://jitpack.io + + @@ -269,6 +274,13 @@ 1.4 + + com.github.Archy-x + AureliumSkills + Alpha1.6.0 + provided + + diff --git a/src/me/staartvin/utils/pluginlibrary/Library.java b/src/me/staartvin/utils/pluginlibrary/Library.java index 00ed37e..be7b53c 100644 --- a/src/me/staartvin/utils/pluginlibrary/Library.java +++ b/src/me/staartvin/utils/pluginlibrary/Library.java @@ -44,7 +44,8 @@ public enum Library { CMI("CMI", CMIHook.class, "Zrips"), UHCSTATS("UhcStats", UHCStatsHook.class, "Mezy"), TOWNY_ADVANCED("Towny", TownyAdvancedHook.class, "Shade"), - MCRPG("McRPG", McRPGHook.class, "Eunoians"); + MCRPG("McRPG", McRPGHook.class, "Eunoians"), + AURELIUM_SKILLS("AureliumSkills", AureliumSkillsHook.class, "Archyx"); private final String internalPluginName; private final String authorName; diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/AureliumSkillsHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/AureliumSkillsHook.java new file mode 100644 index 0000000..b500a7d --- /dev/null +++ b/src/me/staartvin/utils/pluginlibrary/hooks/AureliumSkillsHook.java @@ -0,0 +1,107 @@ +package me.staartvin.utils.pluginlibrary.hooks; + +import com.archyx.aureliumskills.api.AureliumAPI; +import com.archyx.aureliumskills.skills.Skill; +import com.archyx.aureliumskills.stats.Stat; +import me.staartvin.utils.pluginlibrary.Library; + +import java.util.UUID; + +/** + * AureliumSkills library, + * link + * . + *

+ * + * @author Staartvin + */ +public class AureliumSkillsHook extends LibraryHook { + + @Override + public boolean isHooked() { + return isPluginAvailable(Library.AURELIUM_SKILLS); + } + + /* + * (non-Javadoc) + * + * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook() + */ + @Override + public boolean hook() { + // All api calls are done static, so there is no need to get the plugin + // class. + // We only check if the plugin is available. + + return isPluginAvailable(Library.AURELIUM_SKILLS); + } + + /** + * Get the level of a statistic of a player + * + * @param uuid UUID of the player + * @param statType Type of Stat + * @return zero if the stat could not be found. Level of stat otherwise. + */ + public double getStatLevel(UUID uuid, String statType) { + + Stat stat = null; + + try { + stat = Stat.valueOf(statType); + } catch (Exception e) { + return 0; + } + + return AureliumAPI.getStatLevel(uuid, stat); + } + + + /** + * Get the level of a skill for the given player + * + * @param uuid UUID of the player + * @param skillName Name of the skill (use {@link Skill} as reference) + * @return level of a skill or zero if the skill or player cannot be found. + */ + public int getSkillLevel(UUID uuid, String skillName) { + Skill skill = null; + + try { + skill = Skill.valueOf(skillName); + } catch (Exception e) { + return 0; + } + + return AureliumAPI.getSkillLevel(uuid, skill); + } + + /** + * Get the XP of a specific skill for the given player. + * + * @param uuid UUID of the player + * @param skillName Name of the skill + * @return experience points of the skill or zero if the skill could not be found. + */ + public double getXP(UUID uuid, String skillName) { + Skill skill = null; + + try { + skill = Skill.valueOf(skillName); + } catch (Exception e) { + return 0; + } + + return AureliumAPI.getXp(uuid, skill); + } + + /** + * Get the amount of mana a given player has + * + * @param uuid UUID of the player + * @return current mana of the player + */ + public double getMana(UUID uuid) { + return AureliumAPI.getMana(uuid); + } +}