mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-23 04:47:37 +01:00
Additional 'attribute' stats
This commit is contained in:
parent
e326bad6b3
commit
95c355eeed
@ -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<String, AttributeModifier> 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;
|
||||
}
|
||||
|
@ -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<String, PlayerAttribute> 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<PlayerAttribute> getAll() {
|
||||
return map.values();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user