Package lineage2.gameserver.network.serverpackets

Source Code of lineage2.gameserver.network.serverpackets.ExShowProcureCropDetail

package lineage2.gameserver.network.serverpackets;

import lineage2.gameserver.data.xml.holder.ResidenceHolder;
import lineage2.gameserver.instancemanager.CastleManorManager;
import lineage2.gameserver.model.entity.residence.Castle;
import lineage2.gameserver.templates.manor.CropProcure;

import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
* format dd[dddc] dd[dQQc] - Gracia Final
*/
public class ExShowProcureCropDetail extends L2GameServerPacket
{
  private int _cropId;
  private Map<Integer, CropProcure> _castleCrops;

  public ExShowProcureCropDetail(int cropId)
  {
    _cropId = cropId;
    _castleCrops = new TreeMap<Integer, CropProcure>();

    List<Castle> castleList = ResidenceHolder.getInstance().getResidenceList(Castle.class);
    for (Castle c : castleList)
    {
      CropProcure cropItem = c.getCrop(_cropId, CastleManorManager.PERIOD_CURRENT);
      if (cropItem != null && cropItem.getAmount() > 0)
        _castleCrops.put(c.getId(), cropItem);
    }
  }

  @Override
  public void writeImpl()
  {
    writeEx(0x79);

    writeD(_cropId); // crop id
    writeD(_castleCrops.size()); // size

    for (int manorId : _castleCrops.keySet())
    {
      CropProcure crop = _castleCrops.get(manorId);
      writeD(manorId); // manor name
      writeQ(crop.getAmount()); // buy residual
      writeQ(crop.getPrice()); // buy price
      writeC(crop.getReward()); // reward type
    }
  }
}
TOP

Related Classes of lineage2.gameserver.network.serverpackets.ExShowProcureCropDetail

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.