diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/api/PlayerSkillExpGainEvent.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/api/PlayerSkillExpGainEvent.java index 36caa6f..9f5eb34 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/api/PlayerSkillExpGainEvent.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/api/PlayerSkillExpGainEvent.java @@ -13,6 +13,11 @@ public class PlayerSkillExpGainEvent extends PlayerEvent implements Cancellable */ private static final HandlerList HANDLERS = new HandlerList(); + /** + * If multiplier is used in this event + */ + private final boolean multiply; + /** * The skill. */ @@ -37,10 +42,12 @@ public class PlayerSkillExpGainEvent extends PlayerEvent implements Cancellable */ public PlayerSkillExpGainEvent(@NotNull final Player who, @NotNull final Skill skill, - final double amount) { + final double amount, + final boolean multiply) { super(who); this.skill = skill; this.amount = amount; + this.multiply = multiply; } /** @@ -61,6 +68,15 @@ public class PlayerSkillExpGainEvent extends PlayerEvent implements Cancellable return amount; } + /** + * Get if EcoSkills multipliers are used in this event. + * + * @return The experience. + */ + public boolean isMultiply() { + return multiply; + } + /** * Set the amount of experience. * diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt index 6bb2239..d832ab4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/EcoSkillsPlayer.kt @@ -71,15 +71,17 @@ fun OfflinePlayer.getAverageSkillLevel(): Double { } fun Player.giveSkillExperience(skill: Skill, experience: Double, noMultiply: Boolean = false) { - val exp = abs(if (noMultiply) experience else experience * this.getSkillExperienceMultiplier()) + var exp = abs(if (noMultiply) experience else experience * this.getSkillExperienceMultiplier()) - val gainEvent = PlayerSkillExpGainEvent(this, skill, exp) + val gainEvent = PlayerSkillExpGainEvent(this, skill, exp, !noMultiply) Bukkit.getPluginManager().callEvent(gainEvent) if (gainEvent.isCancelled) { return } + exp = gainEvent.amount + val level = this.getSkillLevel(skill) this.setSkillProgress(skill, this.getSkillProgress(skill) + exp)