2
0

ExShowSeedInfo.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import java.util.List;
  21. import com.l2jserver.gameserver.instancemanager.CastleManorManager;
  22. import com.l2jserver.gameserver.model.L2Seed;
  23. import com.l2jserver.gameserver.model.SeedProduction;
  24. /**
  25. * @author l3x
  26. */
  27. public class ExShowSeedInfo extends L2GameServerPacket
  28. {
  29. private final List<SeedProduction> _seeds;
  30. private final int _manorId;
  31. private final boolean _hideButtons;
  32. public ExShowSeedInfo(int manorId, boolean nextPeriod, boolean hideButtons)
  33. {
  34. _manorId = manorId;
  35. _hideButtons = hideButtons;
  36. final CastleManorManager manor = CastleManorManager.getInstance();
  37. _seeds = (nextPeriod && !manor.isManorApproved()) ? null : manor.getSeedProduction(manorId, nextPeriod);
  38. }
  39. @Override
  40. protected void writeImpl()
  41. {
  42. writeC(0xFE); // Id
  43. writeH(0x23); // SubId
  44. writeC(_hideButtons ? 0x01 : 0x00); // Hide "Seed Purchase" button
  45. writeD(_manorId); // Manor ID
  46. writeD(0x00); // Unknown
  47. if (_seeds == null)
  48. {
  49. writeD(0);
  50. return;
  51. }
  52. writeD(_seeds.size());
  53. for (SeedProduction seed : _seeds)
  54. {
  55. writeD(seed.getId()); // Seed id
  56. writeQ(seed.getAmount()); // Left to buy
  57. writeQ(seed.getStartAmount()); // Started amount
  58. writeQ(seed.getPrice()); // Sell Price
  59. final L2Seed s = CastleManorManager.getInstance().getSeed(seed.getId());
  60. if (s == null)
  61. {
  62. writeD(0); // Seed level
  63. writeC(0x01); // Reward 1
  64. writeD(0); // Reward 1 - item id
  65. writeC(0x01); // Reward 2
  66. writeD(0); // Reward 2 - item id
  67. }
  68. else
  69. {
  70. writeD(s.getLevel()); // Seed level
  71. writeC(0x01); // Reward 1
  72. writeD(s.getReward(1)); // Reward 1 - item id
  73. writeC(0x01); // Reward 2
  74. writeD(s.getReward(2)); // Reward 2 - item id
  75. }
  76. }
  77. }
  78. }