123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /*
- * Copyright (C) 2004-2015 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package com.l2jserver.gameserver.network.serverpackets;
- import java.util.Collection;
- import com.l2jserver.gameserver.data.sql.impl.ClanTable;
- import com.l2jserver.gameserver.model.ClanInfo;
- import com.l2jserver.gameserver.model.L2Clan;
- import com.l2jserver.gameserver.network.clientpackets.RequestAllyInfo;
- /**
- * Sent in response to {@link RequestAllyInfo}, if applicable.<BR>
- * @author afk5min
- */
- public class AllianceInfo extends L2GameServerPacket
- {
- private final String _name;
- private final int _total;
- private final int _online;
- private final String _leaderC;
- private final String _leaderP;
- private final ClanInfo[] _allies;
-
- public AllianceInfo(int allianceId)
- {
- final L2Clan leader = ClanTable.getInstance().getClan(allianceId);
- _name = leader.getAllyName();
- _leaderC = leader.getName();
- _leaderP = leader.getLeaderName();
-
- final Collection<L2Clan> allies = ClanTable.getInstance().getClanAllies(allianceId);
- _allies = new ClanInfo[allies.size()];
- int idx = 0, total = 0, online = 0;
- for (final L2Clan clan : allies)
- {
- final ClanInfo ci = new ClanInfo(clan);
- _allies[idx++] = ci;
- total += ci.getTotal();
- online += ci.getOnline();
- }
-
- _total = total;
- _online = online;
- }
-
- @Override
- protected void writeImpl()
- {
- writeC(0xB5);
-
- writeS(_name);
- writeD(_total);
- writeD(_online);
- writeS(_leaderC);
- writeS(_leaderP);
-
- writeD(_allies.length);
- for (final ClanInfo aci : _allies)
- {
- writeS(aci.getClan().getName());
- writeD(0x00);
- writeD(aci.getClan().getLevel());
- writeS(aci.getClan().getLeaderName());
- writeD(aci.getTotal());
- writeD(aci.getOnline());
- }
- }
-
- public String getName()
- {
- return _name;
- }
-
- public int getTotal()
- {
- return _total;
- }
-
- public int getOnline()
- {
- return _online;
- }
-
- public String getLeaderC()
- {
- return _leaderC;
- }
-
- public String getLeaderP()
- {
- return _leaderP;
- }
-
- public ClanInfo[] getAllies()
- {
- return _allies;
- }
- }
|