GmViewQuestInfo.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  17. import com.l2jserver.gameserver.model.quest.Quest;
  18. import com.l2jserver.gameserver.model.quest.QuestState;
  19. /**
  20. * Sh (dd) h (dddd)
  21. * @author Tempy
  22. */
  23. public class GmViewQuestInfo extends L2GameServerPacket
  24. {
  25. private static final String _S__AC_GMVIEWQUESTLIST = "[S] 99 GMViewQuestList";
  26. private L2PcInstance _activeChar;
  27. public GmViewQuestInfo(L2PcInstance cha)
  28. {
  29. _activeChar = cha;
  30. }
  31. @Override
  32. protected final void writeImpl()
  33. {
  34. writeC(0x99);
  35. writeS(_activeChar.getName());
  36. Quest[] questList = _activeChar.getAllActiveQuests();
  37. if (questList.length == 0)
  38. {
  39. writeC(0);
  40. writeH(0);
  41. writeH(0);
  42. return;
  43. }
  44. writeH(questList.length); // quest count
  45. for (Quest q : questList)
  46. {
  47. writeD(q.getQuestIntId());
  48. QuestState qs = _activeChar.getQuestState(q.getName());
  49. if (qs == null)
  50. {
  51. writeD(0);
  52. continue;
  53. }
  54. writeD(qs.getInt("cond")); // stage of quest progress
  55. }
  56. }
  57. /* (non-Javadoc)
  58. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  59. */
  60. @Override
  61. public String getType()
  62. {
  63. return _S__AC_GMVIEWQUESTLIST;
  64. }
  65. }