Added Price#withMultiplier
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user