ExShowReceivedPost.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 ExShowReceivedPost extends L2GameServerPacket
  24. {
  25. private static final String _S__FE_AB_EXSHOWRECEIVEDPOST = "[S] FE:AB ExShowReceivedPost";
  26. private static final Logger _log = Logger.getLogger(ExShowReceivedPost.class.getName());
  27. private Message _msg;
  28. private L2ItemInstance[] _items = null;
  29. public ExShowReceivedPost(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. writeH(item.getItem().getType2());
  61. writeD(0x00); // unknown
  62. writeD(item.getItemId());
  63. writeQ(item.getCount());
  64. writeD(0x00); // unknown
  65. writeD(item.getEnchantLevel());
  66. writeH(item.getCustomType2());
  67. writeH(0x00); // unknown
  68. writeD(item.isAugmented() ? item.getAugmentation().getAugmentationId() : 0x00);
  69. writeD(0x00); // unknown
  70. writeH(item.getAttackElementType());
  71. writeH(item.getAttackElementPower());
  72. for (byte i = 0; i < 6; i++)
  73. writeH(item.getElementDefAttr(i));
  74. writeH(0x00); // Enchant effect 1
  75. writeH(0x00); // Enchant effect 2
  76. writeH(0x00); // Enchant effect 3
  77. }
  78. _items = null;
  79. }
  80. else
  81. writeD(0x00);
  82. writeQ(_msg.getReqAdena());
  83. writeD(0x01); // Unknown why 1
  84. writeD(0x00); // Unknown
  85. _msg = null;
  86. }
  87. /* (non-Javadoc)
  88. * @see com.l2jserver.gameserver.BasePacket#getType()
  89. */
  90. @Override
  91. public String getType()
  92. {
  93. return _S__FE_AB_EXSHOWRECEIVEDPOST;
  94. }
  95. }