49 lines
1.2 KiB
Java
49 lines
1.2 KiB
Java
package cn.infstar.cmagicgem.reward;
|
|
|
|
import cn.infstar.cmagicgem.gem.GemDefinition;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import java.util.IdentityHashMap;
|
|
import java.util.Map;
|
|
import java.util.function.DoubleSupplier;
|
|
|
|
public final class RewardContext {
|
|
private final Player player;
|
|
private final GemDefinition gem;
|
|
private ItemStack item;
|
|
private final boolean removal;
|
|
private final Map<Object, Double> evaluatedNumbers = new IdentityHashMap<>();
|
|
|
|
public RewardContext(Player player, GemDefinition gem, ItemStack item, boolean removal) {
|
|
this.player = player;
|
|
this.gem = gem;
|
|
this.item = item;
|
|
this.removal = removal;
|
|
}
|
|
|
|
public Player player() {
|
|
return player;
|
|
}
|
|
|
|
public GemDefinition gem() {
|
|
return gem;
|
|
}
|
|
|
|
public ItemStack item() {
|
|
return item;
|
|
}
|
|
|
|
public void item(ItemStack item) {
|
|
this.item = item;
|
|
}
|
|
|
|
public boolean removal() {
|
|
return removal;
|
|
}
|
|
|
|
public double evaluatedNumber(Object key, DoubleSupplier supplier) {
|
|
return evaluatedNumbers.computeIfAbsent(key, ignored -> supplier.getAsDouble());
|
|
}
|
|
}
|