RequestExAcceptJoinMPCC.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.L2CommandChannel;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.network.SystemMessageId;
  19. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  20. /**
  21. * format: (ch) d
  22. * @author -Wooden-
  23. *
  24. */
  25. public final class RequestExAcceptJoinMPCC extends L2GameClientPacket
  26. {
  27. private static final String _C__D0_0E_REQUESTEXASKJOINMPCC = "[C] D0:0E RequestExAcceptJoinMPCC";
  28. private int _response;
  29. /**
  30. * @param buf
  31. * @param client
  32. */
  33. @Override
  34. protected void readImpl()
  35. {
  36. _response = readD();
  37. }
  38. /* (non-Javadoc)
  39. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
  40. */
  41. @Override
  42. protected void runImpl()
  43. {
  44. L2PcInstance player = getClient().getActiveChar();
  45. if(player != null)
  46. {
  47. L2PcInstance requestor = player.getActiveRequester();
  48. SystemMessage sm;
  49. if (requestor == null)
  50. return;
  51. if (_response == 1)
  52. {
  53. boolean newCc = false;
  54. if(!requestor.getParty().isInCommandChannel())
  55. {
  56. new L2CommandChannel(requestor); // Create new CC
  57. sm = new SystemMessage(SystemMessageId.COMMAND_CHANNEL_FORMED);
  58. requestor.sendPacket(sm);
  59. newCc = true;
  60. }
  61. requestor.getParty().getCommandChannel().addParty(player.getParty());
  62. if (!newCc)
  63. {
  64. sm = new SystemMessage(SystemMessageId.JOINED_COMMAND_CHANNEL);
  65. player.sendPacket(sm);
  66. }
  67. }
  68. else
  69. {
  70. requestor.sendMessage("The player declined to join your Command Channel.");
  71. }
  72. player.setActiveRequester(null);
  73. requestor.onTransactionResponse();
  74. }
  75. }
  76. /* (non-Javadoc)
  77. * @see com.l2jserver.gameserver.BasePacket#getType()
  78. */
  79. @Override
  80. public String getType()
  81. {
  82. return _C__D0_0E_REQUESTEXASKJOINMPCC;
  83. }
  84. }