RequestJoinAlly.java 2.7 KB

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