Code improvements.

This commit is contained in:
MobiusDev
2016-04-24 16:30:15 +00:00
parent 8bd51aba1c
commit 2dd14bef9b
860 changed files with 8865 additions and 17041 deletions

View File

@@ -55,32 +55,28 @@ public final class GiveRecommendation extends AbstractEffect
public void onStart(BuffInfo info)
{
final L2PcInstance target = info.getEffected() instanceof L2PcInstance ? (L2PcInstance) info.getEffected() : null;
if (target != null)
if (target == null)
{
int recommendationsGiven = _amount;
return;
}
final int recommendationsGiven = (target.getRecomHave() + _amount) >= 255 ? 255 - target.getRecomHave() : _amount;
if (recommendationsGiven > 0)
{
target.setRecomHave(target.getRecomHave() + recommendationsGiven);
if ((target.getRecomHave() + _amount) >= 255)
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_OBTAINED_S1_RECOMMENDATION_S);
sm.addInt(recommendationsGiven);
target.sendPacket(sm);
target.sendPacket(new UserInfo(target));
target.sendPacket(new ExVoteSystemInfo(target));
}
else
{
final L2PcInstance player = info.getEffector() instanceof L2PcInstance ? (L2PcInstance) info.getEffector() : null;
if (player != null)
{
recommendationsGiven = 255 - target.getRecomHave();
}
if (recommendationsGiven > 0)
{
target.setRecomHave(target.getRecomHave() + recommendationsGiven);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_OBTAINED_S1_RECOMMENDATION_S);
sm.addInt(recommendationsGiven);
target.sendPacket(sm);
target.sendPacket(new UserInfo(target));
target.sendPacket(new ExVoteSystemInfo(target));
}
else
{
final L2PcInstance player = info.getEffector() instanceof L2PcInstance ? (L2PcInstance) info.getEffector() : null;
if (player != null)
{
player.sendPacket(SystemMessageId.NOTHING_HAPPENED);
}
player.sendPacket(SystemMessageId.NOTHING_HAPPENED);
}
}
}