mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
!Added method to StatInstance to easily register temp stats
This commit is contained in:
parent
598aaa3ab3
commit
0ca82a0a2d
@ -6,6 +6,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.stats.stat.modifier.StatModifier;
|
import net.Indyuce.mmocore.api.player.stats.stat.modifier.StatModifier;
|
||||||
|
import net.Indyuce.mmocore.api.player.stats.stat.modifier.TemporaryStatModifier;
|
||||||
|
|
||||||
public class PlayerStats {
|
public class PlayerStats {
|
||||||
private final PlayerData data;
|
private final PlayerData data;
|
||||||
@ -101,6 +102,10 @@ public class PlayerStats {
|
|||||||
addModifier(key, new StatModifier(value));
|
addModifier(key, new StatModifier(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void applyTemporaryModifier(String key, StatModifier modifier, long duration) {
|
||||||
|
addModifier(key, new TemporaryStatModifier(modifier.getValue(), duration, modifier.isRelative(), key, this));
|
||||||
|
}
|
||||||
|
|
||||||
public void addModifier(String key, StatModifier modifier) {
|
public void addModifier(String key, StatModifier modifier) {
|
||||||
map.put(key, modifier);
|
map.put(key, modifier);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ public class StatModifier {
|
|||||||
private final double d;
|
private final double d;
|
||||||
private final boolean relative;
|
private final boolean relative;
|
||||||
|
|
||||||
|
|
||||||
public StatModifier(double d) {
|
public StatModifier(double d) {
|
||||||
this(d, false);
|
this(d, false);
|
||||||
}
|
}
|
||||||
@ -34,6 +33,10 @@ public class StatModifier {
|
|||||||
return relative;
|
return relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getValue() {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
public double apply(double in) {
|
public double apply(double in) {
|
||||||
return relative ? in * (1 + d / 100) : in + d;
|
return relative ? in * (1 + d / 100) : in + d;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user