diff --git a/api-bukkit/src/main/java/dev/aurelium/auraskills/api/AuraSkillsBukkit.java b/api-bukkit/src/main/java/dev/aurelium/auraskills/api/AuraSkillsBukkit.java index 982053a0f..bef0bce22 100644 --- a/api-bukkit/src/main/java/dev/aurelium/auraskills/api/AuraSkillsBukkit.java +++ b/api-bukkit/src/main/java/dev/aurelium/auraskills/api/AuraSkillsBukkit.java @@ -1,5 +1,6 @@ package dev.aurelium.auraskills.api; +import dev.aurelium.auraskills.api.item.ItemManager; import dev.aurelium.auraskills.api.region.Regions; public interface AuraSkillsBukkit { @@ -11,6 +12,13 @@ public interface AuraSkillsBukkit { */ Regions getRegions(); + /** + * Gets the item manager used to add modifiers, multipliers, and requirements to items. + * + * @return the item manager + */ + ItemManager getItemManager(); + /** * Gets the instance of the {@link AuraSkillsBukkit} API, * throwing {@link IllegalStateException} if the API is not loaded yet. diff --git a/api/src/main/java/dev/aurelium/auraskills/api/AuraSkillsApi.java b/api/src/main/java/dev/aurelium/auraskills/api/AuraSkillsApi.java index f3d8890fe..710c045aa 100644 --- a/api/src/main/java/dev/aurelium/auraskills/api/AuraSkillsApi.java +++ b/api/src/main/java/dev/aurelium/auraskills/api/AuraSkillsApi.java @@ -75,8 +75,6 @@ public interface AuraSkillsApi { */ Handlers getHandlers(); - T getItemManager(Class itemManagerClass); - /** * Gets the instance of the {@link AuraSkillsApi}, * throwing {@link IllegalStateException} if the API is not loaded yet. diff --git a/api/src/main/java/dev/aurelium/auraskills/api/user/SkillsUser.java b/api/src/main/java/dev/aurelium/auraskills/api/user/SkillsUser.java index 800951741..5f87c2f71 100644 --- a/api/src/main/java/dev/aurelium/auraskills/api/user/SkillsUser.java +++ b/api/src/main/java/dev/aurelium/auraskills/api/user/SkillsUser.java @@ -5,8 +5,11 @@ import dev.aurelium.auraskills.api.skill.Skill; import dev.aurelium.auraskills.api.stat.Stat; import dev.aurelium.auraskills.api.stat.StatModifier; +import dev.aurelium.auraskills.api.trait.Trait; +import org.jetbrains.annotations.Nullable; import java.util.Locale; +import java.util.Map; import java.util.UUID; public interface SkillsUser { @@ -77,6 +80,13 @@ public interface SkillsUser { */ void setSkillLevel(Skill skill, int level); + /** + * Gets the user's average skill level of all enabled skills. + * + * @return the skill average + */ + double getSkillAverage(); + /** * Gets the level of a stat. * @@ -137,6 +147,38 @@ public interface SkillsUser { */ void removeStatModifier(String name); + /** + * Gets a stat modifier from its name. + * + * @param name the name of the modifier + * @return the stat modifier, or null if none exists with the name. + */ + @Nullable + StatModifier getStatModifier(String name); + + /** + * Gets a map of all the user's stat modifiers. + * + * @return the map of all stat modifiers + */ + Map getStatModifiers(); + + /** + * Gets the total level of a trait, including non-plugin base values. + * + * @param trait the trait to get the level of + * @return the total effective level + */ + double getEffectiveTraitLevel(Trait trait); + + /** + * Gets the level of a trait from only the plugin's stats and trait modifiers. + * + * @param trait the trait to get the level of + * @return the bonus trait level + */ + double getBonusTraitLevel(Trait trait); + /** * Gets the level of an ability. * diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/AuraSkills.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/AuraSkills.java index 06e075f4f..e189b6c6b 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/AuraSkills.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/AuraSkills.java @@ -405,6 +405,10 @@ public int getResourceId() { return 81069; } + public AuraSkillsBukkit getApiBukkit() { + return apiBukkit; + } + @Override public AuraSkillsApi getApi() { return api; @@ -550,12 +554,8 @@ public EventHandler getEventHandler() { return eventHandler; } - @Override - public T getItemManager(Class itemManagerClass) { - if (itemManagerClass.equals(ItemManager.class)) { - return itemManagerClass.cast(itemManager); - } - throw new IllegalArgumentException("Invalid itemManagerClass"); + public ItemManager getItemManager() { + return itemManager; } @Override diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/api/ApiAuraSkillsBukkit.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/api/ApiAuraSkillsBukkit.java index c3c144cb2..ef7f7992a 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/api/ApiAuraSkillsBukkit.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/api/ApiAuraSkillsBukkit.java @@ -1,6 +1,7 @@ package dev.aurelium.auraskills.bukkit.api; import dev.aurelium.auraskills.api.AuraSkillsBukkit; +import dev.aurelium.auraskills.api.item.ItemManager; import dev.aurelium.auraskills.api.region.Regions; import dev.aurelium.auraskills.bukkit.AuraSkills; import dev.aurelium.auraskills.bukkit.api.implementation.ApiRegions; @@ -8,13 +9,20 @@ public class ApiAuraSkillsBukkit implements AuraSkillsBukkit { private final ApiRegions blockTracker; + private final ItemManager itemManager; public ApiAuraSkillsBukkit(AuraSkills plugin) { this.blockTracker = new ApiRegions(plugin); + this.itemManager = plugin.getItemManager(); } @Override public Regions getRegions() { return blockTracker; } + + @Override + public ItemManager getItemManager() { + return itemManager; + } } diff --git a/common/src/main/java/dev/aurelium/auraskills/common/AuraSkillsPlugin.java b/common/src/main/java/dev/aurelium/auraskills/common/AuraSkillsPlugin.java index 4e828cf87..8dd88be9c 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/AuraSkillsPlugin.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/AuraSkillsPlugin.java @@ -95,8 +95,6 @@ public interface AuraSkillsPlugin { EventHandler getEventHandler(); - T getItemManager(Class itemManagerClass); - // Message convenience methods /** diff --git a/common/src/main/java/dev/aurelium/auraskills/common/api/ApiAuraSkills.java b/common/src/main/java/dev/aurelium/auraskills/common/api/ApiAuraSkills.java index 521cc6f8a..0ada6da9d 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/api/ApiAuraSkills.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/api/ApiAuraSkills.java @@ -79,8 +79,4 @@ public Handlers getHandlers() { return handlers; } - @Override - public T getItemManager(Class itemManagerClass) { - return null; - } } diff --git a/common/src/main/java/dev/aurelium/auraskills/common/api/implementation/ApiSkillsUser.java b/common/src/main/java/dev/aurelium/auraskills/common/api/implementation/ApiSkillsUser.java index ac22b7068..988c82a02 100644 --- a/common/src/main/java/dev/aurelium/auraskills/common/api/implementation/ApiSkillsUser.java +++ b/common/src/main/java/dev/aurelium/auraskills/common/api/implementation/ApiSkillsUser.java @@ -3,14 +3,17 @@ import dev.aurelium.auraskills.api.ability.Ability; import dev.aurelium.auraskills.api.mana.ManaAbility; +import dev.aurelium.auraskills.api.trait.Trait; import dev.aurelium.auraskills.api.user.SkillsUser; import dev.aurelium.auraskills.api.skill.Skill; import dev.aurelium.auraskills.api.stat.Stat; import dev.aurelium.auraskills.api.stat.StatModifier; import dev.aurelium.auraskills.common.AuraSkillsPlugin; import dev.aurelium.auraskills.common.user.User; +import org.jetbrains.annotations.Nullable; import java.util.Locale; +import java.util.Map; import java.util.UUID; public class ApiSkillsUser implements SkillsUser { @@ -69,6 +72,11 @@ public void setSkillLevel(Skill skill, int level) { user.setSkillLevel(skill, level); } + @Override + public double getSkillAverage() { + return user.getSkillAverage(); + } + @Override public double getStatLevel(Stat stat) { return user.getStatLevel(stat); @@ -109,6 +117,26 @@ public void removeStatModifier(String name) { user.removeStatModifier(name); } + @Override + public @Nullable StatModifier getStatModifier(String name) { + return user.getStatModifier(name); + } + + @Override + public Map getStatModifiers() { + return user.getStatModifiers(); + } + + @Override + public double getEffectiveTraitLevel(Trait trait) { + return user.getEffectiveTraitLevel(trait); + } + + @Override + public double getBonusTraitLevel(Trait trait) { + return user.getBonusTraitLevel(trait); + } + @Override public int getAbilityLevel(Ability ability) { return user.getAbilityLevel(ability);