diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/MMOCoreAttributeStatHandler.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/MMOCoreAttributeStatHandler.java index 9822148b..8cebc77b 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/MMOCoreAttributeStatHandler.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/MMOCoreAttributeStatHandler.java @@ -1,9 +1,10 @@ package net.Indyuce.mmocore.api.player.attribute; -import io.lumine.mythic.lib.api.stat.StatMap; +import io.lumine.mythic.lib.api.stat.StatInstance; import io.lumine.mythic.lib.api.stat.handler.StatHandler; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; +import org.bukkit.configuration.ConfigurationSection; /** * This fixes an issue where registering new stat modifiers in ML @@ -13,17 +14,13 @@ import net.Indyuce.mmocore.api.player.PlayerData; * This stat handler MAY call subsequent stat handlers. There might * be infinite recursion problems if another attr. grants extra attribute pts. */ -public class MMOCoreAttributeStatHandler implements StatHandler { +public class MMOCoreAttributeStatHandler extends StatHandler { private final PlayerAttribute attr; - private final String statName; - public MMOCoreAttributeStatHandler(PlayerAttribute attr) { + public MMOCoreAttributeStatHandler(ConfigurationSection config, PlayerAttribute attr) { + super(config, "ADDITIONAL_" + attr.getId().toUpperCase().replace("-", "_")); + this.attr = attr; - this.statName = "ADDITIONAL_" + attr.getId().toUpperCase().replace("-", "_"); - } - - public String getStat() { - return statName; } /** @@ -31,22 +28,12 @@ public class MMOCoreAttributeStatHandler implements StatHandler { * is not loaded yet, hence the try/catch clause */ @Override - public void runUpdate(StatMap statMap) { + public void runUpdate(StatInstance instance) { try { - final PlayerData playerData = MMOCore.plugin.dataProvider.getDataManager().get(statMap.getPlayerData().getUniqueId()); + final PlayerData playerData = MMOCore.plugin.dataProvider.getDataManager().get(instance.getMap().getPlayerData().getUniqueId()); playerData.getAttributes().getInstance(attr).updateStats(); } catch (NullPointerException exception) { // Player data is not loaded yet so there's nothing to update. } } - - @Override - public double getBaseValue(StatMap statMap) { - return 0; - } - - @Override - public double getTotalValue(StatMap statMap) { - return statMap.getStat(statName); - } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/AttributeManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/AttributeManager.java index 42bb5501..604a6231 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/AttributeManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/AttributeManager.java @@ -5,6 +5,7 @@ import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.ConfigFile; import net.Indyuce.mmocore.api.player.attribute.MMOCoreAttributeStatHandler; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; +import org.bukkit.configuration.ConfigurationSection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -46,8 +47,9 @@ public class AttributeManager implements MMOCoreManager { MMOCore.log(Level.WARNING, "Could not load attribute '" + key + "': " + exception.getMessage()); } + final ConfigurationSection statsConfig = new ConfigFile(MythicLib.plugin, "", "stats").getConfig(); for (PlayerAttribute attr : getAll()) { - final MMOCoreAttributeStatHandler handler = new MMOCoreAttributeStatHandler(attr); + final MMOCoreAttributeStatHandler handler = new MMOCoreAttributeStatHandler(statsConfig, attr); MythicLib.plugin.getStats().registerStat(handler.getStat(), handler); MythicLib.plugin.getStats().registerStat(handler.getStat() + "_PERCENT", handler); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Ambers.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Ambers.java index 848f1e2e..de1551a4 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Ambers.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Ambers.java @@ -53,7 +53,7 @@ public class Ambers extends SkillHandler implements Listener if (passive == null) return; - passive.getTriggeredSkill().cast(new TriggerMetadata(event.getAttacker(), event.getAttack(), event.getEntity())); + passive.getTriggeredSkill().cast(new TriggerMetadata(event)); } public static class Amber extends BukkitRunnable { diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Sneaky_Picky.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Sneaky_Picky.java index 96a11b7d..b1347bf9 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Sneaky_Picky.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/skill/list/Sneaky_Picky.java @@ -45,6 +45,6 @@ public class Sneaky_Picky extends SkillHandler implements Lis if (skill == null) return; - skill.getTriggeredSkill().cast(new TriggerMetadata(event.getAttacker(), event.getAttack(), event.getEntity())); + skill.getTriggeredSkill().cast(new TriggerMetadata(event)); } }