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