mirror of
https://github.com/Auxilor/EcoArmor.git
synced 2025-12-28 03:19:25 +00:00
Changed AttributeModifier effect code
This commit is contained in:
@@ -14,8 +14,8 @@ public class AttackSpeedMultiplier extends Effect<Double> {
|
||||
|
||||
@Override
|
||||
protected void onEnable(@NotNull final Player player) {
|
||||
AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
assert maxHealth != null;
|
||||
AttributeInstance attackSpeed = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
assert attackSpeed != null;
|
||||
|
||||
Double multiplier = this.getStrengthForPlayer(player);
|
||||
|
||||
@@ -24,16 +24,16 @@ public class AttackSpeedMultiplier extends Effect<Double> {
|
||||
}
|
||||
|
||||
AttributeModifier modifier = new AttributeModifier(this.getUuid(), "attack-speed-multiplier", 1 - multiplier, AttributeModifier.Operation.MULTIPLY_SCALAR_1);
|
||||
if (!maxHealth.getModifiers().contains(modifier)) {
|
||||
maxHealth.addModifier(modifier);
|
||||
if (attackSpeed.getModifiers().stream().noneMatch(attributeModifier -> attributeModifier.getUniqueId().equals(modifier.getUniqueId()))) {
|
||||
attackSpeed.addModifier(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable(@NotNull final Player player) {
|
||||
AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
assert maxHealth != null;
|
||||
AttributeInstance attackSpeed = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||
assert attackSpeed != null;
|
||||
|
||||
maxHealth.removeModifier(new AttributeModifier(this.getUuid(), "attack-speed-multiplier", 0, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
|
||||
attackSpeed.removeModifier(new AttributeModifier(this.getUuid(), "attack-speed-multiplier", 0, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ public class BonusHearts extends Effect<Integer> {
|
||||
return;
|
||||
}
|
||||
|
||||
maxHealth.removeModifier(new AttributeModifier(this.getUuid(), "bonus-hearts", 0, AttributeModifier.Operation.ADD_NUMBER));
|
||||
AttributeModifier modifier = new AttributeModifier(this.getUuid(), "bonus-hearts", bonus, AttributeModifier.Operation.ADD_NUMBER);
|
||||
if (maxHealth.getModifiers().stream().noneMatch(attributeModifier -> attributeModifier.getUniqueId().equals(modifier.getUniqueId()))) {
|
||||
maxHealth.addModifier(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,9 +34,6 @@ public class BonusHearts extends Effect<Integer> {
|
||||
AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||
assert maxHealth != null;
|
||||
|
||||
AttributeModifier modifier = new AttributeModifier(this.getUuid(), "bonus-hearts", 0, AttributeModifier.Operation.ADD_NUMBER);
|
||||
if (!maxHealth.getModifiers().contains(modifier)) {
|
||||
maxHealth.addModifier(modifier);
|
||||
}
|
||||
maxHealth.removeModifier(new AttributeModifier(this.getUuid(), "bonus-hearts", 0, AttributeModifier.Operation.ADD_NUMBER));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SpeedMultiplier extends Effect<Double> {
|
||||
}
|
||||
|
||||
AttributeModifier modifier = new AttributeModifier(this.getUuid(), "speed-multiplier", strength - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1);
|
||||
if (!movementSpeed.getModifiers().contains(modifier)) {
|
||||
if (movementSpeed.getModifiers().stream().noneMatch(attributeModifier -> attributeModifier.getUniqueId().equals(modifier.getUniqueId()))) {
|
||||
movementSpeed.addModifier(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user