RequestJoinAlly.java 2.7 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.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.AskJoinAlly;
  21. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  22. /**
  23. * This class ...
  24. *
  25. * @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:30 $
  26. */
  27. public final class RequestJoinAlly extends L2GameClientPacket
  28. {
  29. private static final String _C__82_REQUESTJOINALLY = "[C] 82 RequestJoinAlly";
  30. //private static Logger _log = Logger.getLogger(RequestJoinAlly.class.getName());
  31. private int _id;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _id = readD();
  36. }
  37. @Override
  38. protected void runImpl()
  39. {
  40. L2PcInstance activeChar = getClient().getActiveChar();
  41. if (activeChar == null)
  42. {
  43. return;
  44. }
  45. L2PcInstance ob = L2World.getInstance().getPlayer(_id);
  46. if (ob == null)
  47. {
  48. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
  49. return;
  50. }
  51. if(activeChar.getClan() == null)
  52. {
  53. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
  54. return;
  55. }
  56. L2PcInstance target = ob;
  57. L2Clan clan = activeChar.getClan();
  58. if (!clan.checkAllyJoinCondition(activeChar, target))
  59. {
  60. return;
  61. }
  62. if (!activeChar.getRequest().setRequest(target, this))
  63. {
  64. return;
  65. }
  66. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_ALLIANCE_LEADER_OF_S1_REQUESTED_ALLIANCE);
  67. sm.addString(activeChar.getClan().getAllyName());
  68. sm.addString(activeChar.getName());
  69. target.sendPacket(sm);
  70. sm = null;
  71. AskJoinAlly aja = new AskJoinAlly(activeChar.getObjectId(), activeChar.getClan().getAllyName());
  72. target.sendPacket(aja);
  73. }
  74. @Override
  75. public String getType()
  76. {
  77. return _C__82_REQUESTJOINALLY;
  78. }
  79. }