Skip to content

Commit

Permalink
Add support for AureliumSkills.
Browse files Browse the repository at this point in the history
  • Loading branch information
Staartvin committed Jan 19, 2021
1 parent c01b114 commit a0bbc5b
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 1 deletion.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
<url>https://maven.enginehub.org/repo/</url>
</repository>

<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>

</repositories>

<dependencies>
Expand Down Expand Up @@ -269,6 +274,13 @@
<version>1.4</version>
</dependency>

<dependency>
<groupId>com.github.Archy-x</groupId>
<artifactId>AureliumSkills</artifactId>
<version>Alpha1.6.0</version>
<scope>provided</scope>
</dependency>


<!-- Test dependencies -->

Expand Down
3 changes: 2 additions & 1 deletion src/me/staartvin/utils/pluginlibrary/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
107 changes: 107 additions & 0 deletions src/me/staartvin/utils/pluginlibrary/hooks/AureliumSkillsHook.java
Original file line number Diff line number Diff line change
@@ -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,
* <a href="https://www.spigotmc.org/resources/aurelium-skills-advanced-skills-stats-abilities-and-more.81069/">link</a>
* .
* <p>
*
* @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);
}
}

0 comments on commit a0bbc5b

Please sign in to comment.