RequestJoinPledge.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.L2Clan;
  17. import com.l2jserver.gameserver.model.L2World;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.SystemMessageId;
  20. import com.l2jserver.gameserver.network.serverpackets.AskJoinPledge;
  21. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  22. /**
  23. * This class ...
  24. *
  25. * @version $Revision: 1.3.4.4 $ $Date: 2005/03/27 15:29:30 $
  26. */
  27. public final class RequestJoinPledge extends L2GameClientPacket
  28. {
  29. private static final String _C__24_REQUESTJOINPLEDGE = "[C] 24 RequestJoinPledge";
  30. private int _target;
  31. private int _pledgeType;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _target = readD();
  36. _pledgeType = readD();
  37. }
  38. @Override
  39. protected void runImpl()
  40. {
  41. final L2PcInstance activeChar = getClient().getActiveChar();
  42. if (activeChar == null)
  43. return;
  44. final L2Clan clan = activeChar.getClan();
  45. if (clan == null)
  46. return;
  47. final L2PcInstance target = L2World.getInstance().getPlayer(_target);
  48. if (target == null)
  49. {
  50. activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
  51. return;
  52. }
  53. if (!clan.checkClanJoinCondition(activeChar, target, _pledgeType))
  54. return;
  55. if (!activeChar.getRequest().setRequest(target, this))
  56. return;
  57. final String pledgeName = activeChar.getClan().getName();
  58. final String subPledgeName = (activeChar.getClan().getSubPledge(_pledgeType) != null ? activeChar.getClan().getSubPledge(_pledgeType).getName() : null);
  59. target.sendPacket(new AskJoinPledge(activeChar.getObjectId(), subPledgeName, _pledgeType, pledgeName));
  60. }
  61. public int getPledgeType()
  62. {
  63. return _pledgeType;
  64. }
  65. /* (non-Javadoc)
  66. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  67. */
  68. @Override
  69. public String getType()
  70. {
  71. return _C__24_REQUESTJOINPLEDGE;
  72. }
  73. }