Removed stream usage from BlockActions effect.

This commit is contained in:
MobiusDevelopment
2023-01-08 11:51:53 +00:00
parent 8226d405fc
commit 003a68a7e1
52 changed files with 572 additions and 234 deletions
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5574,12 +5574,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5574,12 +5574,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5574,12 +5574,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5574,12 +5574,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5583,12 +5583,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5583,12 +5583,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5583,12 +5583,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5582,12 +5582,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5582,12 +5582,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5582,12 +5582,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5592,12 +5592,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5592,12 +5592,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5562,12 +5562,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5562,12 +5562,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5562,12 +5562,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5562,12 +5562,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5571,12 +5571,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5596,12 +5596,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5596,12 +5596,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5596,12 +5596,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5595,12 +5595,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5562,12 +5562,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5608,12 +5608,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5627,12 +5627,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5647,12 +5647,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }
@@ -16,9 +16,8 @@
*/ */
package handlers.effecthandlers; package handlers.effecthandlers;
import java.util.Arrays; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.l2jmobius.gameserver.ai.CtrlEvent; import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention; import org.l2jmobius.gameserver.ai.CtrlIntention;
@@ -37,12 +36,17 @@ import org.l2jmobius.gameserver.model.skill.Skill;
*/ */
public class BlockActions extends AbstractEffect public class BlockActions extends AbstractEffect
{ {
private final Set<Integer> _allowedSkills; private final Set<Integer> _allowedSkills = new HashSet<>();
public BlockActions(StatSet params) public BlockActions(StatSet params)
{ {
final String[] allowedSkills = params.getString("allowedSkills", "").split(";"); for (String skill : params.getString("allowedSkills", "").split(";"))
_allowedSkills = Arrays.stream(allowedSkills).filter(s -> !s.isEmpty()).map(Integer::parseInt).collect(Collectors.toSet()); {
if (!skill.isEmpty())
{
_allowedSkills.add(Integer.parseInt(skill));
}
}
} }
@Override @Override
@@ -65,8 +69,13 @@ public class BlockActions extends AbstractEffect
return; return;
} }
_allowedSkills.stream().forEach(effected::addBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.addBlockActionsAllowedSkill(skillId);
}
effected.startParalyze(); effected.startParalyze();
// Cancel running skill casters. // Cancel running skill casters.
effected.abortAllSkillCasters(); effected.abortAllSkillCasters();
} }
@@ -74,7 +83,11 @@ public class BlockActions extends AbstractEffect
@Override @Override
public void onExit(Creature effector, Creature effected, Skill skill) public void onExit(Creature effector, Creature effected, Skill skill)
{ {
_allowedSkills.stream().forEach(effected::removeBlockActionsAllowedSkill); for (Integer skillId : _allowedSkills)
{
effected.removeBlockActionsAllowedSkill(skillId);
}
if (effected.isPlayable()) if (effected.isPlayable())
{ {
if (effected.isSummon()) if (effected.isSummon())
@@ -5647,12 +5647,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return _effectList.hasAbnormalType(abnormalType); return _effectList.hasAbnormalType(abnormalType);
} }
public void addBlockActionsAllowedSkill(int skillId) public void addBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet(); _blockActionsAllowedSkills.computeIfAbsent(skillId, k -> new AtomicInteger()).incrementAndGet();
} }
public void removeBlockActionsAllowedSkill(int skillId) public void removeBlockActionsAllowedSkill(Integer skillId)
{ {
_blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null); _blockActionsAllowedSkills.computeIfPresent(skillId, (k, v) -> v.decrementAndGet() != 0 ? v : null);
} }