RequestSentPost.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.clientpackets;
  16. import static com.l2jserver.gameserver.model.actor.L2Character.ZONE_PEACE;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.instancemanager.MailManager;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.model.entity.Message;
  21. import com.l2jserver.gameserver.network.SystemMessageId;
  22. import com.l2jserver.gameserver.network.serverpackets.ExShowSentPost;
  23. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  24. import com.l2jserver.gameserver.util.Util;
  25. /**
  26. * @author Migi, DS
  27. */
  28. public final class RequestSentPost extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_6E_REQUESTSENTPOST = "[C] D0:6E RequestSentPost";
  31. private int _msgId;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _msgId = readD();
  36. }
  37. @Override
  38. public void runImpl()
  39. {
  40. final L2PcInstance activeChar = getClient().getActiveChar();
  41. if (activeChar == null || !Config.ALLOW_MAIL)
  42. return;
  43. if (!activeChar.isInsideZone(ZONE_PEACE))
  44. {
  45. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANT_USE_MAIL_OUTSIDE_PEACE_ZONE));
  46. return;
  47. }
  48. Message msg = MailManager.getInstance().getMessage(_msgId);
  49. if (msg == null)
  50. return;
  51. if (msg.getSenderId() != activeChar.getObjectId())
  52. {
  53. Util.handleIllegalPlayerAction(activeChar,
  54. "Player "+activeChar.getName()+" tried to read not own post!", Config.DEFAULT_PUNISH);
  55. return;
  56. }
  57. if (msg.isDeletedBySender())
  58. return;
  59. activeChar.sendPacket(new ExShowSentPost(msg));
  60. }
  61. @Override
  62. public String getType()
  63. {
  64. return _C__D0_6E_REQUESTSENTPOST;
  65. }
  66. }