This commit is contained in:
mobius
2015-01-01 20:02:50 +00:00
parent eeae660458
commit a6a3718849
17894 changed files with 2818932 additions and 0 deletions

View File

@@ -0,0 +1,289 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IWriteBoardHandler;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.util.Util;
import com.l2jserver.util.StringUtil;
/**
* Clan board.
* @author Zoey76
*/
public class ClanBoard implements IWriteBoardHandler
{
private static final String[] COMMANDS =
{
"_bbsclan",
"_bbsclan_list",
"_bbsclan_clanhome"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
if (command.equals("_bbsclan"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan", command);
if ((activeChar.getClan() == null) || (activeChar.getClan().getLevel() < 2))
{
clanList(activeChar, 1);
}
else
{
clanHome(activeChar);
}
}
else if (command.startsWith("_bbsclan_clanlist"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan List", command);
if (command.equals("_bbsclan_clanlist"))
{
clanList(activeChar, 1);
}
else if (command.startsWith("_bbsclan_clanlist;"))
{
try
{
clanList(activeChar, Integer.parseInt(command.split(";")[1]));
}
catch (Exception e)
{
clanList(activeChar, 1);
LOG.warning(ClanBoard.class.getSimpleName() + ": Player " + activeChar + " send invalid clan list bypass " + command + "!");
}
}
}
else if (command.startsWith("_bbsclan_clanhome"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan Home", command);
if (command.equals("_bbsclan_clanhome"))
{
clanHome(activeChar);
}
else if (command.startsWith("_bbsclan_clanhome;"))
{
try
{
clanHome(activeChar, Integer.parseInt(command.split(";")[1]));
}
catch (Exception e)
{
clanHome(activeChar);
LOG.warning(ClanBoard.class.getSimpleName() + ": Player " + activeChar + " send invalid clan home bypass " + command + "!");
}
}
}
else if (command.startsWith("_bbsclan_clannotice_edit;"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan Edit", command);
clanNotice(activeChar, activeChar.getClanId());
}
else if (command.startsWith("_bbsclan_clannotice_enable"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan Notice Enable", command);
if (activeChar.getClan() != null)
{
activeChar.getClan().setNoticeEnabled(true);
}
clanNotice(activeChar, activeChar.getClanId());
}
else if (command.startsWith("_bbsclan_clannotice_disable"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Clan Notice Disable", command);
if (activeChar.getClan() != null)
{
activeChar.getClan().setNoticeEnabled(false);
}
clanNotice(activeChar, activeChar.getClanId());
}
else
{
CommunityBoardHandler.separateAndSend("<html><body><br><br><center>Command " + command + " need development.</center><br><br></body></html>", activeChar);
}
return true;
}
private void clanNotice(L2PcInstance activeChar, int clanId)
{
final L2Clan cl = ClanTable.getInstance().getClan(clanId);
if (cl != null)
{
if (cl.getLevel() < 2)
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_COMMUNITIES_IN_MY_CLAN_CLAN_COMMUNITIES_ARE_ALLOWED_FOR_CLANS_WITH_SKILL_LEVELS_OF_2_AND_HIGHER);
parseCommunityBoardCommand("_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> &gt; <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> &gt; <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &amp;$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:&nbsp;&nbsp;&nbsp;on&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;<a action=\"bypass _bbsclan_clannotice_disable\">off</a>");
}
else
{
StringUtil.append(html, "<tr><td fixwidth=610> Clan Notice Function:&nbsp;&nbsp;&nbsp;<a action=\"bypass _bbsclan_clannotice_enable\">on</a>&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;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>");
Util.sendCBHtml(activeChar, html.toString(), activeChar.getClan().getNotice());
}
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>");
CommunityBoardHandler.separateAndSend(html.toString(), 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>&nbsp;</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().getId() : 0), "\">[GO TO MY CLAN]</a>&nbsp;&nbsp;</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.getId()), "\">", 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>");
CommunityBoardHandler.separateAndSend(html.toString(), activeChar);
}
private void clanHome(L2PcInstance activeChar)
{
clanHome(activeChar, activeChar.getClan().getId());
}
private void clanHome(L2PcInstance activeChar, int clanId)
{
L2Clan cl = ClanTable.getInstance().getClan(clanId);
if (cl != null)
{
if (cl.getLevel() < 2)
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_COMMUNITIES_IN_MY_CLAN_CLAN_COMMUNITIES_ARE_ALLOWED_FOR_CLANS_WITH_SKILL_LEVELS_OF_2_AND_HIGHER);
parseCommunityBoardCommand("_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>&nbsp;</td><td width=610 height=30 align=left><a action=\"bypass _bbshome\">HOME</a> &gt; <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> &gt; <a action=\"bypass _bbsclan_clanhome;", String.valueOf(clanId), "\"> &amp;$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>&nbsp;&nbsp;<a action=\"bypass _bbsclan_clannotice_edit;", String.valueOf(clanId), ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;</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>");
CommunityBoardHandler.separateAndSend(html, activeChar);
}
}
}
@Override
public boolean writeCommunityBoardCommand(L2PcInstance activeChar, String arg1, String arg2, String arg3, String arg4, String arg5)
{
// TODO: Implement.
return false;
}
}

View File

@@ -0,0 +1,144 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.util.Util;
/**
* Favorite board.
* @author Zoey76
*/
public class FavoriteBoard implements IParseBoardHandler
{
// SQL Queries
private static final String SELECT_FAVORITES = "SELECT * FROM `bbs_favorites` WHERE `playerId`=? ORDER BY `favAddDate` DESC";
private static final String DELETE_FAVORITE = "DELETE FROM `bbs_favorites` WHERE `playerId`=? AND `favId`=?";
private static final String ADD_FAVORITE = "REPLACE INTO `bbs_favorites`(`playerId`, `favTitle`, `favBypass`) VALUES(?, ?, ?)";
private static final String[] COMMANDS =
{
"_bbsgetfav",
"bbs_add_fav",
"_bbsdelfav_"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
// None of this commands can be added to favorites.
if (command.startsWith("_bbsgetfav"))
{
// Load Favorite links
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/favorite_list.html");
final StringBuilder sb = new StringBuilder();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
{
ps.setInt(1, activeChar.getObjectId());
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
String link = list.replaceAll("%fav_bypass%", String.valueOf(rs.getString("favBypass")));
link = link.replaceAll("%fav_title%", rs.getString("favTitle"));
final SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
link = link.replaceAll("%fav_add_date%", date.format(rs.getTimestamp("favAddDate")));
link = link.replaceAll("%fav_id%", String.valueOf(rs.getInt("favId")));
sb.append(link);
}
}
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/favorite.html");
html = html.replaceAll("%fav_list%", sb.toString());
CommunityBoardHandler.separateAndSend(html, activeChar);
}
catch (Exception e)
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Couldn't load favorite links for player " + activeChar.getName());
}
}
else if (command.startsWith("bbs_add_fav"))
{
final String bypass = CommunityBoardHandler.getInstance().removeBypass(activeChar);
if (bypass != null)
{
final String[] parts = bypass.split("&", 2);
if (parts.length != 2)
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Couldn't add favorite link, " + bypass + " it's not a valid bypass!");
return false;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());
ps.setString(2, parts[0].trim());
ps.setString(3, parts[1].trim());
ps.execute();
// Callback
parseCommunityBoardCommand("_bbsgetfav", activeChar);
}
catch (Exception e)
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Couldn't add favorite link " + bypass + " for player " + activeChar.getName());
}
}
}
else if (command.startsWith("_bbsdelfav_"))
{
final String favId = command.replaceAll("_bbsdelfav_", "");
if (!Util.isDigit(favId))
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Couldn't delete favorite link, " + favId + " it's not a valid ID!");
return false;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
{
ps.setInt(1, activeChar.getObjectId());
ps.setInt(2, Integer.parseInt(favId));
ps.execute();
// Callback
parseCommunityBoardCommand("_bbsgetfav", activeChar);
}
catch (Exception e)
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Couldn't delete favorite link ID " + favId + " for player " + activeChar.getName());
}
}
return true;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Friends board.
* @author Zoey76
*/
public class FriendsBoard implements IParseBoardHandler
{
private static final String[] COMMANDS =
{
"_friendlist",
"_friendblocklist"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
if (command.equals("_friendlist"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Friends List", command);
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/friends_list.html");
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else if (command.equals("_friendblocklist"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Ignore list", command);
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/friends_block_list.html");
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else
{
}
return true;
}
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Home board.
* @author Zoey76
*/
public final class HomeBoard implements IParseBoardHandler
{
// SQL Queries
private static final String COUNT_FAVORITES = "SELECT COUNT(*) AS favorites FROM `bbs_favorites` WHERE `playerId`=?";
private static final String[] COMMANDS =
{
"_bbshome",
"_bbstop"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
if (command.equals("_bbshome") || command.equals("_bbstop"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Home", command);
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/home.html");
html = html.replaceAll("%fav_count%", String.valueOf(getFavoriteCount(activeChar)));
html = html.replaceAll("%region_count%", String.valueOf(getRegionCount(activeChar)));
html = html.replaceAll("%clan_count%", String.valueOf(getClansCount()));
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else if (command.startsWith("_bbstop;"))
{
final String path = command.replace("_bbstop;", "");
if ((path.length() > 0) && path.endsWith(".html"))
{
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + path);
CommunityBoardHandler.separateAndSend(html, activeChar);
}
}
return true;
}
/**
* Gets the Favorite links for the given player.
* @param player the player
* @return the favorite links count
*/
private static int getFavoriteCount(L2PcInstance player)
{
int count = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
{
ps.setInt(1, player.getObjectId());
try (ResultSet rs = ps.executeQuery())
{
if (rs.next())
{
count = rs.getInt("favorites");
}
}
}
catch (Exception e)
{
LOG.warning(FavoriteBoard.class.getSimpleName() + ": Coudn't load favorites count for player " + player.getName());
}
return count;
}
/**
* Gets the registered regions count for the given player.
* @param player the player
* @return the registered regions count
*/
private static int getRegionCount(L2PcInstance player)
{
return 0; // TODO: Implement.
}
/**
* Gets the clans count.
* @return the clans count
*/
private static int getClansCount()
{
return ClanTable.getInstance().getClans().length;
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IParseBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Homepage board.
* @author Zoey76
*/
public class HomepageBoard implements IParseBoardHandler
{
private static final String[] COMMANDS =
{
"_bbslink"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
CommunityBoardHandler.separateAndSend(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/homepage.html"), activeChar);
return true;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IWriteBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Mail board.
* @author Zoey76
*/
public class MailBoard implements IWriteBoardHandler
{
private static final String[] COMMANDS =
{
"_maillist"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Mail Command", command);
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/mail.html");
CommunityBoardHandler.separateAndSend(html, activeChar);
return true;
}
@Override
public boolean writeCommunityBoardCommand(L2PcInstance activeChar, String arg1, String arg2, String arg3, String arg4, String arg5)
{
// TODO: Implement.
return false;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IWriteBoardHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Memo board.
* @author Zoey76
*/
public class MemoBoard implements IWriteBoardHandler
{
private static final String[] COMMANDS =
{
"_bbsmemo",
"_bbstopics"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Memo Command", command);
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/memo.html");
CommunityBoardHandler.separateAndSend(html, activeChar);
return true;
}
@Override
public boolean writeCommunityBoardCommand(L2PcInstance activeChar, String arg1, String arg2, String arg3, String arg4, String arg5)
{
// TODO: Implement.
return false;
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack 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 handlers.communityboard;
import java.util.List;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ClanTable;
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
import com.l2jserver.gameserver.handler.IWriteBoardHandler;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.util.Util;
/**
* Region board.
* @author Zoey76
*/
public class RegionBoard implements IWriteBoardHandler
{
// Region data
// @formatter:off
private static final int[] REGIONS = { 1049, 1052, 1053, 1057, 1060, 1059, 1248, 1247, 1056 };
// @formatter:on
private static final String[] COMMANDS =
{
"_bbsloc"
};
@Override
public String[] getCommunityBoardCommands()
{
return COMMANDS;
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{
if (command.equals("_bbsloc"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Region", command);
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/region_list.html");
final StringBuilder sb = new StringBuilder();
final List<Castle> castles = CastleManager.getInstance().getCastles();
for (int i = 0; i < REGIONS.length; i++)
{
final Castle castle = castles.get(i);
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
String link = list.replaceAll("%region_id%", String.valueOf(i));
link = list.replace("%region_name%", String.valueOf(REGIONS[i]));
link = link.replace("%region_owning_clan%", (clan != null ? clan.getName() : "NPC"));
link = link.replace("%region_owning_clan_alliance%", ((clan != null) && (clan.getAllyName() != null) ? clan.getAllyName() : ""));
link = link.replace("%region_tax_rate%", String.valueOf(castle.getTaxRate() * 100) + "%");
sb.append(link);
}
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/region.html");
html = html.replace("%region_list%", sb.toString());
CommunityBoardHandler.separateAndSend(html, activeChar);
}
else if (command.startsWith("_bbsloc;"))
{
CommunityBoardHandler.getInstance().addBypass(activeChar, "Region>", command);
final String id = command.replace("_bbsloc;", "");
if (!Util.isDigit(id))
{
LOG.warning(RegionBoard.class.getSimpleName() + ": Player " + activeChar + " sent and invalid region bypass " + command + "!");
return false;
}
// TODO: Implement.
}
return true;
}
@Override
public boolean writeCommunityBoardCommand(L2PcInstance activeChar, String arg1, String arg2, String arg3, String arg4, String arg5)
{
// TODO: Implement.
return false;
}
}