Added Price#withMultiplier

This commit is contained in:
Auxilor
2022-11-23 22:00:07 +00:00
parent 823ef6477b
commit 854a10e8fd
5 changed files with 44 additions and 0 deletions

View File

@@ -82,6 +82,14 @@ public final class ConfiguredPrice implements Price {
this.price.setMultiplier(player, multiplier);
}
@Override
public @NotNull ConfiguredPrice withMultiplier(final double multiplier) {
return new ConfiguredPrice(
this.price.withMultiplier(multiplier),
formatString
);
}
/**
* Get the price that this delegates to.
*

View File

@@ -88,4 +88,14 @@ public interface Price {
final double multiplier) {
// Override when needed.
}
/**
* Copy this price with a given base multiplier.
*
* @param multiplier The multiplier.
*/
@NotNull
default Price withMultiplier(final double multiplier) {
return this;
}
}

View File

@@ -81,4 +81,12 @@ public final class PriceEconomy implements Price {
final double multiplier) {
this.multipliers.put(player.getUniqueId(), multiplier);
}
@Override
public @NotNull PriceEconomy withMultiplier(double multiplier) {
return new PriceEconomy(
baseContext,
ctx -> function.apply(ctx) * multiplier
);
}
}

View File

@@ -146,4 +146,13 @@ public final class PriceItem implements Price {
final double multiplier) {
this.multipliers.put(player.getUniqueId(), multiplier);
}
@Override
public @NotNull PriceItem withMultiplier(double multiplier) {
return new PriceItem(
baseContext,
ctx -> function.apply(ctx) * multiplier,
item
);
}
}