Fixed stat trigger issue with multiple players

This commit is contained in:
Jules 2023-02-16 19:52:03 +01:00
parent 25391039bc
commit f23e520635

View File

@ -12,8 +12,7 @@ public class StatTrigger extends Trigger {
private final String stat; private final String stat;
private final double amount; private final double amount;
private final ModifierType type; private final ModifierType type;
private double totalAmount; private final String modifierKey = "mmocore_trigger." + UUID.randomUUID();
private final UUID uuid =UUID.randomUUID();
public StatTrigger(MMOLineConfig config) { public StatTrigger(MMOLineConfig config) {
super(config); super(config);
@ -26,13 +25,11 @@ public class StatTrigger extends Trigger {
stat = config.getString("stat"); stat = config.getString("stat");
amount = config.getDouble("amount"); amount = config.getDouble("amount");
this.type = ModifierType.valueOf(type); this.type = ModifierType.valueOf(type);
this.totalAmount = 0;
} }
@Override @Override
public void apply(PlayerData player) { public void apply(PlayerData player) {
totalAmount+=amount; new StatModifier(modifierKey, stat, amount, type).register(player.getMMOPlayerData());
new StatModifier("trigger."+uuid.toString(),stat,totalAmount,type).register(player.getMMOPlayerData());
} }
/** /**
@ -41,7 +38,6 @@ public class StatTrigger extends Trigger {
* Not a problem to store twice the stat modifiers are there only remain in the RAM. * Not a problem to store twice the stat modifiers are there only remain in the RAM.
*/ */
public void remove(PlayerData playerData) { public void remove(PlayerData playerData) {
totalAmount-=amount; playerData.getMMOPlayerData().getStatMap().getInstance(stat).remove(modifierKey);
new StatModifier("trigger."+uuid.toString(), stat, totalAmount, type).register(playerData.getMMOPlayerData());
} }
} }