Casting Delay

This commit is contained in:
Ka0rX 2022-10-03 22:15:43 +02:00
parent 9abe1fd929
commit c4198f264c
4 changed files with 18 additions and 3 deletions

View File

@ -52,6 +52,7 @@ public class ClassSkill implements CooldownObject {
}
}
public RegisteredSkill getSkill() {
return skill;
}
@ -81,6 +82,15 @@ public class ClassSkill implements CooldownObject {
return Objects.requireNonNull(modifiers.get(modifier), "Could not find modifier '" + modifier + "'").calculate(level);
}
/**
* Gives the delay to launch the skill
*
* @return
*/
public int getDelay(PlayerData data) {
return modifiers.containsKey("delay") ? (int) modifiers.get("delay").calculate(data.getSkillLevel(getSkill())) : 0;
}
public List<String> calculateLore(PlayerData data) {
return calculateLore(data, data.getSkillLevel(skill));
}
@ -125,9 +135,11 @@ public class ClassSkill implements CooldownObject {
return new CastableSkill(this, caster.getSkillLevel(getSkill()));
}
/**
* Be careful, this method creates a new UUID each time it is called. Need to be remembered when trying to unregister passive skill
* from PassiveSkillMap.
*
* @return
*/
public PassiveSkill toPassive(PlayerData caster) {

View File

@ -9,6 +9,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
import net.Indyuce.mmocore.api.SoundEvent;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import net.Indyuce.mmocore.skill.cast.PlayerKey;
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
import org.bukkit.GameMode;
@ -81,7 +82,8 @@ public class SkillBar implements Listener {
*/
if (slot >= 0 && getCaster().hasSkillBound(slot)) {
PlayerMetadata caster = getCaster().getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
getCaster().getBoundSkill(slot).toCastable(getCaster()).cast(new TriggerMetadata(caster, null, null));
int delay= getCaster().getBoundSkill(slot).getDelay(getCaster());
getCaster().getBoundSkill(slot).toCastable(getCaster()).cast(new TriggerMetadata(caster, null, null),delay);
}
}

View File

@ -82,7 +82,8 @@ public class SkillScroller implements Listener {
CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting();
PlayerMetadata caster = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
playerData.getBoundSkill(casting.index).toCastable(playerData).cast(new TriggerMetadata(caster, null, null));
playerData.getBoundSkill(casting.index).toCastable(playerData).cast(new TriggerMetadata(caster, null, null)
, playerData.getBoundSkill(casting.index).getDelay(playerData));
}
}

View File

@ -76,7 +76,7 @@
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId>
<version>1.4.2-SNAPSHOT</version>
<version>1.4.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>