Fixed passive skills being castable thru combos

This commit is contained in:
Jules 2024-06-14 00:43:30 -07:00
parent e17a8f903a
commit 1661b8d6eb
2 changed files with 12 additions and 6 deletions

View File

@ -15,8 +15,11 @@ public class BoundSkillInfo implements Closeable {
private final ClassSkill classSkill; private final ClassSkill classSkill;
/** /**
* PASSIVE skills must be registered inside MythicLib when * Non-permanent passive skills must be registered inside
* bound. When set to null, the skill is not registered. * MythicLib when bound. When set to null, the skill is either
* active or permanent passive.
* <p>
* This does NOT indicate the skill being passive!
*/ */
@Nullable @Nullable
private final PassiveSkill registered; private final PassiveSkill registered;
@ -55,7 +58,7 @@ public class BoundSkillInfo implements Closeable {
} }
public boolean isPassive() { public boolean isPassive() {
return registered != null; return classSkill.getSkill().getTrigger().isPassive();
} }
@Override @Override
@ -63,7 +66,7 @@ public class BoundSkillInfo implements Closeable {
Validate.isTrue(open, "BoundSkillInfo has already been closed"); Validate.isTrue(open, "BoundSkillInfo has already been closed");
open = false; open = false;
// Unregister skill if passive // Unregister skill if non-permanent passive
if (registered != null) registered.unregister(playerData.getMMOPlayerData()); if (registered != null) registered.unregister(playerData.getMMOPlayerData());
// Remove skill buffs associated to the slot // Remove skill buffs associated to the slot

View File

@ -12,6 +12,7 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent; import net.Indyuce.mmocore.api.event.PlayerKeyPressEvent;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.gui.api.item.Placeholders; import net.Indyuce.mmocore.gui.api.item.Placeholders;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.cast.*; import net.Indyuce.mmocore.skill.cast.*;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -146,9 +147,11 @@ public class KeyCombos extends SkillCastingHandler {
else playerData.leaveSkillCasting(true); else playerData.leaveSkillCasting(true);
// Cast spell // Cast spell
if (playerData.hasSkillBound(spellSlot)) { final ClassSkill boundSkill;
if (playerData.hasSkillBound(spellSlot) &&
!(boundSkill = playerData.getBoundSkill(spellSlot)).getSkill().getTrigger().isPassive()) {
final PlayerMetadata caster = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND); final PlayerMetadata caster = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
final SkillResult result = playerData.getBoundSkill(spellSlot).toCastable(playerData).cast(new TriggerMetadata(caster, null, null)); final SkillResult result = boundSkill.toCastable(playerData).cast(new TriggerMetadata(caster, TriggerType.CAST, null, null));
if (!result.isSuccessful()) if (failSkillSound != null) failSkillSound.playTo(player); if (!result.isSuccessful()) if (failSkillSound != null) failSkillSound.playTo(player);
} else if (stayIn) { } else if (stayIn) {
if (failComboSound != null) failComboSound.playTo(player); if (failComboSound != null) failComboSound.playTo(player);