RequestJoinPledge.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.L2Clan;
  17. import net.sf.l2j.gameserver.model.L2Object;
  18. import net.sf.l2j.gameserver.model.L2World;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.serverpackets.AskJoinPledge;
  22. import net.sf.l2j.gameserver.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. @Override
  34. protected void readImpl()
  35. {
  36. _target = readD();
  37. _pledgeType = readD();
  38. }
  39. @Override
  40. protected void runImpl()
  41. {
  42. L2PcInstance activeChar = getClient().getActiveChar();
  43. if (activeChar == null)
  44. {
  45. return;
  46. }
  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. {
  57. return;
  58. }
  59. if (!activeChar.getRequest().setRequest(target, this))
  60. {
  61. return;
  62. }
  63. AskJoinPledge ap = new AskJoinPledge(activeChar.getObjectId(), activeChar.getClan().getName());
  64. target.sendPacket(ap);
  65. }
  66. public int getPledgeType()
  67. {
  68. return _pledgeType;
  69. }
  70. /* (non-Javadoc)
  71. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  72. */
  73. @Override
  74. public String getType()
  75. {
  76. return _C__24_REQUESTJOINPLEDGE;
  77. }
  78. }