RequestAllyInfo.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import com.l2jserver.gameserver.model.ClanInfo;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.network.SystemMessageId;
  23. import com.l2jserver.gameserver.network.serverpackets.AllianceInfo;
  24. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  25. /**
  26. * This class ...
  27. * @version $Revision: 1479 $ $Date: 2005-11-09 00:47:42 +0100 (mer., 09 nov. 2005) $
  28. */
  29. public final class RequestAllyInfo extends L2GameClientPacket
  30. {
  31. private static final String _C__2E_REQUESTALLYINFO = "[C] 2E RequestAllyInfo";
  32. @Override
  33. public void readImpl()
  34. {
  35. }
  36. @Override
  37. protected void runImpl()
  38. {
  39. final L2PcInstance activeChar = getClient().getActiveChar();
  40. if (activeChar == null)
  41. {
  42. return;
  43. }
  44. SystemMessage sm;
  45. final int allianceId = activeChar.getAllyId();
  46. if (allianceId > 0)
  47. {
  48. final AllianceInfo ai = new AllianceInfo(allianceId);
  49. activeChar.sendPacket(ai);
  50. // send for player
  51. sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_INFO_HEAD);
  52. activeChar.sendPacket(sm);
  53. sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_NAME_S1);
  54. sm.addString(ai.getName());
  55. activeChar.sendPacket(sm);
  56. sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_LEADER_S2_OF_S1);
  57. sm.addString(ai.getLeaderC());
  58. sm.addString(ai.getLeaderP());
  59. activeChar.sendPacket(sm);
  60. sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
  61. sm.addInt(ai.getOnline());
  62. sm.addInt(ai.getTotal());
  63. activeChar.sendPacket(sm);
  64. sm = SystemMessage.getSystemMessage(SystemMessageId.ALLIANCE_CLAN_TOTAL_S1);
  65. sm.addInt(ai.getAllies().length);
  66. activeChar.sendPacket(sm);
  67. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_HEAD);
  68. for (final ClanInfo aci : ai.getAllies())
  69. {
  70. activeChar.sendPacket(sm);
  71. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_NAME_S1);
  72. sm.addString(aci.getClan().getName());
  73. activeChar.sendPacket(sm);
  74. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_LEADER_S1);
  75. sm.addString(aci.getClan().getLeaderName());
  76. activeChar.sendPacket(sm);
  77. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_LEVEL_S1);
  78. sm.addInt(aci.getClan().getLevel());
  79. activeChar.sendPacket(sm);
  80. sm = SystemMessage.getSystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
  81. sm.addInt(aci.getOnline());
  82. sm.addInt(aci.getTotal());
  83. activeChar.sendPacket(sm);
  84. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_SEPARATOR);
  85. }
  86. sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_INFO_FOOT);
  87. activeChar.sendPacket(sm);
  88. }
  89. else
  90. {
  91. activeChar.sendPacket(SystemMessageId.NO_CURRENT_ALLIANCES);
  92. }
  93. }
  94. @Override
  95. public String getType()
  96. {
  97. return _C__2E_REQUESTALLYINFO;
  98. }
  99. }