RequestAnswerJoinParty.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  17. import com.l2jserver.gameserver.network.SystemMessageId;
  18. import com.l2jserver.gameserver.network.serverpackets.JoinParty;
  19. import com.l2jserver.gameserver.network.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. if (requestor.getParty() != null)//Update by rocknow-Start
  54. {
  55. if (requestor.getParty().getMemberCount() >= 9)
  56. {
  57. player.sendPacket(new SystemMessage(SystemMessageId.PARTY_FULL));
  58. requestor.sendPacket(new SystemMessage(SystemMessageId.PARTY_FULL));
  59. return;
  60. }
  61. }//Update by rocknow-End
  62. player.joinParty(requestor.getParty());
  63. }
  64. else
  65. {
  66. requestor.sendPacket(new SystemMessage(SystemMessageId.PLAYER_DECLINED));
  67. //activate garbage collection if there are no other members in party (happens when we were creating new one)
  68. if (requestor.getParty() != null && requestor.getParty().getMemberCount() == 1) requestor.setParty(null);
  69. }
  70. if (requestor.getParty() != null)
  71. requestor.getParty().setPendingInvitation(false); // if party is null, there is no need of decreasing
  72. player.setActiveRequester(null);
  73. requestor.onTransactionResponse();
  74. }
  75. }
  76. /* (non-Javadoc)
  77. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  78. */
  79. @Override
  80. public String getType()
  81. {
  82. return _C__2A_REQUESTANSWERPARTY;
  83. }
  84. }