FriendPacket.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under the terms of the
  3. * GNU General Public License as published by the Free Software Foundation, either version 3 of the
  4. * License, or (at your option) any later version.
  5. *
  6. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  7. * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  8. * General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with this program. If
  11. * not, see <http://www.gnu.org/licenses/>.
  12. */
  13. package com.l2jserver.gameserver.network.serverpackets;
  14. import com.l2jserver.gameserver.datatables.CharNameTable;
  15. import com.l2jserver.gameserver.model.L2World;
  16. /**
  17. * Support for "Chat with Friends" dialog.
  18. *
  19. * Add new friend or delete.
  20. * <BR>
  21. * Format: cddSdd <BR>
  22. * d: action <BR>
  23. * d: Player Object ID <BR>
  24. * S: Friend Name <BR>
  25. * d: Online/Offline <BR>
  26. * d: Unknown (0 if offline)<BR>
  27. *
  28. * @author JIV
  29. *
  30. */
  31. public class FriendPacket extends L2GameServerPacket
  32. {
  33. // private static Logger _log = Logger.getLogger(FriendList.class.getName());
  34. private static final String _S__FA_FRIENDLIST = "[S] 76 FriendPacket";
  35. private boolean _action, _online;
  36. private int _objid;
  37. private String _name;
  38. /**
  39. *
  40. * @param action - true for adding, false for remove
  41. */
  42. public FriendPacket(boolean action, int objId)
  43. {
  44. _action = action;
  45. _objid = objId;
  46. _name = CharNameTable.getInstance().getNameById(objId);
  47. _online = L2World.getInstance().getPlayer(objId) != null;
  48. }
  49. @Override
  50. protected final void writeImpl()
  51. {
  52. writeC(0x76);
  53. writeD(_action ? 1 : 3); // 1-add 3-remove
  54. writeD(_objid);
  55. writeS(_name);
  56. writeD(_online ? 1 : 0);
  57. writeD(_online ? _objid : 0);
  58. }
  59. /*
  60. * (non-Javadoc)
  61. *
  62. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  63. */
  64. @Override
  65. public String getType()
  66. {
  67. return _S__FA_FRIENDLIST;
  68. }
  69. }