ExShowSentPost.java 3.0 KB

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