ExReplySentPost.java 3.1 KB

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