/* * Copyright (C) 2004-2014 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 . */ package com.l2jserver.gameserver.communitybbs.Manager; import java.util.StringTokenizer; import com.l2jserver.gameserver.datatables.ClanTable; import com.l2jserver.gameserver.model.L2Clan; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.SystemMessageId; import com.l2jserver.util.StringUtil; public class ClanBBSManager extends BaseBBSManager { public static ClanBBSManager getInstance() { return SingletonHolder._instance; } /** * @param command * @param activeChar */ @Override public void parsecmd(String command, L2PcInstance activeChar) { if (command.equals("_bbsclan")) { if ((activeChar.getClan() == null) || (activeChar.getClan().getLevel() < 2)) { clanlist(activeChar, 1); } else { clanhome(activeChar); } } 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 if (command.startsWith("_bbsclan_clannotice_edit;")) { clanNotice(activeChar, activeChar.getClanId()); } else if (command.startsWith("_bbsclan_clannotice_enable")) { if (activeChar.getClan() != null) { activeChar.getClan().setNoticeEnabled(true); } clanNotice(activeChar, activeChar.getClanId()); } else if (command.startsWith("_bbsclan_clannotice_disable")) { if (activeChar.getClan() != null) { activeChar.getClan().setNoticeEnabled(false); } clanNotice(activeChar, activeChar.getClanId()); } else { separateAndSend("

Command : " + command + " needs core development


", activeChar); } } private void clanNotice(L2PcInstance activeChar, int clanId) { final L2Clan cl = ClanTable.getInstance().getClan(clanId); if (cl != null) { if (cl.getLevel() < 2) { activeChar.sendPacket(SystemMessageId.NO_CB_IN_MY_CLAN); parsecmd("_bbsclan_clanlist", activeChar); } else { final StringBuilder html = StringUtil.startAppend(2000, "

HOME > CLAN COMMUNITY > &$802;
"); if (activeChar.isClanLeader()) { StringUtil.append(html, "

"); if (activeChar.getClan().isNoticeEnabled()) { StringUtil.append(html, "
The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.
Clan Notice Function:   on   /   off"); } else { StringUtil.append(html, "
Clan Notice Function:   on   /   off"); } StringUtil.append(html, "


Edit Notice:

"); send1001(html.toString(), activeChar); send1002(activeChar, activeChar.getClan().getNotice(), " ", "0"); } else { StringUtil.append(html, "
You are not your clan's leader, and therefore cannot change the clan notice
"); if (activeChar.getClan().isNoticeEnabled()) { StringUtil.append(html, "
The current clan notice:
" + activeChar.getClan().getNotice() + "
"); } StringUtil.append(html, "
"); separateAndSend(html.toString(), activeChar); } } } } /** * @param activeChar * @param index */ private void clanlist(L2PcInstance activeChar, int index) { if (index < 1) { index = 1; } // header final StringBuilder html = StringUtil.startAppend(2000, "

  CLAN COMMUNITY
[GO TO MY CLAN]  

CLAN NAMECLAN LEADERCLAN LEVELCLAN MEMBERS
"); int i = 0; for (L2Clan cl : ClanTable.getInstance().getClans()) { if (i > ((index + 1) * 7)) { break; } if (i++ >= ((index - 1) * 7)) { StringUtil.append(html, "
", cl.getName(), "", cl.getLeaderName(), "", String.valueOf(cl.getLevel()), "", String.valueOf(cl.getMembersCount()), "
"); } } html.append(""); if (index == 1) { html.append(""); } else { StringUtil.append(html, ""); } 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) { StringUtil.append(html, ""); } else { StringUtil.append(html, ""); } } if (index == nbp) { html.append(""); } else { StringUtil.append(html, ""); } html.append("
", String.valueOf(i), " ", String.valueOf(i), "
" + // TODO: search (Write in BBS) "


"); separateAndSend(html.toString(), activeChar); } /** * @param activeChar */ private void clanhome(L2PcInstance activeChar) { clanhome(activeChar, activeChar.getClan().getId()); } private static class SingletonHolder { protected static final ClanBBSManager _instance = new ClanBBSManager(); } /** * @param activeChar * @param clanId */ private void clanhome(L2PcInstance activeChar, int clanId) { L2Clan cl = ClanTable.getInstance().getClan(clanId); if (cl != null) { if (cl.getLevel() < 2) { activeChar.sendPacket(SystemMessageId.NO_CB_IN_MY_CLAN); parsecmd("_bbsclan_clanlist", activeChar); } else { final String html = StringUtil.concat("


 HOME > CLAN COMMUNITY > &$802;
[CLAN ANNOUNCEMENT] [CLAN BULLETIN BOARD][CLAN MAIL]  [CLAN NOTICE]  
" + // ADMINISTRATOR ?? /* * html.append(""); html.append(""); html.append(""); html.append(""); */ "
CLAN NAME", cl.getName(), "
CLAN LEVEL", String.valueOf(cl.getLevel()), "
CLAN MEMBERS", String.valueOf(cl.getMembersCount()), "
CLAN LEADER", cl.getLeaderName(), "
ADMINISTRATOR"+cl.getLeaderName()+"
ALLIANCE", (cl.getAllyName() != null) ? cl.getAllyName() : "", "
" + // TODO: the BB for clan :) // html.append(""); "


"); separateAndSend(html, activeChar); } } } @Override public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar) { if (ar1.equals("Set")) { activeChar.getClan().setNotice(ar4); parsecmd("_bbsclan_clanhome;" + activeChar.getClan().getId(), activeChar); } } }