RequestQuestAbort.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 net.sf.l2j.gameserver.clientpackets;
  16. import java.util.logging.Logger;
  17. import net.sf.l2j.Config;
  18. import net.sf.l2j.gameserver.instancemanager.QuestManager;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.model.quest.Quest;
  21. import net.sf.l2j.gameserver.model.quest.QuestState;
  22. import net.sf.l2j.gameserver.serverpackets.QuestList;
  23. /**
  24. * This class ...
  25. *
  26. * @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:30 $
  27. */
  28. public final class RequestQuestAbort extends L2GameClientPacket
  29. {
  30. private static final String _C__64_REQUESTQUESTABORT = "[C] 64 RequestQuestAbort";
  31. private static Logger _log = Logger.getLogger(RequestQuestAbort.class.getName());
  32. private int _questId;
  33. @Override
  34. protected void readImpl()
  35. {
  36. _questId = readD();
  37. }
  38. @Override
  39. protected void runImpl()
  40. {
  41. L2PcInstance activeChar = getClient().getActiveChar();
  42. if (activeChar == null)
  43. return;
  44. Quest qe = QuestManager.getInstance().getQuest(_questId);
  45. if (qe != null)
  46. {
  47. QuestState qs = activeChar.getQuestState(qe.getName());
  48. if(qs != null)
  49. {
  50. qs.exitQuest(true);
  51. activeChar.sendMessage("Quest aborted.");
  52. QuestList ql = new QuestList();
  53. activeChar.sendPacket(ql);
  54. }
  55. else
  56. {
  57. if (Config.DEBUG) _log.info("Player '"+activeChar.getName()+"' try to abort quest "+qe.getName()+" but he didn't have it started.");
  58. }
  59. }
  60. else
  61. {
  62. if (Config.DEBUG) _log.warning("Quest (id='"+_questId+"') not found.");
  63. }
  64. }
  65. /* (non-Javadoc)
  66. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  67. */
  68. @Override
  69. public String getType()
  70. {
  71. return _C__64_REQUESTQUESTABORT;
  72. }
  73. }