mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +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.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||||
import io.lumine.mythic.lib.player.modifier.Closeable;
|
import io.lumine.mythic.lib.player.modifier.Closeable;
|
||||||
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
||||||
@ -110,11 +111,12 @@ public class PlayerAttributes {
|
|||||||
public class AttributeInstance {
|
public class AttributeInstance {
|
||||||
private int spent;
|
private int spent;
|
||||||
|
|
||||||
private final String id;
|
private final String id, enumName;
|
||||||
private final Map<String, AttributeModifier> map = new HashMap<>();
|
private final Map<String, AttributeModifier> map = new HashMap<>();
|
||||||
|
|
||||||
public AttributeInstance(String attribute) {
|
public AttributeInstance(String id) {
|
||||||
id = attribute;
|
this.id = id;
|
||||||
|
this.enumName = UtilityMethods.enumName(this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBase() {
|
public int getBase() {
|
||||||
@ -146,10 +148,14 @@ public class PlayerAttributes {
|
|||||||
if (attr.getType() == ModifierType.FLAT)
|
if (attr.getType() == ModifierType.FLAT)
|
||||||
d += attr.getValue();
|
d += attr.getValue();
|
||||||
|
|
||||||
|
d += data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName);
|
||||||
|
|
||||||
for (AttributeModifier attr : map.values())
|
for (AttributeModifier attr : map.values())
|
||||||
if (attr.getType() == ModifierType.RELATIVE)
|
if (attr.getType() == ModifierType.RELATIVE)
|
||||||
d *= attr.getValue();
|
d *= attr.getValue();
|
||||||
|
|
||||||
|
d *= 1 + data.getMMOPlayerData().getStatMap().getStat("ADDITIONAL_" + enumName + "_PERCENT") / 100;
|
||||||
|
|
||||||
// cast to int at the last moment
|
// cast to int at the last moment
|
||||||
return (int) d;
|
return (int) d;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,13 @@ import java.util.logging.Level;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class AttributeManager implements MMOCoreManager {
|
public class AttributeManager implements MMOCoreManager {
|
||||||
private final Map<String, PlayerAttribute> map = new HashMap<>();
|
private final Map<String, PlayerAttribute> map = new HashMap<>();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public PlayerAttribute get(String id) {
|
public PlayerAttribute get(String id) {
|
||||||
return map.get(id);
|
return map.get(id);
|
||||||
}
|
}
|
||||||
@ -20,6 +23,7 @@ public class AttributeManager implements MMOCoreManager {
|
|||||||
return map.containsKey(id);
|
return map.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Collection<PlayerAttribute> getAll() {
|
public Collection<PlayerAttribute> getAll() {
|
||||||
return map.values();
|
return map.values();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user