ExReplyReceivedPost.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 java.util.logging.Logger;
  17. import com.l2jserver.gameserver.model.L2ItemInstance;
  18. import com.l2jserver.gameserver.model.entity.Message;
  19. import com.l2jserver.gameserver.model.itemcontainer.ItemContainer;
  20. /**
  21. * @author Migi, DS
  22. */
  23. public class ExReplyReceivedPost extends L2GameServerPacket
  24. {
  25. private static final String _S__FE_AB_EXSHOWRECEIVEDPOST = "[S] FE:AB ExShowReceivedPost";
  26. private static final Logger _log = Logger.getLogger(ExReplyReceivedPost.class.getName());
  27. private Message _msg;
  28. private L2ItemInstance[] _items = null;
  29. public ExReplyReceivedPost(Message msg)
  30. {
  31. _msg = msg;
  32. if (msg.hasAttachments())
  33. {
  34. final ItemContainer attachments = msg.getAttachments();
  35. if (attachments != null && attachments.getSize() > 0)
  36. _items = attachments.getItems();
  37. else
  38. _log.warning("Message "+msg.getId()+" has attachments but itemcontainer is empty.");
  39. }
  40. }
  41. /* (non-Javadoc)
  42. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#writeImpl()
  43. */
  44. @Override
  45. protected void writeImpl()
  46. {
  47. writeC(0xfe);
  48. writeH(0xab);
  49. writeD(_msg.getId());
  50. writeD(_msg.isLocked() ? 1 : 0);
  51. writeD(0x00); //Unknown
  52. writeS(_msg.getSenderName());
  53. writeS(_msg.getSubject());
  54. writeS(_msg.getContent());
  55. if (_items != null && _items.length > 0)
  56. {
  57. writeD(_items.length);
  58. for (L2ItemInstance item : _items)
  59. {
  60. writeD(0x00);
  61. writeD(item.getItemId());
  62. writeD(item.getLocationSlot());
  63. writeQ(item.getCount());
  64. writeH(item.getItem().getType2());
  65. writeH(item.getCustomType1());
  66. writeH(item.isEquipped() ? 0x01 : 0x00);
  67. writeD(item.getItem().getBodyPart());
  68. writeH(item.getEnchantLevel());
  69. writeH(item.getCustomType2());
  70. if (item.isAugmented())
  71. writeD(item.getAugmentation().getAugmentationId());
  72. else
  73. writeD(0x00);
  74. writeD(item.getMana());
  75. writeD(item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999);
  76. writeH(item.getAttackElementType());
  77. writeH(item.getAttackElementPower());
  78. for (byte i = 0; i < 6; i++)
  79. {
  80. writeH(item.getElementDefAttr(i));
  81. }
  82. // Enchant Effects
  83. writeH(0);
  84. writeH(0);
  85. writeH(0);
  86. writeD(item.getObjectId());
  87. }
  88. _items = null;
  89. }
  90. else
  91. writeD(0x00);
  92. writeQ(_msg.getReqAdena());
  93. writeD(_msg.hasAttachments() ? 1 : 0);
  94. writeD(_msg.isFourStars() ? 1 : 0);
  95. _msg = null;
  96. }
  97. /* (non-Javadoc)
  98. * @see com.l2jserver.gameserver.BasePacket#getType()
  99. */
  100. @Override
  101. public String getType()
  102. {
  103. return _S__FE_AB_EXSHOWRECEIVEDPOST;
  104. }
  105. }