{
if(targ == null || !targ.isMonster() || !targ.isDead() || !((L2MonsterInstance) targ).isSpoiled())
{
continue;
}
L2MonsterInstance target = (L2MonsterInstance) targ;
if(!target.isSpoiled(player))
{
activeChar.sendPacket(Msg.THERE_ARE_NO_PRIORITY_RIGHTS_ON_A_SWEEPER);
continue;
}
L2ItemInstance[] items = target.takeSweep();
if(items == null)
{
activeChar.getAI().setAttackTarget(null);
target.endDecayTask();
continue;
}
target.setSpoiled(false, null);
for(L2ItemInstance item : items)
{
if(player.isInParty() && player.getParty().isDistributeSpoilLoot())
{
player.getParty().distributeItem(player, item);
continue;
}
long itemCount = item.getCount();
if(player.getInventoryLimit() <= player.getInventory().getSize() && (!item.isStackable() || player.getInventory().getItemByItemId(item.getItemId()) == null))
{
item.dropToTheGround(player, target);
continue;
}
item = player.getInventory().addItem(item);
Log.LogItem(player, target, Log.SweepItem, item);
SystemMessage smsg;
if(itemCount == 1)
{
smsg = new SystemMessage(SystemMessage.YOU_HAVE_OBTAINED_S1);
smsg.addItemName(item.getItemId());
player.sendPacket(smsg);
}
else
{
smsg = new SystemMessage(SystemMessage.YOU_HAVE_OBTAINED_S2_S1);
smsg.addItemName(item.getItemId());
smsg.addNumber(itemCount);
player.sendPacket(smsg);
}
if(player.isInParty())
{
if(itemCount == 1)
{
smsg = new SystemMessage(SystemMessage.S1_HAS_OBTAINED_S2_BY_USING_SWEEPER);
smsg.addString(player.getName());
smsg.addItemName(item.getItemId());
player.getParty().broadcastToPartyMembers(player, smsg);
}
else
{
smsg = new SystemMessage(SystemMessage.S1_HAS_OBTAINED_3_S2_S_BY_USING_SWEEPER);
smsg.addString(player.getName());
smsg.addItemName(item.getItemId());
smsg.addNumber(itemCount);
player.getParty().broadcastToPartyMembers(player, smsg);
}
}
}
activeChar.getAI().setAttackTarget(null);
target.endDecayTask();
}
}