88 lines
2.6 KiB
Java
88 lines
2.6 KiB
Java
/*
|
|
* This file is part of the L2J Mobius project.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package handlers.effecthandlers;
|
|
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
import com.l2jmobius.gameserver.model.CharEffectList;
|
|
import com.l2jmobius.gameserver.model.StatsSet;
|
|
import com.l2jmobius.gameserver.model.actor.L2Character;
|
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
|
import com.l2jmobius.gameserver.model.effects.L2EffectType;
|
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
|
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
|
|
|
/**
|
|
* Dispel By Slot effect implementation.
|
|
* @author Gnacik, Zoey76, Adry_85
|
|
*/
|
|
public final class DispelBySlotMyself extends AbstractEffect
|
|
{
|
|
private final Set<AbnormalType> _dispelAbnormals;
|
|
|
|
public DispelBySlotMyself(StatsSet params)
|
|
{
|
|
final String dispel = params.getString("dispel", null);
|
|
if ((dispel != null) && !dispel.isEmpty())
|
|
{
|
|
_dispelAbnormals = new HashSet<>();
|
|
for (String slot : dispel.split(";"))
|
|
{
|
|
_dispelAbnormals.add(AbnormalType.getAbnormalType(slot));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_dispelAbnormals = Collections.<AbnormalType> emptySet();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public L2EffectType getEffectType()
|
|
{
|
|
return L2EffectType.DISPEL_BY_SLOT;
|
|
}
|
|
|
|
@Override
|
|
public boolean isInstant()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
|
|
{
|
|
if (_dispelAbnormals.isEmpty())
|
|
{
|
|
return;
|
|
}
|
|
|
|
final CharEffectList effectList = effected.getEffectList();
|
|
// There is no need to iterate over all buffs,
|
|
// Just iterate once over all slots to dispel and get the buff with that abnormal if exists,
|
|
// Operation of O(n) for the amount of slots to dispel (which is usually small) and O(1) to get the buff.
|
|
for (AbnormalType entry : _dispelAbnormals)
|
|
{
|
|
// The effectlist should already check if it has buff with this abnormal type or not.
|
|
effectList.stopSkillEffects(true, entry);
|
|
}
|
|
}
|
|
}
|