Chronicle 4 branch.

This commit is contained in:
MobiusDev
2017-07-19 21:24:06 +00:00
parent 9a69bec286
commit 3a0bf3539a
13496 changed files with 641683 additions and 0 deletions

View File

@@ -0,0 +1,272 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.BB;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
import javolution.util.FastList;
import javolution.util.FastMap;
public class Forum
{
// type
public static final int ROOT = 0;
public static final int NORMAL = 1;
public static final int CLAN = 2;
public static final int MEMO = 3;
public static final int MAIL = 4;
// perm
public static final int INVISIBLE = 0;
public static final int ALL = 1;
public static final int CLANMEMBERONLY = 2;
public static final int OWNERONLY = 3;
private static Logger _log = Logger.getLogger(Forum.class.getName());
private final List<Forum> _children;
private final Map<Integer, Topic> _topic;
private final int _ForumId;
private String _ForumName;
// private int _ForumParent;
private int _ForumType;
private int _ForumPost;
private int _ForumPerm;
private final Forum _FParent;
private int _OwnerID;
private boolean loaded = false;
/**
* @param Forumid
* @param FParent
*/
public Forum(int Forumid, Forum FParent)
{
_ForumId = Forumid;
_FParent = FParent;
_children = new FastList<>();
_topic = new FastMap<>();
}
/**
* @param name
* @param parent
* @param type
* @param perm
* @param OwnerID
*/
public Forum(String name, Forum parent, int type, int perm, int OwnerID)
{
_ForumName = name;
_ForumId = ForumsBBSManager.getInstance().GetANewID();
// _ForumParent = parent.getID();
_ForumType = type;
_ForumPost = 0;
_ForumPerm = perm;
_FParent = parent;
_OwnerID = OwnerID;
_children = new FastList<>();
_topic = new FastMap<>();
parent._children.add(this);
ForumsBBSManager.getInstance().addForum(this);
loaded = true;
}
/**
*
*/
private void load()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
{
statement.setInt(1, _ForumId);
try (ResultSet result = statement.executeQuery())
{
if (result.next())
{
_ForumName = result.getString("forum_name");
_ForumPost = result.getInt("forum_post");
_ForumType = result.getInt("forum_type");
_ForumPerm = result.getInt("forum_perm");
_OwnerID = result.getInt("forum_owner_id");
}
}
}
catch (final Exception e)
{
_log.warning("data error on Forum " + _ForumId + " : " + e);
e.printStackTrace();
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC"))
{
statement.setInt(1, _ForumId);
try (ResultSet result = statement.executeQuery())
{
while (result.next())
{
final Topic t = new Topic(Topic.ConstructorType.RESTORE, result.getInt("topic_id"), result.getInt("topic_forum_id"), result.getString("topic_name"), result.getLong("topic_date"), result.getString("topic_ownername"), result.getInt("topic_ownerid"), result.getInt("topic_type"), result.getInt("topic_reply"));
_topic.put(t.getID(), t);
if (t.getID() > TopicBBSManager.getInstance().getMaxID(this))
{
TopicBBSManager.getInstance().setMaxID(t.getID(), this);
}
}
}
}
catch (final Exception e)
{
_log.warning("data error on Forum " + _ForumId + " : " + e);
e.printStackTrace();
}
}
/**
*
*/
private void getChildren()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?"))
{
statement.setInt(1, _ForumId);
try (ResultSet result = statement.executeQuery())
{
while (result.next())
{
final Forum f = new Forum(result.getInt("forum_id"), this);
_children.add(f);
ForumsBBSManager.getInstance().addForum(f);
}
}
}
catch (final Exception e)
{
_log.warning("data error on Forum (children): " + e);
e.printStackTrace();
}
}
public int getTopicSize()
{
vload();
return _topic.size();
}
public Topic gettopic(int j)
{
vload();
return _topic.get(j);
}
public void addtopic(Topic t)
{
vload();
_topic.put(t.getID(), t);
}
/**
* @return
*/
public int getID()
{
return _ForumId;
}
public String getName()
{
vload();
return _ForumName;
}
public int getType()
{
vload();
return _ForumType;
}
/**
* @param name
* @return
*/
public Forum GetChildByName(String name)
{
vload();
for (final Forum f : _children)
{
if (f.getName().equals(name))
{
return f;
}
}
return null;
}
/**
* @param id
*/
public void RmTopicByID(int id)
{
_topic.remove(id);
}
/**
*
*/
public void insertindb()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) values (?,?,?,?,?,?,?)"))
{
statement.setInt(1, _ForumId);
statement.setString(2, _ForumName);
statement.setInt(3, _FParent.getID());
statement.setInt(4, _ForumPost);
statement.setInt(5, _ForumType);
statement.setInt(6, _ForumPerm);
statement.setInt(7, _OwnerID);
statement.execute();
}
catch (final Exception e)
{
_log.warning("error while saving new Forum to db " + e);
}
}
/**
*
*/
public void vload()
{
if (loaded == false)
{
load();
getChildren();
loaded = true;
}
}
}

View File

@@ -0,0 +1,176 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.BB;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.logging.Logger;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.PostBBSManager;
import javolution.util.FastList;
/**
* @author Maktakien
*/
public class Post
{
private static Logger _log = Logger.getLogger(Post.class.getName());
public class CPost
{
public int _PostID;
public String _PostOwner;
public int _PostOwnerID;
public long _PostDate;
public int _PostTopicID;
public int _PostForumID;
public String _PostTxt;
}
private final List<CPost> _post;
public Post(String _PostOwner, int _PostOwnerID, long date, int tid, int _PostForumID, String txt)
{
_post = new FastList<>();
final CPost cp = new CPost();
cp._PostID = 0;
cp._PostOwner = _PostOwner;
cp._PostOwnerID = _PostOwnerID;
cp._PostDate = date;
cp._PostTopicID = tid;
cp._PostForumID = _PostForumID;
cp._PostTxt = txt;
_post.add(cp);
insertindb(cp);
}
public void insertindb(CPost cp)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
{
statement.setInt(1, cp._PostID);
statement.setString(2, cp._PostOwner);
statement.setInt(3, cp._PostOwnerID);
statement.setLong(4, cp._PostDate);
statement.setInt(5, cp._PostTopicID);
statement.setInt(6, cp._PostForumID);
statement.setString(7, cp._PostTxt);
statement.execute();
}
catch (final Exception e)
{
_log.warning("error while saving new Post to db " + e);
}
}
public Post(Topic t)
{
_post = new FastList<>();
load(t);
}
public CPost getCPost(int id)
{
int i = 0;
for (final CPost cp : _post)
{
if (i++ == id)
{
return cp;
}
}
return null;
}
public void deleteme(Topic t)
{
PostBBSManager.getInstance().delPostByTopic(t);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?"))
{
statement.setInt(1, t.getForumID());
statement.setInt(2, t.getID());
statement.execute();
}
catch (final Exception e)
{
e.printStackTrace();
}
}
/**
* @param t
*/
private void load(Topic t)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC"))
{
statement.setInt(1, t.getForumID());
statement.setInt(2, t.getID());
try (ResultSet result = statement.executeQuery())
{
while (result.next())
{
final CPost cp = new CPost();
cp._PostID = Integer.parseInt(result.getString("post_id"));
cp._PostOwner = result.getString("post_owner_name");
cp._PostOwnerID = Integer.parseInt(result.getString("post_ownerid"));
cp._PostDate = Long.parseLong(result.getString("post_date"));
cp._PostTopicID = Integer.parseInt(result.getString("post_topic_id"));
cp._PostForumID = Integer.parseInt(result.getString("post_forum_id"));
cp._PostTxt = result.getString("post_txt");
_post.add(cp);
}
}
}
catch (final Exception e)
{
_log.warning("data error on Post " + t.getForumID() + "/" + t.getID() + " : " + e);
e.printStackTrace();
}
}
/**
* @param i
*/
public void updatetxt(int i)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?"))
{
final CPost cp = getCPost(i);
statement.setString(1, cp._PostTxt);
statement.setInt(2, cp._PostID);
statement.setInt(3, cp._PostTopicID);
statement.setInt(4, cp._PostForumID);
statement.execute();
}
catch (final Exception e)
{
_log.warning("error while saving new Post to db " + e);
}
}
}

View File

@@ -0,0 +1,153 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.BB;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.logging.Logger;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
public class Topic
{
private static Logger _log = Logger.getLogger(Topic.class.getName());
public static final int MORMAL = 0;
public static final int MEMO = 1;
private final int _ID;
private final int _ForumID;
private final String _TopicName;
private final long _date;
private final String _OwnerName;
private final int _OwnerID;
private final int _type;
private final int _Creply;
/**
* @param ct
* @param id
* @param fid
* @param name
* @param date
* @param oname
* @param oid
* @param type
* @param Creply
*/
public Topic(ConstructorType ct, int id, int fid, String name, long date, String oname, int oid, int type, int Creply)
{
_ID = id;
_ForumID = fid;
_TopicName = name;
_date = date;
_OwnerName = oname;
_OwnerID = oid;
_type = type;
_Creply = Creply;
TopicBBSManager.getInstance().addTopic(this);
if (ct == ConstructorType.CREATE)
{
insertindb();
}
}
/**
*
*/
public void insertindb()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, _ID);
statement.setInt(2, _ForumID);
statement.setString(3, _TopicName);
statement.setLong(4, _date);
statement.setString(5, _OwnerName);
statement.setInt(6, _OwnerID);
statement.setInt(7, _type);
statement.setInt(8, _Creply);
statement.execute();
}
catch (final Exception e)
{
_log.warning("error while saving new Topic to db " + e);
}
}
public enum ConstructorType
{
RESTORE,
CREATE
}
/**
* @return
*/
public int getID()
{
return _ID;
}
public int getForumID()
{
return _ForumID;
}
/**
* @return
*/
public String getName()
{
// TODO Auto-generated method stub
return _TopicName;
}
public String getOwnerName()
{
// TODO Auto-generated method stub
return _OwnerName;
}
public void deleteme(Forum f)
{
TopicBBSManager.getInstance().delTopic(this);
f.RmTopicByID(getID());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?"))
{
statement.setInt(1, getID());
statement.setInt(2, f.getID());
statement.execute();
}
catch (final Exception e)
{
e.printStackTrace();
}
}
/**
* @return
*/
public long getDate()
{
return _date;
}
}

View File

@@ -0,0 +1,151 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.communitybbs.Manager.ClanBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.PostBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.TopBBSManager;
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class CommunityBoard
{
private static CommunityBoard _instance;
public static CommunityBoard getInstance()
{
if (_instance == null)
{
_instance = new CommunityBoard();
}
return _instance;
}
public void handleCommands(L2GameClient client, String command)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
switch (Config.COMMUNITY_TYPE)
{
default:
case 0: // disabled
activeChar.sendPacket(new SystemMessage(SystemMessage.CB_OFFLINE));
break;
case 1: // old
RegionBBSManager.getInstance().parsecmd(command, activeChar);
case 2: // new
if (command.startsWith("_bbsclan"))
{
ClanBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbsmemo"))
{
TopicBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbstopics"))
{
TopicBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbsposts"))
{
PostBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbstop"))
{
TopBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbshome"))
{
TopBBSManager.getInstance().parsecmd(command, activeChar);
}
else if (command.startsWith("_bbsloc"))
{
RegionBBSManager.getInstance().parsecmd(command, activeChar);
}
else
{
final 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"));
}
break;
}
}
/**
* @param client
* @param url
* @param arg1
* @param arg2
* @param arg3
* @param arg4
* @param arg5
*/
public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
switch (Config.COMMUNITY_TYPE)
{
case 2:
if (url.equals("Topic"))
{
TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
}
else if (url.equals("Post"))
{
PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
}
else if (url.equals("Region"))
{
RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
}
else
{
final ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url + " 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"));
}
break;
case 1:
RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
break;
default:
case 0:
final ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disabled.</center><br><br></body></html>", "101");
activeChar.sendPacket(sb);
activeChar.sendPacket(new ShowBoard(null, "102"));
activeChar.sendPacket(new ShowBoard(null, "103"));
break;
}
}
}

View File

@@ -0,0 +1,71 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
public class AdminBBSManager extends BaseBBSManager
{
private static AdminBBSManager _Instance = null;
/**
* @return
*/
public static AdminBBSManager getInstance()
{
if (_Instance == null)
{
_Instance = new AdminBBSManager();
}
return _Instance;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.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
{
final 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)
{
if (!activeChar.isGM())
{
return;
}
}
}

View File

@@ -0,0 +1,107 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.util.List;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
import javolution.util.FastList;
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() < 8180)
{
acha.sendPacket(new ShowBoard(html, "101"));
acha.sendPacket(new ShowBoard(null, "102"));
acha.sendPacket(new ShowBoard(null, "103"));
}
else if (html.length() < 16360)
{
acha.sendPacket(new ShowBoard(html.substring(0, 8180), "101"));
acha.sendPacket(new ShowBoard(html.substring(8180, html.length()), "102"));
acha.sendPacket(new ShowBoard(null, "103"));
}
else if (html.length() < 24540)
{
acha.sendPacket(new ShowBoard(html.substring(0, 8180), "101"));
acha.sendPacket(new ShowBoard(html.substring(8180, 16360), "102"));
acha.sendPacket(new ShowBoard(html.substring(16360, html.length()), "103"));
}
}
/**
* @param html
* @param acha
*/
protected void send1001(String html, L2PcInstance acha)
{
if (html.length() < 8180)
{
acha.sendPacket(new ShowBoard(html, "1001"));
}
}
/**
* @param acha
*/
protected void send1002(L2PcInstance acha)
{
send1002(acha, " ", " ", "0");
}
/**
* @param activeChar
* @param string
* @param string2
* @param string3
*/
protected void send1002(L2PcInstance activeChar, String string, String string2, String string3)
{
final 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));
}
}

View File

@@ -0,0 +1,328 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.datatables.ClanTable;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
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;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
final 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;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
final int index = Integer.parseInt(st.nextToken());
clanhome(activeChar, index);
}
}
else
{
separateAndSend("<html><body><br><br><center>Command : " + command + " is not implemented yet</center><br><br></body></html>", activeChar);
}
}
/**
* @param activeChar
* @param index
*/
private void clanlist(L2PcInstance activeChar, int index)
{
if (index < 1)
{
index = 1;
}
// header
final TextBuilder html = new TextBuilder("<html><body><br><br><center>");
html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
html.append("<td width=610 height=30 align=left>");
html.append("<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>");
html.append("</td></tr></table>");
html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
html.append("<tr><td height=10></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=5></td>");
html.append("<td fixWIDTH=600>");
html.append("<a action=\"bypass _bbsclan_clanhome;" + ((activeChar.getClan() != null) ? activeChar.getClan().getClanId() : 0) + "\">[GO TO MY CLAN]</a>&nbsp;&nbsp;");
html.append("</td>");
html.append("<td fixWIDTH=5></td>");
html.append("</tr>");
html.append("<tr><td height=10></td></tr>");
html.append("</table>");
// body
html.append("<br>");
html.append("<table border=0 cellspacing=0 cellpadding=2 bgcolor=5A5A5A width=610>");
html.append("<tr>");
html.append("<td FIXWIDTH=5></td>");
html.append("<td FIXWIDTH=200 align=center>CLAN NAME</td>");
html.append("<td FIXWIDTH=200 align=center>CLAN LEADER</td>");
html.append("<td FIXWIDTH=100 align=center>CLAN LEVEL</td>");
html.append("<td FIXWIDTH=100 align=center>CLAN MEMBERS</td>");
html.append("<td FIXWIDTH=5></td>");
html.append("</tr>");
html.append("</table>");
html.append("<img src=\"L2UI.Squareblank\" width=\"1\" height=\"5\">");
int i = 0;
for (final L2Clan cl : ClanTable.getInstance().getClans())
{
if (i > ((index + 1) * 7))
{
break;
}
if (i++ >= ((index - 1) * 7))
{
html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
html.append("<tr> ");
html.append("<td FIXWIDTH=5></td>");
html.append("<td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;" + cl.getClanId() + "\">" + cl.getName() + "</a></td>");
html.append("<td FIXWIDTH=200 align=center>" + cl.getLeaderName() + "</td>");
html.append("<td FIXWIDTH=100 align=center>" + cl.getLevel() + "</td>");
html.append("<td FIXWIDTH=100 align=center>" + cl.getMembersCount() + "</td>");
html.append("<td FIXWIDTH=5></td>");
html.append("</tr>");
html.append("<tr><td height=5></td></tr>");
html.append("</table>");
html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
html.append("<img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
}
}
html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"2\">");
html.append("<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
{
html.append("<td><button action=\"_bbsclan_clanlist;" + (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)
{
html.append("<td> " + i + " </td>");
}
else
{
html.append("<td><a action=\"bypass _bbsclan_clanlist;" + i + "\"> " + 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
{
html.append("<td><button action=\"bypass _bbsclan_clanlist;" + (index + 1) + "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
}
html.append("</tr></table>");
html.append("<table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr>");
html.append("</table>");
html.append("<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)
html.append("<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>");
html.append("<br>");
html.append("<br>");
html.append("</center>");
html.append("</body>");
html.append("</html>");
separateAndSend(html.toString(), activeChar);
}
/**
* @param activeChar
*/
private void clanhome(L2PcInstance activeChar)
{
clanhome(activeChar, activeChar.getClan().getClanId());
}
/**
* @param activeChar
* @param clanId
*/
private void clanhome(L2PcInstance activeChar, int clanId)
{
final L2Clan cl = ClanTable.getInstance().getClan(clanId);
if (cl != null)
{
if (cl.getLevel() < 2)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.NO_CB_IN_MY_CLAN));
parsecmd("_bbsclan_clanlist", activeChar);
}
else
{
final TextBuilder html = new TextBuilder("<html><body><center><br><br>");
html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
html.append("<td width=610 height=30 align=left>");
html.append("<a action=\"bypass _bbshome\">HOME</a> &gt; <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> &gt; <a action=\"bypass _bbsclan_clanhome;" + clanId + "\"> &amp;$802; </a>");
html.append("</td></tr></table>");
html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
html.append("<tr><td height=10></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=5></td>");
html.append("<td fixwidth=600>");
html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;" + clanId + ";cbb\">[CLAN BULLETIN BOARD]</a>");
html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cmail\">[CLAN MAIL]</a>&nbsp;&nbsp;");
html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;");
html.append("</td>");
html.append("<td fixWIDTH=5></td>");
html.append("</tr>");
html.append("<tr><td height=10></td></tr>");
html.append("</table>");
html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
html.append("<tr><td height=10></td></tr>");
html.append("<tr><td fixWIDTH=5></td>");
html.append("<td fixwidth=290 valign=top>");
html.append("</td>");
html.append("<td fixWIDTH=5></td>");
html.append("<td fixWIDTH=5 align=center valign=top><img src=\"l2ui.squaregray\" width=2 height=128></td>");
html.append("<td fixWIDTH=5></td>");
html.append("<td fixwidth=295>");
html.append("<table border=0 cellspacing=0 cellpadding=0 width=295>");
html.append("<tr>");
html.append("<td fixWIDTH=100 align=left>CLAN NAME</td>");
html.append("<td fixWIDTH=195 align=left>" + cl.getName() + "</td>");
html.append("</tr>");
html.append("<tr><td height=7></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=100 align=left>CLAN LEVEL</td>");
html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLevel() + "</td>");
html.append("</tr>");
html.append("<tr><td height=7></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=100 align=left>CLAN MEMBERS</td>");
html.append("<td fixWIDTH=195 align=left height=16>" + cl.getMembersCount() + "</td>");
html.append("</tr>");
html.append("<tr><td height=7></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=100 align=left>CLAN LEADER</td>");
html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLeaderName() + "</td>");
html.append("</tr>");
html.append("<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>");
*/
html.append("<tr><td height=7></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=100 align=left>ALLIANCE</td>");
html.append("<td fixWIDTH=195 align=left height=16>" + ((cl.getAllyName() != null) ? cl.getAllyName() : "") + "</td>");
html.append("</tr>");
html.append("</table>");
html.append("</td>");
html.append("<td fixWIDTH=5></td>");
html.append("</tr>");
html.append("<tr><td height=10></td></tr>");
html.append("</table>");
// TODO: the BB for clan :)
// html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=333333>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">");
html.append("<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">");
html.append("<br>");
html.append("</center>");
html.append("<br> <br>");
html.append("</body>");
html.append("</html>");
separateAndSend(html.toString(), activeChar);
}
}
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
{
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,170 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.logging.Logger;
import com.l2jmobius.L2DatabaseFactory;
import com.l2jmobius.gameserver.communitybbs.BB.Forum;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import javolution.util.FastList;
public class ForumsBBSManager extends BaseBBSManager
{
private static Logger _log = Logger.getLogger(ForumsBBSManager.class.getName());
private final List<Forum> _table;
private static ForumsBBSManager _Instance;
private int lastid = 1;
/**
* @return
*/
public static ForumsBBSManager getInstance()
{
if (_Instance == null)
{
_Instance = new ForumsBBSManager();
}
return _Instance;
}
public ForumsBBSManager()
{
_table = new FastList<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_type=0");
ResultSet result = statement.executeQuery())
{
while (result.next())
{
final int forumId = result.getInt("forum_id");
final Forum f = new Forum(forumId, null);
addForum(f);
}
}
catch (final Exception e)
{
_log.warning("data error on Forum (root): " + e);
e.printStackTrace();
}
}
public void initRoot()
{
for (final 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();
}
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsecmd(String command, L2PcInstance activeChar)
{
// TODO Auto-generated method stub
}
/**
* @param Name
* @return
*/
public Forum getForumByName(String Name)
{
for (final Forum f : _table)
{
if (f.getName().equals(Name))
{
return f;
}
}
return null;
}
/**
* @param name
* @param parent
* @param type
* @param perm
* @param oid
* @return
*/
public Forum CreateNewForum(String name, Forum parent, int type, int perm, int oid)
{
final Forum forum = new Forum(name, parent, type, perm, oid);
forum.insertindb();
return forum;
}
/**
* @return
*/
public int GetANewID()
{
return ++lastid;
}
/**
* @param idf
* @return
*/
public Forum getForumByID(int idf)
{
for (final Forum f : _table)
{
if (f.getID() == idf)
{
return f;
}
}
return null;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
{
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,374 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.communitybbs.BB.Forum;
import com.l2jmobius.gameserver.communitybbs.BB.Post;
import com.l2jmobius.gameserver.communitybbs.BB.Post.CPost;
import com.l2jmobius.gameserver.communitybbs.BB.Topic;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
import javolution.text.TextBuilder;
import javolution.util.FastMap;
public class PostBBSManager extends BaseBBSManager
{
private final Map<Topic, Post> _PostByTopic;
private static PostBBSManager _Instance;
public static PostBBSManager getInstance()
{
if (_Instance == null)
{
_Instance = new PostBBSManager();
}
return _Instance;
}
public 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.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsecmd(String command, L2PcInstance activeChar)
{
if (command.startsWith("_bbsposts;read;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final int idf = Integer.parseInt(st.nextToken());
final 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;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final int idf = Integer.parseInt(st.nextToken());
final int idt = Integer.parseInt(st.nextToken());
final int idp = Integer.parseInt(st.nextToken());
showEditPost((TopicBBSManager.getInstance().getTopicByID(idt)), ForumsBBSManager.getInstance().getForumByID(idf), activeChar, idp);
}
else
{
final 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 forum
* @param activeChar
* @param idp
*/
private void showEditPost(Topic topic, Forum forum, L2PcInstance activeChar, int idp)
{
final Post p = getGPosttByTopic(topic);
if ((forum == null) || (topic == null) || (p == null))
{
final 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 topic
* @param forum
* @param activeChar
* @param ind
*/
private void showPost(Topic topic, Forum forum, L2PcInstance activeChar, int ind)
{
if ((forum == null) || (topic == null))
{
final 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
{
final 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 TextBuilder html = new TextBuilder("<html>");
html.append("<body><br><br>");
html.append("<table border=0 width=610><tr><td width=10></td><td width=600 align=left>");
html.append("<a action=\"bypass _bbshome\">HOME</a>&nbsp;>&nbsp;<a action=\"bypass _bbsmemo\">" + forum.getName() + " Form</a>");
html.append("</td></tr>");
html.append("</table>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">");
html.append("<center>");
html.append("<table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td width=610><img src=\"sek.cbui355\" width=\"610\" height=\"1\"><br1><img src=\"sek.cbui355\" width=\"610\" height=\"1\"></td></tr>");
html.append("</table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=20></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29>&$413;</td>");
html.append("<td FIXWIDTH=540>" + topic.getName() + "</td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr></table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29 valign=top>&$427;</td>");
html.append("<td align=center FIXWIDTH=540><MultiEdit var =\"Content\" width=535 height=313></td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("</table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29>&nbsp;</td>");
html.append("<td align=center FIXWIDTH=70><button value=\"&$140;\" action=\"Write Post " + forum.getID() + ";" + topic.getID() + ";0 _ Content Content Content\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>");
html.append("<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>");
html.append("<td align=center FIXWIDTH=400>&nbsp;</td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr></table>");
html.append("</center>");
html.append("</body>");
html.append("</html>");
send1001(html.toString(), 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)
{
//
final Post p = getGPosttByTopic(topic);
final Locale locale = Locale.getDefault();
final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
final TextBuilder html = new TextBuilder("<html><body><br><br>");
html.append("<table border=0 width=610><tr><td width=10></td><td width=600 align=left>");
html.append("<a action=\"bypass _bbshome\">HOME</a>&nbsp;>&nbsp;<a action=\"bypass _bbsmemo\">Memo Form</a>");
html.append("</td></tr>");
html.append("</table>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">");
html.append("<center>");
html.append("<table border=0 cellspacing=0 cellpadding=0 bgcolor=333333>");
html.append("<tr><td height=10></td></tr>");
html.append("<tr>");
html.append("<td fixWIDTH=55 align=right valign=top>&$413; : &nbsp;</td>");
html.append("<td fixWIDTH=380 valign=top>" + topic.getName() + "</td>");
html.append("<td fixwidth=5></td>");
html.append("<td fixwidth=50></td>");
html.append("<td fixWIDTH=120></td>");
html.append("</tr>");
html.append("<tr><td height=10></td></tr>");
html.append("<tr>");
html.append("<td align=right><font color=\"AAAAAA\" >&$417; : &nbsp;</font></td>");
html.append("<td><font color=\"AAAAAA\">" + topic.getOwnerName() + "</font></td>");
html.append("<td></td>");
html.append("<td><font color=\"AAAAAA\">&$418; :</font></td>");
html.append("<td><font color=\"AAAAAA\">" + dateFormat.format(p.getCPost(0)._PostDate) + "</font></td>");
html.append("</tr>");
html.append("<tr><td height=10></td></tr>");
html.append("</table>");
html.append("<br>");
html.append("<table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr>");
html.append("<td fixwidth=5></td>");
String Mes = p.getCPost(0)._PostTxt.replace(">", "&gt;");
Mes = Mes.replace("<", "&lt;");
Mes = Mes.replace("\n", "<br1>");
html.append("<td FIXWIDTH=600 align=left>" + Mes + "</td>");
html.append("<td fixqqwidth=5></td>");
html.append("</tr>");
html.append("</table>");
html.append("<br>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">");
html.append("<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">");
html.append("<table border=0 cellspacing=0 cellpadding=0 FIXWIDTH=610>");
html.append("<tr>");
html.append("<td width=50>");
html.append("<button value=\"&$422;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\">");
html.append("</td>");
html.append("<td width=560 align=right><table border=0 cellspacing=0><tr>");
html.append("<td FIXWIDTH=300></td><td><button value = \"&$424;\" action=\"bypass _bbsposts;edit;" + forum.getID() + ";" + topic.getID() + ";0\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>&nbsp;");
html.append("<td><button value = \"&$425;\" action=\"bypass _bbstopics;del;" + forum.getID() + ";" + topic.getID() + "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>&nbsp;");
html.append("<td><button value = \"&$421;\" action=\"bypass _bbstopics;crea;" + forum.getID() + "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>&nbsp;");
html.append("</tr></table>");
html.append("</td>");
html.append("</tr>");
html.append("</table>");
html.append("<br>");
html.append("<br>");
html.append("<br></center>");
html.append("</body>");
html.append("</html>");
separateAndSend(html.toString(), activeChar);
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(ar1, ";");
final int idf = Integer.parseInt(st.nextToken());
final int idt = Integer.parseInt(st.nextToken());
final int idp = Integer.parseInt(st.nextToken());
final Forum f = ForumsBBSManager.getInstance().getForumByID(idf);
if (f == null)
{
final 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
{
final Topic t = f.gettopic(idt);
if (t == null)
{
final 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;
final Post p = getGPosttByTopic(t);
if (p != null)
{
cp = p.getCPost(idp);
}
if (cp == null)
{
final 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 if (p != null)
{
p.getCPost(idp)._PostTxt = ar4;
p.updatetxt(idp);
parsecmd("_bbsposts;read;" + f.getID() + ";" + t.getID(), activeChar);
}
}
}
}
}

View File

@@ -0,0 +1,680 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.util.Collection;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameServer;
import com.l2jmobius.gameserver.model.BlockList;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.Experience;
import com.l2jmobius.gameserver.network.clientpackets.Say2;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import javolution.text.TextBuilder;
import javolution.util.FastList;
import javolution.util.FastMap;
public class RegionBBSManager extends BaseBBSManager
{
private static Logger _logChat = Logger.getLogger("chat");
private static RegionBBSManager _Instance = null;
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()
{
if (_Instance == null)
{
_Instance = new RegionBBSManager();
}
return _Instance;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.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;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
int page = 0;
try
{
page = Integer.parseInt(st.nextToken());
}
catch (final NumberFormatException nfe)
{
}
showOldCommunity(activeChar, page);
}
else if (command.startsWith("_bbsloc;playerinfo;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final String name = st.nextToken();
showOldCommunityPI(activeChar, name);
}
else
{
if (Config.COMMUNITY_TYPE == 1)
{
showOldCommunity(activeChar, 1);
}
else
{
final 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 TextBuilder htmlCode = new TextBuilder("<html><body><br>");
htmlCode.append("<table border=0><tr><td FIXWIDTH=15></td><td align=center>Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
final 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";
}
htmlCode.append("<table border=0><tr><td>" + player.getName() + " (" + sex + " " + player.getTemplate().className + "):</td></tr>");
htmlCode.append("<tr><td>Level: " + levelApprox + "</td></tr>");
htmlCode.append("<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();
}
htmlCode.append("<tr><td>Level: " + player.getLevel() + "</td></tr>");
htmlCode.append("<tr><td>Experience: " + player.getExp() + "/" + nextLevelExp + "</td></tr>");
htmlCode.append("<tr><td>Experience needed for level up: " + nextLevelExpNeeded + "</td></tr>");
htmlCode.append("<tr><td><br></td></tr>");
}
final int uptime = (int) player.getUptime() / 1000;
final int h = uptime / 3600;
final int m = (uptime - (h * 3600)) / 60;
final int s = ((uptime - (h * 3600)) - (m * 60));
htmlCode.append("<tr><td>Uptime: " + h + "h " + m + "m " + s + "s</td></tr>");
htmlCode.append("<tr><td><br></td></tr>");
if (player.getClan() != null)
{
htmlCode.append("<tr><td>Clan: " + player.getClan().getName() + "</td></tr>");
htmlCode.append("<tr><td><br></td></tr>");
}
htmlCode.append("<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=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr><tr><td><br><button value=\"Back\" action=\"bypass _bbsloc\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>");
htmlCode.append("</td></tr></table>");
htmlCode.append("</body></html>");
separateAndSend(htmlCode.toString(), activeChar);
}
else
{
final ShowBoard sb = new ShowBoard("<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
* @param page
*/
private void showOldCommunity(L2PcInstance activeChar, int page)
{
separateAndSend(getCommunityPage(page, activeChar.isGM() ? "gm" : "pl"), activeChar);
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.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 TextBuilder htmlCode = new TextBuilder("<html><body><br>");
htmlCode.append("<table border=0><tr><td FIXWIDTH=15></td><td align=center>Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
try
{
final L2PcInstance receiver = L2World.getInstance().getPlayer(ar2);
if (receiver == null)
{
htmlCode.append("Player not found!<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;" + ar2 + "\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
htmlCode.append("</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 cannot chat while in jail.");
return;
}
if (Config.LOG_CHAT)
{
final LogRecord record = new LogRecord(Level.INFO, ar3);
record.setLoggerName("chat");
record.setParameters(new Object[]
{
"TELL",
"[" + activeChar.getName() + " to " + receiver.getName() + "]"
});
_logChat.log(record);
}
final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), ar3);
if (!BlockList.isBlocked(receiver, activeChar))
{
if (!receiver.getMessageRefusal())
{
receiver.sendPacket(cs);
activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), Say2.TELL, "->" + receiver.getName(), ar3));
htmlCode.append("Message Sent<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;" + receiver.getName() + "\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
htmlCode.append("</td></tr></table></body></html>");
separateAndSend(htmlCode.toString(), activeChar);
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessage.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
activeChar.sendPacket(sm);
parsecmd("_bbsloc;playerinfo;" + receiver.getName(), activeChar);
}
}
else
{
SystemMessage sm = new SystemMessage(SystemMessage.S1_IS_NOT_ONLINE);
sm.addString(receiver.getName());
activeChar.sendPacket(sm);
sm = null;
}
}
catch (final StringIndexOutOfBoundsException e)
{
// ignore
}
}
else
{
final 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"));
}
}
public synchronized void changeCommunityBoard()
{
if (Config.COMMUNITY_TYPE == 0)
{
return;
}
Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
final FastList<L2PcInstance> sortedPlayers = new FastList<>();
sortedPlayers.addAll(players);
players = null;
Collections.sort(sortedPlayers, (p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()));
_onlinePlayers.clear();
_onlineCount = 0;
_onlineCountGm = 0;
for (final L2PcInstance player : sortedPlayers)
{
addOnlinePlayer(player);
}
_communityPages.clear();
writeCommunityPages();
}
private void addOnlinePlayer(L2PcInstance player)
{
boolean added = false;
for (final 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)
{
final FastList<L2PcInstance> temp = new FastList<>();
final int page = _onlinePlayers.size() + 1;
if (temp.add(player))
{
_onlinePlayers.put(page, temp);
if (!player.getAppearance().getInvisible())
{
_onlineCount++;
}
_onlineCountGm++;
}
}
}
private void writeCommunityPages()
{
for (final int page : _onlinePlayers.keySet())
{
final FastMap<String, String> communityPage = new FastMap<>();
TextBuilder htmlCode = new TextBuilder("<html><body><br>");
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>";
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "Server Restarted: " + GameServer.DateTimeServerStarted.getTime() + tdClose);
htmlCode.append(trClose);
htmlCode.append("</table>");
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "XP Rate: x" + Config.RATE_XP + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Party XP Rate: x" + (Config.RATE_XP * Config.RATE_PARTY_XP) + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "XP Exponent: " + Config.ALT_GAME_EXPONENT_XP + tdClose);
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "SP Rate: x" + Config.RATE_SP + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Party SP Rate: x" + (Config.RATE_SP * Config.RATE_PARTY_SP) + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "SP Exponent: " + Config.ALT_GAME_EXPONENT_SP + tdClose);
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "Drop Rate: x" + Config.RATE_DROP_ITEMS + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Boss Drop Rate: x" + Config.RATE_BOSS_DROP_ITEMS + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Spoil Rate: x" + Config.RATE_DROP_SPOIL + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Adena Rate: x" + Config.RATE_DROP_ADENA + tdClose);
htmlCode.append(trClose);
htmlCode.append("</table>");
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + L2World.getInstance().getAllVisibleObjectsCount() + " Object count</td>");
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + getOnlineCount("gm") + " Player(s) Online</td>");
htmlCode.append(trClose);
htmlCode.append("</table>");
int cell = 0;
if (Config.BBS_SHOW_PLAYERLIST)
{
htmlCode.append("<table border=0>");
htmlCode.append("<tr><td><table border=0>");
for (final L2PcInstance player : getOnlinePlayers(page))
{
cell++;
if (cell == 1)
{
htmlCode.append(trOpen);
}
htmlCode.append("<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;" + player.getName() + "\">");
if (player.isGM())
{
htmlCode.append("<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></td></tr>");
htmlCode.append(trOpen);
htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
htmlCode.append(trClose);
htmlCode.append("</table>");
}
if (getOnlineCount("gm") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
{
htmlCode.append("<table border=0 width=600>");
htmlCode.append("<tr>");
if (page == 1)
{
htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
else
{
htmlCode.append("<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;" + (page - 1) + "\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
htmlCode.append("<td FIXWIDTH=10></td>");
htmlCode.append("<td align=center valign=top width=200>Displaying " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1) + " - " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size()) + " player(s)</td>");
htmlCode.append("<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=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
else
{
htmlCode.append("<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;" + (page + 1) + "\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
htmlCode.append("</tr>");
htmlCode.append("</table>");
}
htmlCode.append("</body></html>");
communityPage.put("gm", htmlCode.toString());
htmlCode = new TextBuilder("<html><body><br>");
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "Server Restarted: " + GameServer.DateTimeServerStarted.getTime() + tdClose);
htmlCode.append(trClose);
htmlCode.append("</table>");
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "XP Rate: x" + Config.RATE_XP + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Party XP Rate: x" + (Config.RATE_XP * Config.RATE_PARTY_XP) + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "XP Exponent: " + Config.ALT_GAME_EXPONENT_XP + tdClose);
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "SP Rate: x" + Config.RATE_SP + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Party SP Rate: x" + (Config.RATE_SP * Config.RATE_PARTY_SP) + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "SP Exponent: " + Config.ALT_GAME_EXPONENT_SP + tdClose);
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + "Drop Rate: x" + Config.RATE_DROP_ITEMS + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Boss Drop Rate: x" + Config.RATE_BOSS_DROP_ITEMS + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Spoil Rate: x" + Config.RATE_DROP_SPOIL + tdClose);
htmlCode.append(colSpacer);
htmlCode.append(tdOpen + "Adena Rate: x" + Config.RATE_DROP_ADENA + tdClose);
htmlCode.append(trClose);
htmlCode.append("</table>");
htmlCode.append("<table>");
htmlCode.append(trOpen);
htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
htmlCode.append(trClose);
htmlCode.append(trOpen);
htmlCode.append(tdOpen + getOnlineCount("gm") + " Player(s) Online</td>");
htmlCode.append(trClose);
htmlCode.append("</table>");
if (Config.BBS_SHOW_PLAYERLIST)
{
htmlCode.append("<table border=0>");
htmlCode.append("<tr><td><table border=0>");
cell = 0;
for (final L2PcInstance player : getOnlinePlayers(page))
{
if ((player == null) || player.getAppearance().getInvisible())
{
continue; // Go to next
}
cell++;
if (cell == 1)
{
htmlCode.append(trOpen);
}
htmlCode.append("<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;" + player.getName() + "\">");
if (player.isGM())
{
htmlCode.append("<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>");
htmlCode.append(trOpen);
htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
htmlCode.append(trClose);
htmlCode.append("</table>");
}
if (getOnlineCount("pl") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
{
htmlCode.append("<table border=0 width=600>");
htmlCode.append("<tr>");
if (page == 1)
{
htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
else
{
htmlCode.append("<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;" + (page - 1) + "\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
htmlCode.append("<td FIXWIDTH=10></td>");
htmlCode.append("<td align=center valign=top width=200>Displaying " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1) + " - " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size()) + " player(s)</td>");
htmlCode.append("<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=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
else
{
htmlCode.append("<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;" + (page + 1) + "\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
}
htmlCode.append("</tr>");
htmlCode.append("</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;
}
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.gameserver.communitybbs.Manager;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
public class TopBBSManager extends BaseBBSManager
{
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsecmd(String command, L2PcInstance activeChar)
{
if (command.equals("_bbstop"))
{
String content = HtmCache.getInstance().getHtm("data/html/CommunityBoard/index.htm");
if (content == null)
{
content = new String("<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("data/html/CommunityBoard/index.htm");
if (content == null)
{
content = new String("<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;"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
final int idp = Integer.parseInt(st.nextToken());
String content = HtmCache.getInstance().getHtm("data/html/CommunityBoard/" + idp + ".htm");
if (content == null)
{
content = new String("<html><body><br><br><center>404 :File Not found: 'data/html/CommunityBoard/" + idp + ".htm' </center></body></html>");
}
separateAndSend(content, activeChar);
}
else
{
final 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"));
}
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
{
// TODO Auto-generated method stub
}
private static TopBBSManager _Instance = new TopBBSManager();
/**
* @return
*/
public static TopBBSManager getInstance()
{
return _Instance;
}
}

View File

@@ -0,0 +1,472 @@
/*
* This file is part of the L2J Mobius project.
*
* 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.l2jmobius.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 com.l2jmobius.gameserver.communitybbs.BB.Forum;
import com.l2jmobius.gameserver.communitybbs.BB.Post;
import com.l2jmobius.gameserver.communitybbs.BB.Topic;
import com.l2jmobius.gameserver.datatables.ClanTable;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
import javolution.text.TextBuilder;
import javolution.util.FastList;
import javolution.util.FastMap;
public class TopicBBSManager extends BaseBBSManager
{
private final List<Topic> _table;
private final Map<Forum, Integer> _Maxid;
private static TopicBBSManager _Instance;
public static TopicBBSManager getInstance()
{
if (_Instance == null)
{
_Instance = new TopicBBSManager();
}
return _Instance;
}
public 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)
{
final Integer i = _Maxid.get(f);
if (i == null)
{
return 0;
}
return i;
}
public Topic getTopicByID(int idf)
{
for (final Topic t : _table)
{
if (t.getID() == idf)
{
return t;
}
}
return null;
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.l2jmobius.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"))
{
final Forum f = ForumsBBSManager.getInstance().getForumByID(Integer.parseInt(ar2));
if (f == null)
{
final 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();
final 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);
final 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"))
{
final Forum f = ForumsBBSManager.getInstance().getForumByID(Integer.parseInt(ar2));
if (f == null)
{
final 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
{
final Topic t = f.gettopic(Integer.parseInt(ar3));
if (t == null)
{
final 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;
final Post p = PostBBSManager.getInstance().getGPosttByTopic(t);
if (p != null)
{
p.deleteme(t);
}
t.deleteme(f);
parsecmd("_bbsmemo", activeChar);
}
}
}
else
{
final 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"));
}
}
/*
* (non-Javadoc)
* @see com.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jmobius.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"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final 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"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final int idf = Integer.parseInt(st.nextToken());
showNewTopic(ForumsBBSManager.getInstance().getForumByID(idf), activeChar, idf);
}
else if (command.startsWith("_bbstopics;del"))
{
final StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
final int idf = Integer.parseInt(st.nextToken());
final int idt = Integer.parseInt(st.nextToken());
final Forum f = ForumsBBSManager.getInstance().getForumByID(idf);
if (f == null)
{
final 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
{
final Topic t = f.gettopic(idt);
if (t == null)
{
final 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;
final Post p = PostBBSManager.getInstance().getGPosttByTopic(t);
if (p != null)
{
p.deleteme(t);
}
t.deleteme(f);
parsecmd("_bbsmemo", activeChar);
}
}
}
else
{
final 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 forum
* @param activeChar
* @param idf
*/
private void showNewTopic(Forum forum, L2PcInstance activeChar, int idf)
{
if (forum == null)
{
final 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
{
final 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 TextBuilder html = new TextBuilder("<html>");
html.append("<body><br><br>");
html.append("<table border=0 width=610><tr><td width=10></td><td width=600 align=left>");
html.append("<a action=\"bypass _bbshome\">HOME</a>&nbsp;>&nbsp;<a action=\"bypass _bbsmemo\">Memo Form</a>");
html.append("</td></tr>");
html.append("</table>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">");
html.append("<center>");
html.append("<table border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td width=610><img src=\"sek.cbui355\" width=\"610\" height=\"1\"><br1><img src=\"sek.cbui355\" width=\"610\" height=\"1\"></td></tr>");
html.append("</table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=20></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29>&$413;</td>");
html.append("<td FIXWIDTH=540><edit var = \"Title\" width=540 height=13></td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr></table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29 valign=top>&$427;</td>");
html.append("<td align=center FIXWIDTH=540><MultiEdit var =\"Content\" width=535 height=313></td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("</table>");
html.append("<table fixwidth=610 border=0 cellspacing=0 cellpadding=0>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("<tr>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("<td align=center FIXWIDTH=60 height=29>&nbsp;</td>");
html.append("<td align=center FIXWIDTH=70><button value=\"&$140;\" action=\"Write Topic crea " + forum.getID() + " Title Content Title\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td>");
html.append("<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>");
html.append("<td align=center FIXWIDTH=400>&nbsp;</td>");
html.append("<td><img src=\"l2ui.mini_logo\" width=5 height=1></td>");
html.append("</tr></table>");
html.append("</center>");
html.append("</body>");
html.append("</html>");
send1001(html.toString(), activeChar);
send1002(activeChar);
}
/**
* @param forum
* @param activeChar
* @param index
* @param idf
*/
private void showTopics(Forum forum, L2PcInstance activeChar, int index, int idf)
{
if (forum == null)
{
final 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
{
final 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
* @param index
*/
private void ShowMemoTopics(Forum forum, L2PcInstance activeChar, int index)
{
forum.vload();
final TextBuilder html = new TextBuilder("<html><body><br><br>");
html.append("<table border=0 width=610><tr><td width=10></td><td width=600 align=left>");
html.append("<a action=\"bypass _bbshome\">HOME</a>&nbsp;>&nbsp;<a action=\"bypass _bbsmemo\">Memo Form</a>");
html.append("</td></tr>");
html.append("</table>");
html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"10\">");
html.append("<center>");
html.append("<table border=0 cellspacing=0 cellpadding=2 bgcolor=888888 width=610>");
html.append("<tr>");
html.append("<td FIXWIDTH=5></td>");
html.append("<td FIXWIDTH=415 align=center>&$413;</td>");
html.append("<td FIXWIDTH=120 align=center></td>");
html.append("<td FIXWIDTH=70 align=center>&$418;</td>");
html.append("</tr>");
html.append("</table>");
for (int i = 0, j = getMaxID(forum) + 1; i < (12 * index); j--)
{
if (j < 0)
{
break;
}
final Topic t = forum.gettopic(j);
if (t != null)
{
if (i++ >= (12 * (index - 1)))
{
html.append("<table border=0 cellspacing=0 cellpadding=5 WIDTH=610>");
html.append("<tr>");
html.append("<td FIXWIDTH=5></td>");
html.append("<td FIXWIDTH=415><a action=\"bypass _bbsposts;read;" + forum.getID() + ";" + t.getID() + "\">" + t.getName() + "</a></td>");
html.append("<td FIXWIDTH=120 align=center></td>");
html.append("<td FIXWIDTH=70 align=center>" + DateFormat.getInstance().format(new Date(t.getDate())) + "</td>");
html.append("</tr>");
html.append("</table>");
html.append("<img src=\"L2UI.Squaregray\" width=\"610\" height=\"1\">");
}
}
}
html.append("<br>");
html.append("<table width=610 cellspace=0 cellpadding=0>");
html.append("<tr>");
html.append("<td width=50>");
html.append("<button value=\"&$422;\" action=\"bypass _bbsmemo\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\">");
html.append("</td>");
html.append("<td width=510 align=center>");
html.append("<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
{
html.append("<td><button action=\"bypass _bbstopics;read;" + forum.getID() + ";" + (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)
{
html.append("<td> " + i + " </td>");
}
else
{
html.append("<td><a action=\"bypass _bbstopics;read;" + forum.getID() + ";" + i + "\"> " + 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
{
html.append("<td><button action=\"bypass _bbstopics;read;" + forum.getID() + ";" + (index + 1) + "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
}
html.append("</tr></table> </td> ");
html.append("<td align=right><button value = \"&$421;\" action=\"bypass _bbstopics;crea;" + forum.getID() + "\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\" ></td></tr>");
html.append("<tr><td><img src=\"l2ui.mini_logo\" width=5 height=10></td></tr>");
html.append("<tr> ");
html.append("<td></td>");
html.append("<td align=center><table border=0><tr><td></td><td><edit var = \"Search\" width=130 height=11></td>");
html.append("<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>");
html.append("</tr>");
html.append("</table>");
html.append("<br>");
html.append("<br>");
html.append("<br>");
html.append("</center>");
html.append("</body>");
html.append("</html>");
separateAndSend(html.toString(), activeChar);
}
}