Format code [skip actions]

This commit is contained in:
github-actions 2023-11-05 19:58:28 +00:00
parent d224178a64
commit 1fac319eb2
3 changed files with 38 additions and 27 deletions

View File

@ -55,21 +55,22 @@ public class Ability {
// //
avatarSkillStartIds = new HashSet<>(); avatarSkillStartIds = new HashSet<>();
if (data.onAbilityStart != null) { if (data.onAbilityStart != null) {
avatarSkillStartIds.addAll(Arrays.stream(data.onAbilityStart) avatarSkillStartIds.addAll(
.filter(action -> Arrays.stream(data.onAbilityStart)
action.type == AbilityModifierAction.Type.AvatarSkillStart) .filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID) .map(action -> action.skillID)
.toList()); .toList());
} }
avatarSkillStartIds.addAll(data.modifiers.values() avatarSkillStartIds.addAll(
.stream() data.modifiers.values().stream()
.map(m -> (List<AbilityModifierAction>)(m.onAdded == null ? .map(
Collections.emptyList() : m ->
Arrays.asList(m.onAdded))) (List<AbilityModifierAction>)
.flatMap(List::stream) (m.onAdded == null ? Collections.emptyList() : Arrays.asList(m.onAdded)))
.filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart) .flatMap(List::stream)
.map(action -> action.skillID) .filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.toList()); .map(action -> action.skillID)
.toList());
} }
public static String getAbilityName(AbilityString abString) { public static String getAbilityName(AbilityString abString) {

View File

@ -85,16 +85,24 @@ public final class AbilityManager extends BasePlayerManager {
boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible;
if (modifier.onAdded != null) { if (modifier.onAdded != null) {
skillInvincibility |= Arrays.stream(modifier.onAdded) skillInvincibility |=
.filter(action -> Arrays.stream(modifier.onAdded)
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance && .filter(
action.resistanceListID == 11002) action ->
.toList().size() > 0; action.type == AbilityModifierAction.Type.AttachAbilityStateResistance
&& action.resistanceListID == 11002)
.toList()
.size()
> 0;
} }
if (this.clearBurstEnergy != null && this.burstCasterId == entityId && if (this.clearBurstEnergy != null
(ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) { && this.burstCasterId == entityId
Grasscutter.getLogger().trace("Caster ID's {} burst successful, clearing energy and setting invulnerability", entityId); && (ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) {
Grasscutter.getLogger()
.trace(
"Caster ID's {} burst successful, clearing energy and setting invulnerability",
entityId);
this.abilityInvulnerable = true; this.abilityInvulnerable = true;
this.clearBurstEnergy.accept(entityId); this.clearBurstEnergy.accept(entityId);
this.removePendingEnergyClear(); this.removePendingEnergyClear();
@ -329,9 +337,11 @@ public final class AbilityManager extends BasePlayerManager {
} }
// Track this elemental burst to possibly clear avatar energy later. // Track this elemental burst to possibly clear avatar energy later.
this.clearBurstEnergy = (ignored) -> this.clearBurstEnergy =
player.getEnergyManager().handleEvtDoSkillSuccNotify( (ignored) ->
player.getSession(), skillId, casterId); player
.getEnergyManager()
.handleEvtDoSkillSuccNotify(player.getSession(), skillId, casterId);
this.burstCasterId = casterId; this.burstCasterId = casterId;
this.burstSkillId = skillId; this.burstSkillId = skillId;
} }

View File

@ -265,8 +265,8 @@ public class EnergyManager extends BasePlayerManager {
var skillData = GameData.getAvatarSkillDataMap().get(skillId); var skillData = GameData.getAvatarSkillDataMap().get(skillId);
// If the cast skill was a burst, consume energy. // If the cast skill was a burst, consume energy.
if ((avatar.getSkillDepot() != null && skillId == avatar.getSkillDepot().getEnergySkill()) || if ((avatar.getSkillDepot() != null && skillId == avatar.getSkillDepot().getEnergySkill())
(skillData != null && skillData.getCostElemVal() > 0)) { || (skillData != null && skillData.getCostElemVal() > 0)) {
avatar.getAsEntity().clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START); avatar.getAsEntity().clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START);
} }
} }