2
0

RequestAnswerJoinParty.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 net.sf.l2j.gameserver.clientpackets;
  16. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  17. import net.sf.l2j.gameserver.network.SystemMessageId;
  18. import net.sf.l2j.gameserver.serverpackets.JoinParty;
  19. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  20. /**
  21. * sample
  22. * 2a
  23. * 01 00 00 00
  24. *
  25. * format cdd
  26. *
  27. *
  28. * @version $Revision: 1.7.4.2 $ $Date: 2005/03/27 15:29:30 $
  29. */
  30. public final class RequestAnswerJoinParty extends L2GameClientPacket
  31. {
  32. private static final String _C__2A_REQUESTANSWERPARTY = "[C] 2A RequestAnswerJoinParty";
  33. //private static Logger _log = Logger.getLogger(RequestAnswerJoinParty.class.getName());
  34. private int _response;
  35. @Override
  36. protected void readImpl()
  37. {
  38. _response = readD();
  39. }
  40. @Override
  41. protected void runImpl()
  42. {
  43. L2PcInstance player = getClient().getActiveChar();
  44. if(player != null)
  45. {
  46. L2PcInstance requestor = player.getActiveRequester();
  47. if (requestor == null)
  48. return;
  49. JoinParty join = new JoinParty(_response);
  50. requestor.sendPacket(join);
  51. if (_response == 1)
  52. {
  53. player.joinParty(requestor.getParty());
  54. } else
  55. {
  56. SystemMessage msg = new SystemMessage(SystemMessageId.PLAYER_DECLINED);
  57. requestor.sendPacket(msg);
  58. msg = null;
  59. //activate garbage collection if there are no other members in party (happens when we were creating new one)
  60. if (requestor.getParty() != null && requestor.getParty().getMemberCount() == 1) requestor.setParty(null);
  61. }
  62. if (requestor.getParty() != null)
  63. requestor.getParty().decreasePendingInvitationNumber(); // if party is null, there is no need of decreasing
  64. player.setActiveRequester(null);
  65. requestor.onTransactionResponse();
  66. }
  67. }
  68. /* (non-Javadoc)
  69. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  70. */
  71. @Override
  72. public String getType()
  73. {
  74. return _C__2A_REQUESTANSWERPARTY;
  75. }
  76. }