use of com.winthier.skills.CustomReward in project Skills by StarTux.
the class BukkitSkill method giveReward.
final void giveReward(@NonNull Player player, Reward reward, double factor) {
int level = getSkills().getScore().getSkillLevel(player.getUniqueId(), this);
double bonusFactor = getSkillType() == BukkitSkillType.SACRIFICE ? 1.0 : 1.0 + (double) (level / 10) / 100.0;
if (reward == null)
return;
double skillPoints = reward.getSkillPoints() * factor;
double money = reward.getMoney() * factor * bonusFactor;
double exp = reward.getExp() * factor;
if (skillPoints < 0.01 && money < 0.01 && exp < 0.01)
return;
if (getSkills().hasDebugMode(player)) {
BukkitReward br = BukkitReward.of(reward);
BukkitUtil.msg(player, "[sk] &e%s &8%s &e%s %s&8:&e%s &8\"&e%s&8\" &6%.2f&8sp &6%.2f&8mo &6%.2f&8xp", getShorthand(), Strings.camelCase(br.key.getTarget().name()), Strings.camelCase(br.key.typeAsPrettyString()), br.key.typeAsString(), br.key.dataAsString(), br.key.nameAsString(), skillPoints, money, exp);
}
giveSkillPoints(player, skillPoints);
giveMoney(player, money);
giveExp(player, exp);
Reward outcome = new CustomReward((float) skillPoints, (float) money, (float) exp);
BukkitPlayer.of(player).onReward(player, this, outcome);
getSkills().getScore().logReward(reward, player.getUniqueId(), outcome);
Bukkit.getServer().getPluginManager().callEvent(new SkillsRewardEvent(player, this, outcome));
}
use of com.winthier.skills.CustomReward in project Skills by StarTux.
the class BukkitSkillSacrifice method fullRewardForItem.
/**
* Utility function for the checkitem command. Do not use for
* actual rewarding!
*/
public Reward fullRewardForItem(ItemStack item) {
float skillPoints = 0;
float money = 0;
float exp = 0;
for (Reward reward : rewardsForItem(item)) {
skillPoints += reward.getSkillPoints();
money += reward.getMoney();
exp += reward.getExp();
}
return new CustomReward(skillPoints, money, exp);
}
Aggregations