Removed BuffInfo from effect handlers.

This commit is contained in:
MobiusDev
2017-12-09 07:32:32 +00:00
parent 584bc234f7
commit 247a5bc9f5
461 changed files with 2706 additions and 3035 deletions

View File

@@ -780,7 +780,7 @@ public class CharStat
// Call pump to each effect
//@formatter:off
effectsStream.forEach(info -> info.getEffects().stream()
.filter(effect -> effect.canStart(info))
.filter(effect -> effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
.filter(effect -> effect.canPump(info.getEffector(), info.getEffected(), info.getSkill()))
.forEach(effect -> effect.pump(info.getEffected(), info.getSkill())));
//@formatter:on
@@ -792,7 +792,7 @@ public class CharStat
.filter(BuffInfo::isInUse)
.filter(info -> info.isAbnormalType(AbnormalType.ABILITY_CHANGE))
.forEach(info -> info.getEffects().stream()
.filter(effect -> effect.canStart(info))
.filter(effect -> effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
.filter(effect -> effect.canPump(_activeChar, _activeChar, info.getSkill()))
.forEach(effect -> effect.pump(_activeChar, info.getSkill())));
//@formatter:on

View File

@@ -21,14 +21,13 @@ import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.BuffInfo;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* Abstract effect implementation.<br>
* Instant effects should not override {@link #onExit(BuffInfo)}.<br>
* Instant effects should not override {@link #canStart(BuffInfo)}, all checks should be done {@link #onStart(BuffInfo)}.<br>
* Do not call super class methods {@link #onStart(BuffInfo)} nor {@link #onExit(BuffInfo)}.
* Instant effects should not override {@link #onExit(L2Character, L2Character, Skill)}.<br>
* Instant effects should not override {@link #canStart(L2Character, L2Character, Skill)}, all checks should be done {@link #onStart(L2Character, L2Character, Skill)}.<br>
* Do not call super class methods {@link #onStart(L2Character, L2Character, Skill)} nor {@link #onExit(L2Character, L2Character, Skill)}.
* @author Zoey76
*/
public abstract class AbstractEffect
@@ -75,23 +74,15 @@ public abstract class AbstractEffect
return true;
}
/**
* Get this effect's type.<br>
* TODO: Remove.
* @return the effect type
*/
public L2EffectType getEffectType()
{
return L2EffectType.NONE;
}
/**
* Verify if the buff can start.<br>
* Used for continuous effects.
* @param info the buff info
* @param effector
* @param effected
* @param skill
* @return {@code true} if all the start conditions are meet, {@code false} otherwise
*/
public boolean canStart(BuffInfo info)
public boolean canStart(L2Character effector, L2Character effected, Skill skill)
{
return true;
}
@@ -111,34 +102,24 @@ public abstract class AbstractEffect
}
/**
* Called on effect start.
* @param info the buff info
*/
public void onStart(BuffInfo info)
public void onExit(L2Character effector, L2Character effected, Skill skill)
{
}
/**
* Called on each tick.<br>
* If the abnormal time is lesser than zero it will last forever.
* @param info the buff info
* @param effector
* @param effected
* @param skill
* @return if {@code true} this effect will continue forever, if {@code false} it will stop after abnormal time has passed
*/
public boolean onActionTime(BuffInfo info)
public boolean onActionTime(L2Character effector, L2Character effected, Skill skill)
{
return false;
}
/**
* Called when the effect is exited.
* @param info the buff info
*/
public void onExit(BuffInfo info)
{
}
/**
* Get the effect flags.
* @return bit flag for current effect
@@ -148,12 +129,6 @@ public abstract class AbstractEffect
return EffectFlag.NONE.getMask();
}
@Override
public String toString()
{
return "Effect " + getClass().getSimpleName();
}
public boolean checkCondition(Object obj)
{
return true;
@@ -187,4 +162,20 @@ public abstract class AbstractEffect
{
}
/**
* Get this effect's type.<br>
* TODO: Remove.
* @return the effect type
*/
public L2EffectType getEffectType()
{
return L2EffectType.NONE;
}
@Override
public String toString()
{
return "Effect " + getClass().getSimpleName();
}
}

View File

@@ -176,7 +176,7 @@ public class Options
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
effect.pump(player, info.getSkill());
if (effect.canStart(info))
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
{
info.addEffect(effect);
}

View File

@@ -334,7 +334,6 @@ public final class BuffInfo
// Call on start.
effect.onStart(getEffector(), getEffected(), getSkill());
effect.onStart(this);
// If it's a continuous effect, if has ticks schedule a task with period, otherwise schedule a simple task to end it.
if (effect.getTicks() > 0)
@@ -361,7 +360,7 @@ public final class BuffInfo
if (_isInUse)
{
// Callback for on action time event.
continueForever = effect.onActionTime(this);
continueForever = effect.onActionTime(getEffector(), getEffected(), getSkill());
}
if (!continueForever && _skill.isToggle())
@@ -392,7 +391,7 @@ public final class BuffInfo
// Instant effects shouldn't call onExit(..).
if (!effect.isInstant())
{
effect.onExit(this);
effect.onExit(getEffector(), getEffected(), getSkill());
}
}

View File

@@ -1265,7 +1265,7 @@ public final class Skill implements IIdentifiable
effect.continuousInstant(info.getEffector(), info.getEffected(), info.getSkill(), info.getItem());
}
if (effect.canStart(info))
if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()))
{
info.addEffect(effect);
}