/*
* This program 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.
*
* This program 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 .
*/
package net.sf.l2j.gameserver.communitybbs.Manager;
import java.util.StringTokenizer;
import javolution.text.TextBuilder;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
public class ClanBBSManager extends BaseBBSManager
{
private static ClanBBSManager _instance = new ClanBBSManager();
/**
* @return
*/
public static ClanBBSManager getInstance()
{
return _instance;
}
/**
* @param command
* @param activeChar
*/
@Override
public void parsecmd(String command, L2PcInstance activeChar)
{
if (command.equals("_bbsclan"))
{
if (activeChar.getClan() != null)
{
if (activeChar.getClan().getLevel() >= 2)
{
clanhome(activeChar);
}
else
{
clanlist(activeChar, 1);
}
}
else
{
clanlist(activeChar, 1);
}
}
else if (command.startsWith("_bbsclan_clanlist"))
{
if (command.equals("_bbsclan_clanlist"))
{
clanlist(activeChar, 1);
}
else if (command.startsWith("_bbsclan_clanlist;"))
{
StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
int index = Integer.parseInt(st.nextToken());
clanlist(activeChar, index);
}
}
else if (command.startsWith("_bbsclan_clanhome"))
{
if (command.equals("_bbsclan_clanhome"))
{
clanhome(activeChar);
}
else if (command.startsWith("_bbsclan_clanhome;"))
{
StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
int index = Integer.parseInt(st.nextToken());
clanhome(activeChar, index);
}
}
else
{
separateAndSend("
Commande : " + command
+ " pas encore implante
", activeChar);
}
}
/**
* @param activeChar
*/
private void clanlist(L2PcInstance activeChar, int index)
{
if (index < 1)
{
index = 1;
}
//header
TextBuilder html = new TextBuilder("
");
}
i = 0;
int nbp;
nbp = ClanTable.getInstance().getClans().length / 8;
if (nbp * 8 != ClanTable.getInstance().getClans().length)
{
nbp++;
}
for (i = 1; i <= nbp; i++)
{
if (i == index)
{
html.append("