AllyInfo.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.serverpackets;
  16. import com.l2jserver.gameserver.datatables.ClanTable;
  17. import com.l2jserver.gameserver.model.L2Clan;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.SystemMessageId;
  20. /**
  21. */
  22. public class AllyInfo extends L2GameServerPacket
  23. {
  24. //private static Logger _log = Logger.getLogger(AllyInfo.class.getName());
  25. private static final String _S__B5_ALLYINFO = "[S] b5 AllyInfo";
  26. private static L2PcInstance _cha ;
  27. public AllyInfo(L2PcInstance cha)
  28. {
  29. _cha = cha;
  30. }
  31. @Override
  32. protected final void writeImpl()
  33. {
  34. L2PcInstance activeChar = getClient().getActiveChar();
  35. if (activeChar == null) return;
  36. if (activeChar.getAllyId() == 0)
  37. {
  38. _cha.sendPacket(new SystemMessage(SystemMessageId.NO_CURRENT_ALLIANCES));
  39. return;
  40. }
  41. //======<AllyInfo>======
  42. SystemMessage sm = new SystemMessage(SystemMessageId.ALLIANCE_INFO_HEAD);
  43. _cha.sendPacket(sm);
  44. //======<Ally Name>======
  45. sm = new SystemMessage(SystemMessageId.ALLIANCE_NAME_S1);
  46. sm.addString(_cha.getClan().getAllyName());
  47. _cha.sendPacket(sm);
  48. int online = 0;
  49. int count = 0;
  50. int clancount = 0;
  51. for (L2Clan clan : ClanTable.getInstance().getClans()){
  52. if (clan.getAllyId() == _cha.getAllyId()){
  53. clancount++;
  54. online+=clan.getOnlineMembers(0).length;
  55. count+=clan.getMembers().length;
  56. }
  57. }
  58. //Connection
  59. sm = new SystemMessage(SystemMessageId.CONNECTION_S1_TOTAL_S2);
  60. sm.addString(""+online);
  61. sm.addString(""+count);
  62. _cha.sendPacket(sm);
  63. L2Clan leaderclan = ClanTable.getInstance().getClan(_cha.getAllyId());
  64. sm = new SystemMessage(SystemMessageId.ALLIANCE_LEADER_S2_OF_S1);
  65. sm.addString(leaderclan.getName());
  66. sm.addString(leaderclan.getLeaderName());
  67. _cha.sendPacket(sm);
  68. //clan count
  69. sm = new SystemMessage(SystemMessageId.ALLIANCE_CLAN_TOTAL_S1);
  70. sm.addString(""+clancount);
  71. _cha.sendPacket(sm);
  72. //clan information
  73. sm = new SystemMessage(SystemMessageId.CLAN_INFO_HEAD);
  74. _cha.sendPacket(sm);
  75. for (L2Clan clan : ClanTable.getInstance().getClans()){
  76. if (clan.getAllyId() == _cha.getAllyId()){
  77. //clan name
  78. sm = new SystemMessage(SystemMessageId.CLAN_INFO_NAME);
  79. sm.addString(clan.getName());
  80. _cha.sendPacket(sm);
  81. //clan leader name
  82. sm = new SystemMessage(SystemMessageId.CLAN_INFO_LEADER);
  83. sm.addString(clan.getLeaderName());
  84. _cha.sendPacket(sm);
  85. //clan level
  86. sm = new SystemMessage(SystemMessageId.CLAN_INFO_LEVEL);
  87. sm.addNumber(clan.getLevel());
  88. _cha.sendPacket(sm);
  89. //---------
  90. sm = new SystemMessage(SystemMessageId.CLAN_INFO_SEPARATOR);
  91. _cha.sendPacket(sm);
  92. }
  93. }
  94. //=========================
  95. sm = new SystemMessage(SystemMessageId.CLAN_INFO_FOOT);
  96. _cha.sendPacket(sm);
  97. }
  98. /* (non-Javadoc)
  99. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  100. */
  101. @Override
  102. public String getType()
  103. {
  104. return _S__B5_ALLYINFO;
  105. }
  106. }