actual freya branch
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
|
||||
public class AdminBBSManager extends BaseBBSManager
|
||||
{
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static AdminBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private AdminBBSManager()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (!activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("admin_bbs"))
|
||||
{
|
||||
separateAndSend("<html><body><br><br><center>This Page is only an exemple :)<br><br>command=" + command + "</center></body></html>", activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
if (!activeChar.isGM())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AdminBBSManager _instance = new AdminBBSManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
|
||||
public abstract class BaseBBSManager
|
||||
{
|
||||
public abstract void parsecmd(String command, L2PcInstance activeChar);
|
||||
|
||||
public abstract void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar);
|
||||
|
||||
protected void separateAndSend(String html, L2PcInstance acha)
|
||||
{
|
||||
if (html == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (html.length() < 4090)
|
||||
{
|
||||
acha.sendPacket(new ShowBoard(html, "101"));
|
||||
acha.sendPacket(new ShowBoard(null, "102"));
|
||||
acha.sendPacket(new ShowBoard(null, "103"));
|
||||
|
||||
}
|
||||
else if (html.length() < 8180)
|
||||
{
|
||||
acha.sendPacket(new ShowBoard(html.substring(0, 4090), "101"));
|
||||
acha.sendPacket(new ShowBoard(html.substring(4090, html.length()), "102"));
|
||||
acha.sendPacket(new ShowBoard(null, "103"));
|
||||
|
||||
}
|
||||
else if (html.length() < 12270)
|
||||
{
|
||||
acha.sendPacket(new ShowBoard(html.substring(0, 4090), "101"));
|
||||
acha.sendPacket(new ShowBoard(html.substring(4090, 8180), "102"));
|
||||
acha.sendPacket(new ShowBoard(html.substring(8180, html.length()), "103"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param html
|
||||
*/
|
||||
protected void send1001(String html, L2PcInstance acha)
|
||||
{
|
||||
if (html.length() < 8180)
|
||||
{
|
||||
acha.sendPacket(new ShowBoard(html, "1001"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
*/
|
||||
protected void send1002(L2PcInstance acha)
|
||||
{
|
||||
send1002(acha, " ", " ", "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param string
|
||||
* @param string2
|
||||
*/
|
||||
protected void send1002(L2PcInstance activeChar, String string, String string2, String string3)
|
||||
{
|
||||
List<String> _arg = new FastList<>();
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
_arg.add(activeChar.getName());
|
||||
_arg.add(Integer.toString(activeChar.getObjectId()));
|
||||
_arg.add(activeChar.getAccountName());
|
||||
_arg.add("9");
|
||||
_arg.add(string2);
|
||||
_arg.add(string2);
|
||||
_arg.add(string);
|
||||
_arg.add(string3);
|
||||
_arg.add(string3);
|
||||
_arg.add("0");
|
||||
_arg.add("0");
|
||||
activeChar.sendPacket(new ShowBoard(_arg));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class ClanBBSManager extends BaseBBSManager
|
||||
{
|
||||
private ClanBBSManager()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
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.getClan().getClanId());
|
||||
}
|
||||
else if (command.startsWith("_bbsclan_clannotice_enable"))
|
||||
{
|
||||
activeChar.getClan().setNoticeEnabled(true);
|
||||
clanNotice(activeChar, activeChar.getClan().getClanId());
|
||||
}
|
||||
else if (command.startsWith("_bbsclan_clannotice_disable"))
|
||||
{
|
||||
activeChar.getClan().setNoticeEnabled(false);
|
||||
clanNotice(activeChar, activeChar.getClan().getClanId());
|
||||
}
|
||||
else
|
||||
{
|
||||
separateAndSend("<html><body><br><br><center>Command : " + command + " needs core development</center><br><br></body></html>", activeChar);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void clanNotice(L2PcInstance activeChar, int clanId)
|
||||
{
|
||||
L2Clan cl = ClanTable.getInstance().getClan(clanId);
|
||||
if (cl != null)
|
||||
{
|
||||
if (cl.getLevel() < 2)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_CB_IN_MY_CLAN));
|
||||
parsecmd("_bbsclan_clanlist", activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br>" + "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > " + "<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> > " + "<a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &$802; </a>" + "</td></tr>" + "</table>");
|
||||
if (activeChar.isClanLeader())
|
||||
{
|
||||
StringUtil.append(html, "<br><br><center>" + "<table width=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td fixwidth=610><font color=\"AAAAAA\">The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.</font> </td></tr>" + "<tr><td height=20></td></tr>");
|
||||
|
||||
if (activeChar.getClan().isNoticeEnabled())
|
||||
{
|
||||
StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function: on / <a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function: <a action=\"bypass _bbsclan_clannotice_enable\">on</a> / off");
|
||||
}
|
||||
|
||||
StringUtil.append(html, "</td></tr>" + "</table>" + "<img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\">" + "<br> <br>" + "<table width=610 border=0 cellspacing=2 cellpadding=0>" + "<tr><td>Edit Notice: </td></tr>" + "<tr><td height=5></td></tr>" + "<tr><td>" + "<MultiEdit var =\"Content\" width=610 height=100>" + "</td></tr>" + "</table>" + "<br>" + "<table width=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td height=5></td></tr>" + "<tr>" + "<td align=center FIXWIDTH=65><button value=\"&$140;\" action=\"Write Notice Set _ Content Content Content\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>" + "<td align=center FIXWIDTH=45></td>" + "<td align=center FIXWIDTH=500></td>" + "</tr>" + "</table>" + "</center>" + "</body>" + "</html>");
|
||||
send1001(html.toString(), activeChar);
|
||||
send1002(activeChar, activeChar.getClan().getNotice(), " ", "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>" + "<table border=0 cellspacing=0 cellpadding=0><tr>" + "<td>You are not your clan's leader, and therefore cannot change the clan notice</td>" + "</tr></table>");
|
||||
if (activeChar.getClan().isNoticeEnabled())
|
||||
{
|
||||
StringUtil.append(html, "<table border=0 cellspacing=0 cellpadding=0>" + "<tr>" + "<td>The current clan notice:</td>" + "</tr>" + "<tr><td fixwidth=5></td>" + "<td FIXWIDTH=600 align=left>" + activeChar.getClan().getNotice() + "</td>" + "<td fixqqwidth=5></td>" + "</tr>" + "</table>");
|
||||
}
|
||||
StringUtil.append(html, "</center>" + "</body>" + "</html>");
|
||||
separateAndSend(html.toString(), activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void clanlist(L2PcInstance activeChar, int index)
|
||||
{
|
||||
if (index < 1)
|
||||
{
|
||||
index = 1;
|
||||
}
|
||||
|
||||
// header
|
||||
final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br><center>" + "<br1><br1><table border=0 cellspacing=0 cellpadding=0>" + "<tr><td FIXWIDTH=15> </td>" + "<td width=610 height=30 align=left>" + "<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>" + "</td></tr></table>" + "<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>" + "<tr><td height=10></td></tr>" + "<tr>" + "<td fixWIDTH=5></td>" + "<td fixWIDTH=600>" + "<a action=\"bypass _bbsclan_clanhome;", String.valueOf((activeChar.getClan() != null) ? activeChar.getClan().getClanId() : 0), "\">[GO TO MY CLAN]</a> " + "</td>" + "<td fixWIDTH=5></td>" + "</tr>" + "<tr><td height=10></td></tr>" + "</table>" + "<br>" + "<table border=0 cellspacing=0 cellpadding=2 bgcolor=5A5A5A width=610>" + "<tr>" + "<td FIXWIDTH=5></td>" + "<td FIXWIDTH=200 align=center>CLAN NAME</td>" + "<td FIXWIDTH=200 align=center>CLAN LEADER</td>" + "<td FIXWIDTH=100 align=center>CLAN LEVEL</td>" + "<td FIXWIDTH=100 align=center>CLAN MEMBERS</td>" + "<td FIXWIDTH=5></td>" + "</tr>" + "</table>" + "<img src=\"L2UI.Squareblank\" width=\"1\" height=\"5\">");
|
||||
|
||||
int i = 0;
|
||||
for (L2Clan cl : ClanTable.getInstance().getClans())
|
||||
{
|
||||
if (i > ((index + 1) * 7))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (i++ >= ((index - 1) * 7))
|
||||
{
|
||||
StringUtil.append(html, "<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">" + "<table border=0 cellspacing=0 cellpadding=0 width=610>" + "<tr> " + "<td FIXWIDTH=5></td>" + "<td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;", String.valueOf(cl.getClanId()), "\">", cl.getName(), "</a></td>" + "<td FIXWIDTH=200 align=center>", cl.getLeaderName(), "</td>" + "<td FIXWIDTH=100 align=center>", String.valueOf(cl.getLevel()), "</td>" + "<td FIXWIDTH=100 align=center>", String.valueOf(cl.getMembersCount()), "</td>" + "<td FIXWIDTH=5></td>" + "</tr>" + "<tr><td height=5></td></tr>" + "</table>" + "<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">" + "<img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
|
||||
}
|
||||
}
|
||||
|
||||
html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"2\">" + "<table cellpadding=0 cellspacing=2 border=0><tr>");
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
html.append("<td><button action=\"\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><button action=\"_bbsclan_clanlist;", String.valueOf(index - 1), "\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
|
||||
}
|
||||
|
||||
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, "<td> ", String.valueOf(i), " </td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><a action=\"bypass _bbsclan_clanlist;", String.valueOf(i), "\"> ", String.valueOf(i), " </a></td>");
|
||||
}
|
||||
|
||||
}
|
||||
if (index == nbp)
|
||||
{
|
||||
html.append("<td><button action=\"\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><button action=\"bypass _bbsclan_clanlist;", String.valueOf(index + 1), "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
|
||||
}
|
||||
html.append("</tr></table>" + "<table border=0 cellspacing=0 cellpadding=0>" + "<tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr>" + "</table>" + "<table border=0><tr><td><combobox width=65 var=keyword list=\"Name;Ruler\"></td><td><edit var = \"Search\" width=130 height=11 length=\"16\"></td>" +
|
||||
// TODO: search (Write in BBS)
|
||||
"<td><button value=\"&$420;\" action=\"Write 5 -1 0 Search keyword keyword\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td> </tr></table>" + "<br>" + "<br>" + "</center>" + "</body>" + "</html>");
|
||||
separateAndSend(html.toString(), activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void clanhome(L2PcInstance activeChar)
|
||||
{
|
||||
clanhome(activeChar, activeChar.getClan().getClanId());
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.NO_CB_IN_MY_CLAN));
|
||||
parsecmd("_bbsclan_clanlist", activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String html = StringUtil.concat("<html><body><center><br><br>" + "<br1><br1><table border=0 cellspacing=0 cellpadding=0>" + "<tr><td FIXWIDTH=15> </td>" + "<td width=610 height=30 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> > <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &$802; </a>" + "</td></tr></table>" + "<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>" + "<tr><td height=10></td></tr>" + "<tr>" + "<td fixWIDTH=5></td>" + "<td fixwidth=600>" + "<a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";cbb\">[CLAN BULLETIN BOARD]</a>" + "<a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), ";cmail\">[CLAN MAIL]</a> " + "<a action=\"bypass _bbsclan_clannotice_edit;", String.valueOf(clanId), ";cnotice\">[CLAN NOTICE]</a> " + "</td>" + "<td fixWIDTH=5></td>" + "</tr>" + "<tr><td height=10></td></tr>" + "</table>" + "<table border=0 cellspacing=0 cellpadding=0 width=610>" + "<tr><td height=10></td></tr>" + "<tr><td fixWIDTH=5></td>" + "<td fixwidth=290 valign=top>" + "</td>" + "<td fixWIDTH=5></td>" + "<td fixWIDTH=5 align=center valign=top><img src=\"l2ui.squaregray\" width=2 height=128></td>" + "<td fixWIDTH=5></td>" + "<td fixwidth=295>" + "<table border=0 cellspacing=0 cellpadding=0 width=295>" + "<tr>" + "<td fixWIDTH=100 align=left>CLAN NAME</td>" + "<td fixWIDTH=195 align=left>", cl.getName(), "</td>" + "</tr>" + "<tr><td height=7></td></tr>" + "<tr>" + "<td fixWIDTH=100 align=left>CLAN LEVEL</td>" + "<td fixWIDTH=195 align=left height=16>", String.valueOf(cl.getLevel()), "</td>" + "</tr>" + "<tr><td height=7></td></tr>" + "<tr>" + "<td fixWIDTH=100 align=left>CLAN MEMBERS</td>" + "<td fixWIDTH=195 align=left height=16>", String.valueOf(cl.getMembersCount()), "</td>" + "</tr>" + "<tr><td height=7></td></tr>" + "<tr>" + "<td fixWIDTH=100 align=left>CLAN LEADER</td>" + "<td fixWIDTH=195 align=left height=16>", cl.getLeaderName(), "</td>" + "</tr>" + "<tr><td height=7></td></tr>" +
|
||||
// ADMINISTRATOR ??
|
||||
/*
|
||||
* html.append("<tr>"); html.append("<td fixWIDTH=100 align=left>ADMINISTRATOR</td>"); html.append("<td fixWIDTH=195 align=left height=16>"+cl.getLeaderName()+"</td>"); html.append("</tr>");
|
||||
*/
|
||||
"<tr><td height=7></td></tr>" + "<tr>" + "<td fixWIDTH=100 align=left>ALLIANCE</td>" + "<td fixWIDTH=195 align=left height=16>", (cl.getAllyName() != null) ? cl.getAllyName() : "", "</td>" + "</tr>" + "</table>" + "</td>" + "<td fixWIDTH=5></td>" + "</tr>" + "<tr><td height=10></td></tr>" + "</table>" +
|
||||
// TODO: the BB for clan :)
|
||||
// html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=333333>");
|
||||
"<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">" + "<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">" + "<br>" + "</center>" + "<br> <br>" + "</body>" + "</html>");
|
||||
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().getClanId(), activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Forum;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class ForumsBBSManager extends BaseBBSManager
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(ForumsBBSManager.class.getName());
|
||||
private final List<Forum> _table;
|
||||
private int _lastid = 1;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static ForumsBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private ForumsBBSManager()
|
||||
{
|
||||
_table = new FastList<>();
|
||||
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_type=0");
|
||||
ResultSet result = statement.executeQuery();
|
||||
while (result.next())
|
||||
{
|
||||
int forumId = result.getInt("forum_id");
|
||||
Forum f = new Forum(forumId, null);
|
||||
addForum(f);
|
||||
}
|
||||
result.close();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Data error on Forum (root): " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
public void initRoot()
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
f.vload();
|
||||
}
|
||||
_log.info("Loaded " + _table.size() + " forums. Last forum id used: " + _lastid);
|
||||
}
|
||||
|
||||
public void addForum(Forum ff)
|
||||
{
|
||||
if (ff == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_table.add(ff);
|
||||
|
||||
if (ff.getID() > _lastid)
|
||||
{
|
||||
_lastid = ff.getID();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public Forum getForumByName(String Name)
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
if (f.getName().equals(Name))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param forumByName
|
||||
* @return
|
||||
*/
|
||||
public Forum createNewForum(String name, Forum parent, int type, int perm, int oid)
|
||||
{
|
||||
Forum forum = new Forum(name, parent, type, perm, oid);
|
||||
forum.insertIntoDb();
|
||||
return forum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getANewID()
|
||||
{
|
||||
return ++_lastid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param idf
|
||||
* @return
|
||||
*/
|
||||
public Forum getForumByID(int idf)
|
||||
{
|
||||
for (Forum f : _table)
|
||||
{
|
||||
if (f.getID() == idf)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ForumsBBSManager _instance = new ForumsBBSManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Forum;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Post;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Post.CPost;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Topic;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class PostBBSManager extends BaseBBSManager
|
||||
{
|
||||
|
||||
private final Map<Topic, Post> _postByTopic;
|
||||
|
||||
public static PostBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private PostBBSManager()
|
||||
{
|
||||
_postByTopic = new FastMap<>();
|
||||
}
|
||||
|
||||
public Post getGPosttByTopic(Topic t)
|
||||
{
|
||||
Post post = null;
|
||||
post = _postByTopic.get(t);
|
||||
if (post == null)
|
||||
{
|
||||
post = load(t);
|
||||
_postByTopic.put(t, post);
|
||||
}
|
||||
return post;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param t
|
||||
*/
|
||||
public void delPostByTopic(Topic t)
|
||||
{
|
||||
_postByTopic.remove(t);
|
||||
}
|
||||
|
||||
public void addPostByTopic(Post p, Topic t)
|
||||
{
|
||||
if (_postByTopic.get(t) == null)
|
||||
{
|
||||
_postByTopic.put(t, p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
private Post load(Topic t)
|
||||
{
|
||||
Post p;
|
||||
p = new Post(t);
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("_bbsposts;read;"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
int idp = Integer.parseInt(st.nextToken());
|
||||
String index = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
index = st.nextToken();
|
||||
}
|
||||
int ind = 0;
|
||||
if (index == null)
|
||||
{
|
||||
ind = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ind = Integer.parseInt(index);
|
||||
}
|
||||
|
||||
showPost((TopicBBSManager.getInstance().getTopicByID(idp)), ForumsBBSManager.getInstance().getForumByID(idf), activeChar, ind);
|
||||
}
|
||||
else if (command.startsWith("_bbsposts;edit;"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
int idt = Integer.parseInt(st.nextToken());
|
||||
int idp = Integer.parseInt(st.nextToken());
|
||||
showEditPost((TopicBBSManager.getInstance().getTopicByID(idt)), ForumsBBSManager.getInstance().getForumByID(idf), activeChar, idp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param topic
|
||||
* @param forumByID
|
||||
* @param activeChar
|
||||
* @param idp
|
||||
*/
|
||||
private void showEditPost(Topic topic, Forum forum, L2PcInstance activeChar, int idp)
|
||||
{
|
||||
Post p = getGPosttByTopic(topic);
|
||||
if ((forum == null) || (topic == null) || (p == null))
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>Error, this forum, topic or post does not exit !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
showHtmlEditPost(topic, activeChar, forum, p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param posttByTopic
|
||||
* @param forumByID
|
||||
* @param activeChar
|
||||
* @param ind
|
||||
* @param idf
|
||||
*/
|
||||
private void showPost(Topic topic, Forum forum, L2PcInstance activeChar, int ind)
|
||||
{
|
||||
if ((forum == null) || (topic == null))
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>Error, this forum is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else if (forum.getType() == Forum.MEMO)
|
||||
{
|
||||
showMemoPost(topic, activeChar, forum);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + forum.getName() + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param topic
|
||||
* @param activeChar
|
||||
* @param forum
|
||||
* @param p
|
||||
*/
|
||||
private void showHtmlEditPost(Topic topic, L2PcInstance activeChar, Forum forum, Post p)
|
||||
{
|
||||
final String html = StringUtil.concat("<html>" + "<body><br><br>" + "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsmemo\">", forum.getName(), " Form</a>" + "</td></tr>" + "</table>" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>" + "<table border=0 cellspacing=0 cellpadding=0>" + "<tr><td width=610><img src=\"sek.cbui355\" width=\"610\" height=\"1\"><br1><img src=\"sek.cbui355\" width=\"610\" height=\"1\"></td></tr>" + "</table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=20></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29>&$413;</td>" + "<td FIXWIDTH=540>", topic.getName(), "</td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr></table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29 valign=top>&$427;</td>" + "<td align=center FIXWIDTH=540><MultiEdit var =\"Content\" width=535 height=313></td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "</table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29> </td>" + "<td align=center FIXWIDTH=70><button value=\"&$140;\" action=\"Write Post ", String.valueOf(forum.getID()), ";", String.valueOf(topic.getID()), ";0 _ Content Content Content\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>" + "<td align=center FIXWIDTH=70><button value = \"&$141;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td>" + "<td align=center FIXWIDTH=400> </td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr></table>" + "</center>" + "</body>" + "</html>");
|
||||
send1001(html, activeChar);
|
||||
send1002(activeChar, p.getCPost(0).postTxt, topic.getName(), DateFormat.getInstance().format(new Date(topic.getDate())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param topic
|
||||
* @param activeChar
|
||||
* @param forum
|
||||
*/
|
||||
private void showMemoPost(Topic topic, L2PcInstance activeChar, Forum forum)
|
||||
{
|
||||
//
|
||||
Post p = getGPosttByTopic(topic);
|
||||
Locale locale = Locale.getDefault();
|
||||
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
|
||||
|
||||
String mes = p.getCPost(0).postTxt.replace(">", ">");
|
||||
mes = mes.replace("<", "<");
|
||||
mes = mes.replace("\n", "<br1>");
|
||||
|
||||
final String html = StringUtil.concat("<html><body><br><br>" + "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsmemo\">Memo Form</a>" + "</td></tr>" + "</table>" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>" + "<table border=0 cellspacing=0 cellpadding=0 bgcolor=333333>" + "<tr><td height=10></td></tr>" + "<tr>" + "<td fixWIDTH=55 align=right valign=top>&$413; : </td>" + "<td fixWIDTH=380 valign=top>", topic.getName(), "</td>" + "<td fixwidth=5></td>" + "<td fixwidth=50></td>" + "<td fixWIDTH=120></td>" + "</tr>" + "<tr><td height=10></td></tr>" + "<tr>" + "<td align=right><font color=\"AAAAAA\" >&$417; : </font></td>" + "<td><font color=\"AAAAAA\">", topic.getOwnerName() + "</font></td>" + "<td></td>" + "<td><font color=\"AAAAAA\">&$418; :</font></td>" + "<td><font color=\"AAAAAA\">", dateFormat.format(p.getCPost(0).postDate), "</font></td>" + "</tr>" + "<tr><td height=10></td></tr>" + "</table>" + "<br>" + "<table border=0 cellspacing=0 cellpadding=0>" + "<tr>" + "<td fixwidth=5></td>" + "<td FIXWIDTH=600 align=left>", mes, "</td>" + "<td fixqqwidth=5></td>" + "</tr>" + "</table>" + "<br>" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">" + "<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">" + "<table border=0 cellspacing=0 cellpadding=0 FIXWIDTH=610>" + "<tr>" + "<td width=50>" + "<button value=\"&$422;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\">" + "</td>" + "<td width=560 align=right><table border=0 cellspacing=0><tr>" + "<td FIXWIDTH=300></td><td><button value = \"&$424;\" action=\"bypass _bbsposts;edit;", String.valueOf(forum.getID()), ";", String.valueOf(topic.getID()), ";0\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td> " + "<td><button value = \"&$425;\" action=\"bypass _bbstopics;del;", String.valueOf(forum.getID()), ";", String.valueOf(topic.getID()), "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td> " + "<td><button value = \"&$421;\" action=\"bypass _bbstopics;crea;", String.valueOf(forum.getID()), "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td> " + "</tr></table>" + "</td>" + "</tr>" + "</table>" + "<br>" + "<br>" + "<br></center>" + "</body>" + "</html>");
|
||||
separateAndSend(html, activeChar);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
StringTokenizer st = new StringTokenizer(ar1, ";");
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
int idt = Integer.parseInt(st.nextToken());
|
||||
int idp = Integer.parseInt(st.nextToken());
|
||||
|
||||
Forum f = ForumsBBSManager.getInstance().getForumByID(idf);
|
||||
if (f == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + idf + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Topic t = f.getTopic(idt);
|
||||
if (t == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the topic: " + idt + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
CPost cp = null;
|
||||
Post p = getGPosttByTopic(t);
|
||||
if (p != null)
|
||||
{
|
||||
cp = p.getCPost(idp);
|
||||
}
|
||||
if (cp == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the post: " + idp + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getCPost(idp).postTxt = ar4;
|
||||
p.updatetxt(idp);
|
||||
parsecmd("_bbsposts;read;" + f.getID() + ";" + t.getID(), activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PostBBSManager _instance = new PostBBSManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,545 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GameServer;
|
||||
import com.l2jserver.gameserver.model.BlockList;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.base.Experience;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.clientpackets.Say2;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class RegionBBSManager extends BaseBBSManager
|
||||
{
|
||||
private static Logger _logChat = Logger.getLogger("chat");
|
||||
|
||||
private RegionBBSManager()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("_bbsloc"))
|
||||
{
|
||||
showOldCommunity(activeChar, 1);
|
||||
}
|
||||
else if (command.startsWith("_bbsloc;page;"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int page = 0;
|
||||
try
|
||||
{
|
||||
page = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
}
|
||||
|
||||
showOldCommunity(activeChar, page);
|
||||
}
|
||||
else if (command.startsWith("_bbsloc;playerinfo;"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
String name = st.nextToken();
|
||||
|
||||
showOldCommunityPI(activeChar, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.COMMUNITY_TYPE == 1)
|
||||
{
|
||||
showOldCommunity(activeChar, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param name
|
||||
*/
|
||||
private void showOldCommunityPI(L2PcInstance activeChar, String name)
|
||||
{
|
||||
final StringBuilder htmlCode = StringUtil.startAppend(1000, "<html><body><br>" + "<table border=0><tr><td FIXWIDTH=15></td><td align=center>L2J Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(name);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
String sex = "Male";
|
||||
if (player.getAppearance().getSex())
|
||||
{
|
||||
sex = "Female";
|
||||
}
|
||||
String levelApprox = "low";
|
||||
if (player.getLevel() >= 60)
|
||||
{
|
||||
levelApprox = "very high";
|
||||
}
|
||||
else if (player.getLevel() >= 40)
|
||||
{
|
||||
levelApprox = "high";
|
||||
}
|
||||
else if (player.getLevel() >= 20)
|
||||
{
|
||||
levelApprox = "medium";
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<table border=0><tr><td>", player.getName(), " (", sex, " ", player.getTemplate().className, "):</td></tr>" + "<tr><td>Level: ", levelApprox, "</td></tr>" + "<tr><td><br></td></tr>");
|
||||
|
||||
if ((activeChar != null) && (activeChar.isGM() || (player.getObjectId() == activeChar.getObjectId()) || Config.SHOW_LEVEL_COMMUNITYBOARD))
|
||||
{
|
||||
long nextLevelExp = 0;
|
||||
long nextLevelExpNeeded = 0;
|
||||
if (player.getLevel() < (Experience.MAX_LEVEL - 1))
|
||||
{
|
||||
nextLevelExp = Experience.LEVEL[player.getLevel() + 1];
|
||||
nextLevelExpNeeded = nextLevelExp - player.getExp();
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<tr><td>Level: ", String.valueOf(player.getLevel()), "</td></tr>" + "<tr><td>Experience: ", String.valueOf(player.getExp()), "/", String.valueOf(nextLevelExp), "</td></tr>" + "<tr><td>Experience needed for level up: ", String.valueOf(nextLevelExpNeeded), "</td></tr>" + "<tr><td><br></td></tr>");
|
||||
}
|
||||
|
||||
int uptime = (int) player.getUptime() / 1000;
|
||||
int h = uptime / 3600;
|
||||
int m = (uptime - (h * 3600)) / 60;
|
||||
int s = ((uptime - (h * 3600)) - (m * 60));
|
||||
|
||||
StringUtil.append(htmlCode, "<tr><td>Uptime: ", String.valueOf(h), "h ", String.valueOf(m), "m ", String.valueOf(s), "s</td></tr>" + "<tr><td><br></td></tr>");
|
||||
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
StringUtil.append(htmlCode, "<tr><td>Clan: ", player.getClan().getName(), "</td></tr>" + "<tr><td><br></td></tr>");
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<tr><td><multiedit var=\"pm\" width=240 height=40><button value=\"Send PM\" action=\"Write Region PM ", player.getName(), " pm pm pm\" width=110 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><br><button value=\"Back\" action=\"bypass _bbsloc\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>" + "</td></tr></table>" + "</body></html>");
|
||||
separateAndSend(htmlCode.toString(), activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard(StringUtil.concat("<html><body><br><br><center>No player with name ", name, "</center><br><br></body></html>"), "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showOldCommunity(L2PcInstance activeChar, int page)
|
||||
{
|
||||
separateAndSend(getCommunityPage(page, activeChar.isGM() ? "gm" : "pl"), activeChar);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ar1.equals("PM"))
|
||||
{
|
||||
final StringBuilder htmlCode = StringUtil.startAppend(500, "<html><body><br>" + "<table border=0><tr><td FIXWIDTH=15></td><td align=center>L2J Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
L2PcInstance receiver = L2World.getInstance().getPlayer(ar2);
|
||||
if (receiver == null)
|
||||
{
|
||||
StringUtil.append(htmlCode, "Player not found!<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;", ar2, "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "</td></tr></table></body></html>");
|
||||
separateAndSend(htmlCode.toString(), activeChar);
|
||||
return;
|
||||
}
|
||||
if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
|
||||
{
|
||||
activeChar.sendMessage("Player is in jail.");
|
||||
return;
|
||||
}
|
||||
if (receiver.isChatBanned())
|
||||
{
|
||||
activeChar.sendMessage("Player is chat banned.");
|
||||
return;
|
||||
}
|
||||
if (activeChar.isInJail() && Config.JAIL_DISABLE_CHAT)
|
||||
{
|
||||
activeChar.sendMessage("You can not chat while in jail.");
|
||||
return;
|
||||
}
|
||||
if (activeChar.isChatBanned())
|
||||
{
|
||||
activeChar.sendMessage("You are banned from using chat");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.LOG_CHAT)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, ar3);
|
||||
record.setLoggerName("chat");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
"TELL",
|
||||
"[" + activeChar.getName() + " to " + receiver.getName() + "]"
|
||||
});
|
||||
_logChat.log(record);
|
||||
}
|
||||
CreatureSay cs = new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), ar3);
|
||||
if (!receiver.isSilenceMode() && !BlockList.isBlocked(receiver, activeChar))
|
||||
{
|
||||
receiver.sendPacket(cs);
|
||||
activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), Say2.TELL, "->" + receiver.getName(), ar3));
|
||||
StringUtil.append(htmlCode, "Message Sent<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;", receiver.getName(), "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "</td></tr></table></body></html>");
|
||||
separateAndSend(htmlCode.toString(), activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
|
||||
activeChar.sendPacket(sm);
|
||||
parsecmd("_bbsloc;playerinfo;" + receiver.getName(), activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard(StringUtil.concat("<html><body><br><br><center>the command: ", ar1, " is not implemented yet</center><br><br></body></html>"), "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int _onlineCount = 0;
|
||||
private int _onlineCountGm = 0;
|
||||
private static FastMap<Integer, FastList<L2PcInstance>> _onlinePlayers = new FastMap<Integer, FastList<L2PcInstance>>().shared();
|
||||
private static FastMap<Integer, FastMap<String, String>> _communityPages = new FastMap<Integer, FastMap<String, String>>().shared();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static RegionBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
public/* synchronized */void changeCommunityBoard()
|
||||
{
|
||||
FastList<L2PcInstance> sortedPlayers = new FastList<>();
|
||||
sortedPlayers.addAll(L2World.getInstance().getAllPlayers().values());
|
||||
|
||||
Collections.sort(sortedPlayers, (p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()));
|
||||
|
||||
_onlinePlayers.clear();
|
||||
_onlineCount = 0;
|
||||
_onlineCountGm = 0;
|
||||
|
||||
for (L2PcInstance player : sortedPlayers)
|
||||
{
|
||||
addOnlinePlayer(player);
|
||||
}
|
||||
|
||||
_communityPages.clear();
|
||||
writeCommunityPages();
|
||||
}
|
||||
|
||||
private void addOnlinePlayer(L2PcInstance player)
|
||||
{
|
||||
boolean added = false;
|
||||
|
||||
for (FastList<L2PcInstance> page : _onlinePlayers.values())
|
||||
{
|
||||
if (page.size() < Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
|
||||
{
|
||||
if (!page.contains(player))
|
||||
{
|
||||
page.add(player);
|
||||
if (!player.getAppearance().getInvisible())
|
||||
{
|
||||
_onlineCount++;
|
||||
}
|
||||
_onlineCountGm++;
|
||||
}
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
else if (page.contains(player))
|
||||
{
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!added)
|
||||
{
|
||||
FastList<L2PcInstance> temp = new FastList<>();
|
||||
int page = _onlinePlayers.size() + 1;
|
||||
if (temp.add(player))
|
||||
{
|
||||
_onlinePlayers.put(page, temp);
|
||||
if (!player.getAppearance().getInvisible())
|
||||
{
|
||||
_onlineCount++;
|
||||
}
|
||||
_onlineCountGm++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCommunityPages()
|
||||
{
|
||||
final StringBuilder htmlCode = new StringBuilder(2000);
|
||||
final String tdClose = "</td>";
|
||||
final String tdOpen = "<td align=left valign=top>";
|
||||
final String trClose = "</tr>";
|
||||
final String trOpen = "<tr>";
|
||||
final String colSpacer = "<td FIXWIDTH=15></td>";
|
||||
|
||||
for (int page : _onlinePlayers.keySet())
|
||||
{
|
||||
FastMap<String, String> communityPage = new FastMap<>();
|
||||
htmlCode.setLength(0);
|
||||
StringUtil.append(htmlCode, "<html><body><br>" + "<table>" + trOpen + "<td align=left valign=top>Server Restarted: ", String.valueOf(GameServer.dateTimeServerStarted.getTime()), tdClose + trClose + "</table>" + "<table>" + trOpen + tdOpen + "XP Rate: x", String.valueOf(Config.RATE_XP), tdClose + colSpacer + tdOpen + "Party XP Rate: x", String.valueOf(Config.RATE_XP * Config.RATE_PARTY_XP), tdClose + colSpacer + tdOpen + "XP Exponent: ", String.valueOf(Config.ALT_GAME_EXPONENT_XP), tdClose + trClose + trOpen + tdOpen + "SP Rate: x", String.valueOf(Config.RATE_SP), tdClose + colSpacer + tdOpen + "Party SP Rate: x", String.valueOf(Config.RATE_SP * Config.RATE_PARTY_SP), tdClose + colSpacer + tdOpen + "SP Exponent: ", String.valueOf(Config.ALT_GAME_EXPONENT_SP), tdClose + trClose + trOpen + tdOpen + "Drop Rate: ", String.valueOf(Config.RATE_DROP_ITEMS), tdClose + colSpacer + tdOpen + "Spoil Rate: ", String.valueOf(Config.RATE_DROP_SPOIL), tdClose + colSpacer + tdOpen + "Adena Rate: ", String.valueOf(Config.RATE_DROP_ITEMS_ID.get(57)), tdClose + trClose + "</table>" + "<table>" + trOpen + "<td><img src=\"sek.cbui355\" width=600 height=1><br></td>" + trClose + trOpen + tdOpen, String.valueOf(L2World.getInstance().getAllVisibleObjectsCount()), " Object count</td>" + trClose + trOpen + tdOpen, String.valueOf(getOnlineCount("gm")), " Player(s) Online</td>" + trClose + "</table>");
|
||||
|
||||
int cell = 0;
|
||||
if (Config.BBS_SHOW_PLAYERLIST)
|
||||
{
|
||||
htmlCode.append("<table border=0><tr><td><table border=0>");
|
||||
|
||||
for (L2PcInstance player : getOnlinePlayers(page))
|
||||
{
|
||||
cell++;
|
||||
|
||||
if (cell == 1)
|
||||
{
|
||||
htmlCode.append(trOpen);
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;", player.getName(), "\">");
|
||||
|
||||
if (player.isGM())
|
||||
{
|
||||
StringUtil.append(htmlCode, "<font color=\"LEVEL\">", player.getName(), "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlCode.append(player.getName());
|
||||
}
|
||||
|
||||
htmlCode.append("</a></td>");
|
||||
|
||||
if (cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
|
||||
{
|
||||
htmlCode.append(colSpacer);
|
||||
}
|
||||
|
||||
if (cell == Config.NAME_PER_ROW_COMMUNITYBOARD)
|
||||
{
|
||||
cell = 0;
|
||||
htmlCode.append(trClose);
|
||||
}
|
||||
}
|
||||
if ((cell > 0) && (cell < Config.NAME_PER_ROW_COMMUNITYBOARD))
|
||||
{
|
||||
htmlCode.append(trClose);
|
||||
}
|
||||
|
||||
htmlCode.append("</table><br></td></tr>" + trOpen + "<td><img src=\"sek.cbui355\" width=600 height=1><br></td>" + trClose + "</table>");
|
||||
}
|
||||
|
||||
if (getOnlineCount("gm") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
|
||||
{
|
||||
htmlCode.append("<table border=0 width=600><tr>");
|
||||
if (page == 1)
|
||||
{
|
||||
htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(htmlCode, "<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;", String.valueOf(page - 1), "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<td FIXWIDTH=10></td>" + "<td align=center valign=top width=200>Displaying ", String.valueOf(((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1), " - ", String.valueOf(((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size()), " player(s)</td>" + "<td FIXWIDTH=10></td>");
|
||||
if (getOnlineCount("gm") <= (page * Config.NAME_PAGE_SIZE_COMMUNITYBOARD))
|
||||
{
|
||||
htmlCode.append("<td width=190><button value=\"Next\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(htmlCode, "<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;", String.valueOf(page + 1), "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
htmlCode.append("</tr></table>");
|
||||
}
|
||||
|
||||
htmlCode.append("</body></html>");
|
||||
|
||||
communityPage.put("gm", htmlCode.toString());
|
||||
|
||||
htmlCode.setLength(0);
|
||||
StringUtil.append(htmlCode, "<html><body><br>" + "<table>" + trOpen + "<td align=left valign=top>Server Restarted: ", String.valueOf(GameServer.dateTimeServerStarted.getTime()), tdClose + trClose + "</table>" + "<table>" + trOpen + tdOpen + "XP Rate: ", String.valueOf(Config.RATE_XP), tdClose + colSpacer + tdOpen + "Party XP Rate: ", String.valueOf(Config.RATE_PARTY_XP), tdClose + colSpacer + tdOpen + "XP Exponent: ", String.valueOf(Config.ALT_GAME_EXPONENT_XP), tdClose + trClose + trOpen + tdOpen + "SP Rate: ", String.valueOf(Config.RATE_SP), tdClose + colSpacer + tdOpen + "Party SP Rate: ", String.valueOf(Config.RATE_PARTY_SP), tdClose + colSpacer + tdOpen + "SP Exponent: ", String.valueOf(Config.ALT_GAME_EXPONENT_SP), tdClose + trClose + trOpen + tdOpen + "Drop Rate: ", String.valueOf(Config.RATE_DROP_ITEMS), tdClose + colSpacer + tdOpen + "Spoil Rate: ", String.valueOf(Config.RATE_DROP_SPOIL), tdClose + colSpacer + tdOpen + "Adena Rate: ", String.valueOf(Config.RATE_DROP_ITEMS_ID.get(57)), tdClose + trClose + "</table>" + "<table>" + trOpen + "<td><img src=\"sek.cbui355\" width=600 height=1><br></td>" + trClose + trOpen + tdOpen, String.valueOf(getOnlineCount("pl")), " Player(s) Online</td>" + trClose + "</table>");
|
||||
|
||||
if (Config.BBS_SHOW_PLAYERLIST)
|
||||
{
|
||||
htmlCode.append("<table border=0><tr><td><table border=0>");
|
||||
|
||||
cell = 0;
|
||||
for (L2PcInstance player : getOnlinePlayers(page))
|
||||
{
|
||||
if ((player == null) || (player.getAppearance().getInvisible()))
|
||||
{
|
||||
continue; // Go to next
|
||||
}
|
||||
|
||||
cell++;
|
||||
|
||||
if (cell == 1)
|
||||
{
|
||||
htmlCode.append(trOpen);
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;", player.getName(), "\">");
|
||||
|
||||
if (player.isGM())
|
||||
{
|
||||
StringUtil.append(htmlCode, "<font color=\"LEVEL\">", player.getName(), "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlCode.append(player.getName());
|
||||
}
|
||||
|
||||
htmlCode.append("</a></td>");
|
||||
|
||||
if (cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
|
||||
{
|
||||
htmlCode.append(colSpacer);
|
||||
}
|
||||
|
||||
if (cell == Config.NAME_PER_ROW_COMMUNITYBOARD)
|
||||
{
|
||||
cell = 0;
|
||||
htmlCode.append(trClose);
|
||||
}
|
||||
}
|
||||
if ((cell > 0) && (cell < Config.NAME_PER_ROW_COMMUNITYBOARD))
|
||||
{
|
||||
htmlCode.append(trClose);
|
||||
}
|
||||
|
||||
htmlCode.append("</table><br></td></tr>" + trOpen + "<td><img src=\"sek.cbui355\" width=600 height=1><br></td>" + trClose + "</table>");
|
||||
}
|
||||
|
||||
if (getOnlineCount("pl") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
|
||||
{
|
||||
htmlCode.append("<table border=0 width=600><tr>");
|
||||
|
||||
if (page == 1)
|
||||
{
|
||||
htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(htmlCode, "<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;", String.valueOf(page - 1), "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
|
||||
StringUtil.append(htmlCode, "<td FIXWIDTH=10></td>" + "<td align=center valign=top width=200>Displaying ", String.valueOf(((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1), " - ", String.valueOf(((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size()), " player(s)</td>" + "<td FIXWIDTH=10></td>");
|
||||
|
||||
if (getOnlineCount("pl") <= (page * Config.NAME_PAGE_SIZE_COMMUNITYBOARD))
|
||||
{
|
||||
htmlCode.append("<td width=190><button value=\"Next\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(htmlCode, "<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;", String.valueOf(page + 1), "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
|
||||
htmlCode.append("</tr></table>");
|
||||
}
|
||||
|
||||
htmlCode.append("</body></html>");
|
||||
|
||||
communityPage.put("pl", htmlCode.toString());
|
||||
|
||||
_communityPages.put(page, communityPage);
|
||||
}
|
||||
}
|
||||
|
||||
private int getOnlineCount(String type)
|
||||
{
|
||||
if (type.equalsIgnoreCase("gm"))
|
||||
{
|
||||
return _onlineCountGm;
|
||||
}
|
||||
return _onlineCount;
|
||||
}
|
||||
|
||||
private FastList<L2PcInstance> getOnlinePlayers(int page)
|
||||
{
|
||||
return _onlinePlayers.get(page);
|
||||
}
|
||||
|
||||
public String getCommunityPage(int page, String type)
|
||||
{
|
||||
if (_communityPages.get(page) != null)
|
||||
{
|
||||
return _communityPages.get(page).get(type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final RegionBBSManager _instance = new RegionBBSManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
|
||||
public class TopBBSManager extends BaseBBSManager
|
||||
{
|
||||
private TopBBSManager()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("_bbstop"))
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/index.htm");
|
||||
if (content == null)
|
||||
{
|
||||
content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/index.htm' </center></body></html>";
|
||||
}
|
||||
separateAndSend(content, activeChar);
|
||||
}
|
||||
else if (command.equals("_bbshome"))
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/index.htm");
|
||||
if (content == null)
|
||||
{
|
||||
content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/index.htm' </center></body></html>";
|
||||
}
|
||||
separateAndSend(content, activeChar);
|
||||
}
|
||||
else if (command.startsWith("_bbstop;"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
int idp = Integer.parseInt(st.nextToken());
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + idp + ".htm");
|
||||
if (content == null)
|
||||
{
|
||||
content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/" + idp + ".htm' </center></body></html>";
|
||||
}
|
||||
separateAndSend(content, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
}
|
||||
|
||||
public static TopBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final TopBBSManager _instance = new TopBBSManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.communitybbs.Manager;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Forum;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Post;
|
||||
import com.l2jserver.gameserver.communitybbs.BB.Topic;
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class TopicBBSManager extends BaseBBSManager
|
||||
{
|
||||
private final List<Topic> _table;
|
||||
private final Map<Forum, Integer> _maxId;
|
||||
|
||||
public static TopicBBSManager getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private TopicBBSManager()
|
||||
{
|
||||
_table = new FastList<>();
|
||||
_maxId = new FastMap<Forum, Integer>().shared();
|
||||
}
|
||||
|
||||
public void addTopic(Topic tt)
|
||||
{
|
||||
_table.add(tt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param topic
|
||||
*/
|
||||
public void delTopic(Topic topic)
|
||||
{
|
||||
_table.remove(topic);
|
||||
}
|
||||
|
||||
public void setMaxID(int id, Forum f)
|
||||
{
|
||||
_maxId.put(f, id);
|
||||
}
|
||||
|
||||
public int getMaxID(Forum f)
|
||||
{
|
||||
Integer i = _maxId.get(f);
|
||||
if (i == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public Topic getTopicByID(int idf)
|
||||
{
|
||||
for (Topic t : _table)
|
||||
{
|
||||
if (t.getID() == idf)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
|
||||
{
|
||||
if (ar1.equals("crea"))
|
||||
{
|
||||
Forum f = ForumsBBSManager.getInstance().getForumByID(Integer.parseInt(ar2));
|
||||
if (f == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + ar2 + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
f.vload();
|
||||
Topic t = new Topic(Topic.ConstructorType.CREATE, TopicBBSManager.getInstance().getMaxID(f) + 1, Integer.parseInt(ar2), ar5, Calendar.getInstance().getTimeInMillis(), activeChar.getName(), activeChar.getObjectId(), Topic.MEMO, 0);
|
||||
f.addTopic(t);
|
||||
TopicBBSManager.getInstance().setMaxID(t.getID(), f);
|
||||
Post p = new Post(activeChar.getName(), activeChar.getObjectId(), Calendar.getInstance().getTimeInMillis(), t.getID(), f.getID(), ar4);
|
||||
PostBBSManager.getInstance().addPostByTopic(p, t);
|
||||
parsecmd("_bbsmemo", activeChar);
|
||||
}
|
||||
|
||||
}
|
||||
else if (ar1.equals("del"))
|
||||
{
|
||||
Forum f = ForumsBBSManager.getInstance().getForumByID(Integer.parseInt(ar2));
|
||||
if (f == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + ar2 + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Topic t = f.getTopic(Integer.parseInt(ar3));
|
||||
if (t == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the topic: " + ar3 + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// CPost cp = null;
|
||||
Post p = PostBBSManager.getInstance().getGPosttByTopic(t);
|
||||
if (p != null)
|
||||
{
|
||||
p.deleteme(t);
|
||||
}
|
||||
t.deleteme(f);
|
||||
parsecmd("_bbsmemo", activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + ar1 + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
@Override
|
||||
public void parsecmd(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("_bbsmemo"))
|
||||
{
|
||||
showTopics(activeChar.getMemo(), activeChar, 1, activeChar.getMemo().getID());
|
||||
}
|
||||
else if (command.startsWith("_bbstopics;read"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
String index = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
index = st.nextToken();
|
||||
}
|
||||
int ind = 0;
|
||||
if (index == null)
|
||||
{
|
||||
ind = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ind = Integer.parseInt(index);
|
||||
}
|
||||
showTopics(ForumsBBSManager.getInstance().getForumByID(idf), activeChar, ind, idf);
|
||||
}
|
||||
else if (command.startsWith("_bbstopics;crea"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
showNewTopic(ForumsBBSManager.getInstance().getForumByID(idf), activeChar, idf);
|
||||
}
|
||||
else if (command.startsWith("_bbstopics;del"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, ";");
|
||||
st.nextToken();
|
||||
st.nextToken();
|
||||
int idf = Integer.parseInt(st.nextToken());
|
||||
int idt = Integer.parseInt(st.nextToken());
|
||||
Forum f = ForumsBBSManager.getInstance().getForumByID(idf);
|
||||
if (f == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + idf + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Topic t = f.getTopic(idt);
|
||||
if (t == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the topic: " + idt + " does not exist !</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// CPost cp = null;
|
||||
Post p = PostBBSManager.getInstance().getGPosttByTopic(t);
|
||||
if (p != null)
|
||||
{
|
||||
p.deleteme(t);
|
||||
}
|
||||
t.deleteme(f);
|
||||
parsecmd("_bbsmemo", activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forumByID
|
||||
* @param activeChar
|
||||
* @param idf
|
||||
*/
|
||||
private void showNewTopic(Forum forum, L2PcInstance activeChar, int idf)
|
||||
{
|
||||
if (forum == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + idf + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else if (forum.getType() == Forum.MEMO)
|
||||
{
|
||||
showMemoNewTopics(forum, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + forum.getName() + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forum
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMemoNewTopics(Forum forum, L2PcInstance activeChar)
|
||||
{
|
||||
final String html = StringUtil.concat("<html>" + "<body><br><br>" + "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsmemo\">Memo Form</a>" + "</td></tr>" + "</table>" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>" + "<table border=0 cellspacing=0 cellpadding=0>" + "<tr><td width=610><img src=\"sek.cbui355\" width=\"610\" height=\"1\"><br1><img src=\"sek.cbui355\" width=\"610\" height=\"1\"></td></tr>" + "</table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=20></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29>&$413;</td>" + "<td FIXWIDTH=540><edit var = \"Title\" width=540 height=13></td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr></table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29 valign=top>&$427;</td>" + "<td align=center FIXWIDTH=540><MultiEdit var =\"Content\" width=535 height=313></td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "</table>" + "<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "<tr>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "<td align=center FIXWIDTH=60 height=29> </td>" + "<td align=center FIXWIDTH=70><button value=\"&$140;\" action=\"Write Topic crea ", String.valueOf(forum.getID()), " Title Content Title\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>" + "<td align=center FIXWIDTH=70><button value = \"&$141;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td>" + "<td align=center FIXWIDTH=400> </td>" + "<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>" + "</tr></table>" + "</center>" + "</body>" + "</html>");
|
||||
send1001(html, activeChar);
|
||||
send1002(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param memo
|
||||
*/
|
||||
private void showTopics(Forum forum, L2PcInstance activeChar, int index, int idf)
|
||||
{
|
||||
if (forum == null)
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + idf + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
else if (forum.getType() == Forum.MEMO)
|
||||
{
|
||||
showMemoTopics(forum, activeChar, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBoard sb = new ShowBoard("<html><body><br><br><center>the forum: " + forum.getName() + " is not implemented yet</center><br><br></body></html>", "101");
|
||||
activeChar.sendPacket(sb);
|
||||
activeChar.sendPacket(new ShowBoard(null, "102"));
|
||||
activeChar.sendPacket(new ShowBoard(null, "103"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forum
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMemoTopics(Forum forum, L2PcInstance activeChar, int index)
|
||||
{
|
||||
forum.vload();
|
||||
final StringBuilder html = StringUtil.startAppend(2000, "<html><body><br><br>" + "<table border=0 width=610><tr><td width=10></td><td width=600 align=left>" + "<a action=\"bypass _bbshome\">HOME</a> > <a action=\"bypass _bbsmemo\">Memo Form</a>" + "</td></tr>" + "</table>" + "<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">" + "<center>" + "<table border=0 cellspacing=0 cellpadding=2 bgcolor=888888 width=610>" + "<tr>" + "<td FIXWIDTH=5></td>" + "<td FIXWIDTH=415 align=center>&$413;</td>" + "<td FIXWIDTH=120 align=center></td>" + "<td FIXWIDTH=70 align=center>&$418;</td>" + "</tr>" + "</table>");
|
||||
final DateFormat dateFormat = DateFormat.getInstance();
|
||||
|
||||
for (int i = 0, j = getMaxID(forum) + 1; i < (12 * index); j--)
|
||||
{
|
||||
if (j < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Topic t = forum.getTopic(j);
|
||||
if (t != null)
|
||||
{
|
||||
if (i++ >= (12 * (index - 1)))
|
||||
{
|
||||
StringUtil.append(html, "<table border=0 cellspacing=0 cellpadding=5 WIDTH=610>" + "<tr>" + "<td FIXWIDTH=5></td>" + "<td FIXWIDTH=415><a action=\"bypass _bbsposts;read;", String.valueOf(forum.getID()), ";", String.valueOf(t.getID()), "\">", t.getName(), "</a></td>" + "<td FIXWIDTH=120 align=center></td>" + "<td FIXWIDTH=70 align=center>", dateFormat.format(new Date(t.getDate())), "</td>" + "</tr>" + "</table>" + "<img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html.append("<br>" + "<table width=610 cellspace=0 cellpadding=0>" + "<tr>" + "<td width=50>" + "<button value=\"&$422;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\">" + "</td>" + "<td width=510 align=center>" + "<table border=0><tr>");
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
html.append("<td><button action=\"\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><button action=\"bypass _bbstopics;read;", String.valueOf(forum.getID()), ";", String.valueOf(index - 1), "\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
|
||||
}
|
||||
|
||||
int nbp;
|
||||
nbp = forum.getTopicSize() / 8;
|
||||
if ((nbp * 8) != ClanTable.getInstance().getClans().length)
|
||||
{
|
||||
nbp++;
|
||||
}
|
||||
for (int i = 1; i <= nbp; i++)
|
||||
{
|
||||
if (i == index)
|
||||
{
|
||||
StringUtil.append(html, "<td> ", String.valueOf(i), " </td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><a action=\"bypass _bbstopics;read;", String.valueOf(forum.getID()), ";", String.valueOf(i), "\"> ", String.valueOf(i), " </a></td>");
|
||||
}
|
||||
}
|
||||
if (index == nbp)
|
||||
{
|
||||
html.append("<td><button action=\"\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(html, "<td><button action=\"bypass _bbstopics;read;", String.valueOf(forum.getID()), ";", String.valueOf(index + 1), "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
|
||||
}
|
||||
|
||||
StringUtil.append(html, "</tr></table> </td> " + "<td align=right><button value = \"&$421;\" action=\"bypass _bbstopics;crea;", String.valueOf(forum.getID()), "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td></tr>" + "<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>" + "<tr> " + "<td></td>" + "<td align=center><table border=0><tr><td></td><td><edit var = \"Search\" width=130 height=11></td>" + "<td><button value=\"&$420;\" action=\"Write 5 -2 0 Search _ _\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td> </tr></table> </td>" + "</tr>" + "</table>" + "<br>" + "<br>" + "<br>" + "</center>" + "</body>" + "</html>");
|
||||
separateAndSend(html.toString(), activeChar);
|
||||
}
|
||||
|
||||
@SuppressWarnings("synthetic-access")
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final TopicBBSManager _instance = new TopicBBSManager();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user