mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +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.stats.stat.modifier.StatModifier;
|
||||
import net.Indyuce.mmocore.api.player.stats.stat.modifier.TemporaryStatModifier;
|
||||
|
||||
public class PlayerStats {
|
||||
private final PlayerData data;
|
||||
@ -101,6 +102,10 @@ public class PlayerStats {
|
||||
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) {
|
||||
map.put(key, modifier);
|
||||
|
||||
|
@ -8,7 +8,6 @@ public class StatModifier {
|
||||
private final double d;
|
||||
private final boolean relative;
|
||||
|
||||
|
||||
public StatModifier(double d) {
|
||||
this(d, false);
|
||||
}
|
||||
@ -33,6 +32,10 @@ public class StatModifier {
|
||||
public boolean isRelative() {
|
||||
return relative;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return d;
|
||||
}
|
||||
|
||||
public double apply(double in) {
|
||||
return relative ? in * (1 + d / 100) : in + d;
|
||||
|
@ -7,7 +7,7 @@ import net.Indyuce.mmocore.api.player.stats.PlayerStats.StatInstance;
|
||||
|
||||
public class TemporaryStatModifier extends StatModifier {
|
||||
private final BukkitRunnable runnable;
|
||||
|
||||
|
||||
public TemporaryStatModifier(double d, long duration, boolean relative, String key, StatInstance ins) {
|
||||
super(d, relative);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user