FriendStatusPacket.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * <BR>
  19. * Inform player about friend online status change
  20. * <BR>
  21. * Format: cdSd<BR>
  22. * d: Online/Offline<BR>
  23. * S: Friend Name <BR>
  24. * d: Player Object ID <BR>
  25. *
  26. * @author JIV
  27. *
  28. */
  29. public class FriendStatusPacket extends L2GameServerPacket
  30. {
  31. private static final String _S__FA_FRIENDLIST = "[S] 77 FriendStatusPacket";
  32. private boolean _online;
  33. private int _objid;
  34. private String _name;
  35. public FriendStatusPacket(int objId)
  36. {
  37. _objid = objId;
  38. _name = CharNameTable.getInstance().getNameById(objId);
  39. _online = L2World.getInstance().getPlayer(objId) != null;
  40. }
  41. @Override
  42. protected final void writeImpl()
  43. {
  44. writeC(0x77);
  45. writeD(_online ? 1 : 0);
  46. writeS(_name);
  47. writeD(_objid);
  48. }
  49. /*
  50. * (non-Javadoc)
  51. *
  52. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  53. */
  54. @Override
  55. public String getType()
  56. {
  57. return _S__FA_FRIENDLIST;
  58. }
  59. }