diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java index 255d65ee..88674958 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/attribute/PlayerAttributes.java @@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.player.attribute; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.player.modifier.Closeable; import io.lumine.mythic.lib.player.modifier.ModifierSource; @@ -110,11 +111,12 @@ public class PlayerAttributes { public class AttributeInstance { private int spent; - private final String id; + private final String id, enumName; private final Map map = new HashMap<>(); - public AttributeInstance(String attribute) { - id = attribute; + public AttributeInstance(String id) { + this.id = id; + this.enumName = UtilityMethods.enumName(this.id); } public int getBase() { @@ -146,10 +148,14 @@ public class PlayerAttributes { if (attr.getType() == ModifierType.FLAT) d += attr.getValue(); + d += data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName); + for (AttributeModifier attr : map.values()) if (attr.getType() == ModifierType.RELATIVE) d *= attr.getValue(); + d *= 1 + data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName + "_PERCENT") / 100; + // cast to int at the last moment return (int) d; } 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 fc1a50b9..0aef0d2f 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 @@ -8,10 +8,13 @@ import java.util.logging.Level; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute; import net.Indyuce.mmocore.api.ConfigFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class AttributeManager implements MMOCoreManager { private final Map map = new HashMap<>(); + @Nullable public PlayerAttribute get(String id) { return map.get(id); } @@ -20,6 +23,7 @@ public class AttributeManager implements MMOCoreManager { return map.containsKey(id); } + @NotNull public Collection getAll() { return map.values(); }