ExItemAuctionInfoPacket.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.gameserver.model.ItemInfo;
  17. import com.l2jserver.gameserver.model.itemauction.ItemAuction;
  18. import com.l2jserver.gameserver.model.itemauction.ItemAuctionBid;
  19. import com.l2jserver.gameserver.model.itemauction.ItemAuctionState;
  20. /**
  21. * @author Forsaiken
  22. * Format: (cdqd)(dddqhhhdhhdddhhhhhhhhhhh)(ddd)(dddqhhhdhhdddhhhhhhhhhhh)
  23. */
  24. public final class ExItemAuctionInfoPacket extends L2GameServerPacket
  25. {
  26. private final boolean _refresh;
  27. private final int _timeRemaining;
  28. private final ItemAuction _currentAuction;
  29. private final ItemAuction _nextAuction;
  30. public ExItemAuctionInfoPacket(final boolean refresh, final ItemAuction currentAuction, final ItemAuction nextAuction)
  31. {
  32. if (currentAuction == null)
  33. throw new NullPointerException();
  34. if (currentAuction.getAuctionState() != ItemAuctionState.STARTED)
  35. _timeRemaining = 0;
  36. else
  37. _timeRemaining = (int) (currentAuction.getFinishingTimeRemaining() / 1000); // in seconds
  38. _refresh = refresh;
  39. _currentAuction = currentAuction;
  40. _nextAuction = nextAuction;
  41. }
  42. @Override
  43. protected void writeImpl()
  44. {
  45. writeC(0xFE);
  46. writeH(0x68);
  47. writeC(_refresh ? 0x00 : 0x01);
  48. writeD(_currentAuction.getInstanceId());
  49. final ItemAuctionBid highestBid = _currentAuction.getHighestBid();
  50. writeQ(highestBid != null ? highestBid.getLastBid() : _currentAuction.getAuctionInitBid());
  51. writeD(_timeRemaining);
  52. writeItemInfo(_currentAuction.getItemInfo());
  53. if (_nextAuction != null)
  54. {
  55. writeQ(_nextAuction.getAuctionInitBid());
  56. writeD((int) (_nextAuction.getStartingTime() / 1000)); // unix time in seconds
  57. writeItemInfo(_nextAuction.getItemInfo());
  58. }
  59. }
  60. private final void writeItemInfo(final ItemInfo item)
  61. {
  62. writeD(item.getItem().getItemId());
  63. writeD(item.getItem().getItemId());
  64. writeD(item.getLocation());
  65. writeQ(item.getCount());
  66. writeH(item.getItem().getType2());
  67. writeH(item.getCustomType1());
  68. writeH(0x00); //Equipped ? ON AUCTION?
  69. writeD(item.getItem().getBodyPart());
  70. writeH(item.getEnchant());
  71. writeH(item.getCustomType2());
  72. writeD(item.getAugmentationBonus());
  73. writeD(item.getMana());
  74. writeD(item.getTime());
  75. writeH(item.getAttackElementType());
  76. writeH(item.getAttackElementPower());
  77. for (byte i = 0; i < 6; i++)
  78. super.writeH(item.getElementDefAttr(i));
  79. writeH(0x00); // enchant effect 1
  80. writeH(0x00); // enchant effect 2
  81. writeH(0x00); // enchant effect 3
  82. }
  83. @Override
  84. public final String getType()
  85. {
  86. return "[S] fe:68:00 ExItemAuctionInfoPacket";
  87. }
  88. }