123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package com.l2jserver.communityserver.communityboard.boards;
- import java.util.logging.Logger;
- import javolution.text.TextBuilder;
- import com.l2jserver.communityserver.cache.HtmCache;
- import com.l2jserver.communityserver.communityboard.CommunityBoard;
- import com.l2jserver.communityserver.communityboard.CommunityBoardManager;
- import com.l2jserver.communityserver.model.L2Player;
- public final class FriendBoard extends CommunityBoard
- {
- private static Logger _log = Logger.getLogger(FriendBoard.class.getName());
- public FriendBoard(final CommunityBoardManager mgr)
- {
- super(mgr);
- }
-
- @Override
- public void parseCmd(final int playerObjId, final String cmd)
- {
- if (cmd.equals("_bbsfriend"))
- showMainPage(playerObjId, false);
- else if (cmd.split(";")[1].equalsIgnoreCase("mail"))
- {
- showMailWrite(playerObjId);
- }
- else if (cmd.split(";")[1].equalsIgnoreCase("select"))
- {
- L2Player player = super.getCommunityBoardManager().getPlayer(playerObjId);
- Integer friendId = Integer.valueOf(cmd.split(";")[2]);
- if (!player.getSelectedFriendsList().contains(friendId))
- player.selectFriend(friendId);
- showMainPage(playerObjId, false);
- }
- else if (cmd.split(";")[1].equalsIgnoreCase("deselect"))
- {
- L2Player player = super.getCommunityBoardManager().getPlayer(playerObjId);
- player.deSelectFriend(Integer.valueOf(cmd.split(";")[2]));
- showMainPage(playerObjId, false);
- }
- else if (cmd.split(";")[1].equalsIgnoreCase("delconfirm"))
- {
- showMainPage(playerObjId, true);
- }
- else
- _log.info("Friend command missing: " + cmd.split(";")[1]);
- }
-
- public final void showMainPage(final int playerObjId, boolean delMsg)
- {
- String content = HtmCache.getInstance().getHtm("data/staticfiles/html/friend.htm");
- TextBuilder fList = new TextBuilder();
- L2Player player = super.getCommunityBoardManager().getPlayer(playerObjId);
- for (int f:player.getFriendList())
- {
- L2Player friend = super.getCommunityBoardManager().getPlayer(f);
- fList.append("<a action=\"bypass _bbsfriend;select;" + friend.getObjId() + "\">" + friend.getName() + "</a> (" + (friend.isOnline() ? "On":"Off") + ") ");
- }
- content = content.replaceAll("%friendslist%", fList.toString());
- fList.clear();
- for (int f:player.getSelectedFriendsList())
- {
- L2Player friend = super.getCommunityBoardManager().getPlayer(f);
- fList.append("<a action=\"bypass _bbsfriend;deselect;" + friend.getObjId() + "\">" + friend.getName() + "</a>;");
- }
- content = content.replaceAll("%selectedFriendsList%", fList.toString());
- if (delMsg)
- content = content.replaceAll("%deleteMSG%", "<br>\nAre you sure you want to delete all messages from your Friends List? <button value = \"OK\" action=\"bypass _bssfriend;delall\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\">");
- else
- content = content.replaceAll("%deleteMSG%", "");
- super.send(playerObjId, content);
- }
-
- public final void showMailWrite(final int playerObjId)
- {
- String title = " ";
- String message = " ";
- String content = HtmCache.getInstance().getHtm("data/staticfiles/html/mail-write.htm");
- content = content.replaceAll("%maillink%", "<a action=\"bypass _bbsfriend\">&\\$904;</a> > &\\$915;");
- content = content.replaceAll("%playerObjId%", String.valueOf(playerObjId));
- content = content.replaceAll("%postId%", "-1");
-
- String toList = "";
- L2Player player = super.getCommunityBoardManager().getPlayer(playerObjId);
- for (int f:player.getSelectedFriendsList())
- {
- if (toList.equals(""))
- toList += super.getCommunityBoardManager().getPlayer(f).getName();
- else
- toList += (";" + super.getCommunityBoardManager().getPlayer(f).getName());
- }
- super.sendWrite(playerObjId, content, message, title, toList);
- }
- @Override
- public final void parseWrite(final int playerObjId, final String ar1, final String ar2, final String ar3, final String ar4, final String ar5)
- {
-
- }
- }
|