diff --git a/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java b/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java index 1f21f1ee..99640094 100644 --- a/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java +++ b/src/main/java/com/github/manasmods/manascore/api/skills/TickingSkill.java @@ -6,28 +6,31 @@ import java.util.Optional; +@Getter public class TickingSkill { private int duration = 0; - @Getter private final ManasSkill skill; public TickingSkill(ManasSkill skill) { this.skill = skill; } public boolean tick(SkillStorage storage, LivingEntity entity) { - Optional optional = storage.getSkill(skill); + Optional optional = storage.getSkill(this.getSkill()); if (optional.isEmpty()) return false; ManasSkillInstance instance = optional.get(); if (reachedMaxDuration(instance, entity)) return false; - if (!instance.canInteractSkill(entity)) return false; + if (!instance.canInteractSkill(entity)) { + instance.onRelease(entity, this.getDuration()); + return false; + } return instance.onHeld(entity, this.duration++); } public boolean reachedMaxDuration(ManasSkillInstance instance, LivingEntity entity) { int maxDuration = instance.getMaxHeldTime(entity); if (maxDuration == -1) return false; - return duration >= maxDuration; + return this.getDuration() >= maxDuration; } }