/* * 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 . */ 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("" + friend.getName() + " (" + (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("" + friend.getName() + ";"); } content = content.replaceAll("%selectedFriendsList%", fList.toString()); if (delMsg) content = content.replaceAll("%deleteMSG%", "
\nAre you sure you want to delete all messages from your Friends List?