I have a method from an interface that goes through an array of items and buffs and calculates the sum of all of a certain method like so:
@Override
public float getDamageReduction(EntityPlayable playable) {
float bonus = (float) Arrays.stream(items).filter(Objects::nonNull).mapToDouble(Item::getDamageReduction(this)).sum();
float buffBonus = (float)buffs.stream().mapToDouble(Buff::getDamageReduction(this)).sum();
return bonus + buffBonus;
}
This code doesn't work because you can't Buff::getDamageReduction(this) because you're not allowed to use method references with parameters.
How can I get around this?