EngineerLekon.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package vehicles.EngineerLekon;
  20. import com.l2jserver.gameserver.instancemanager.AirShipManager;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  26. public final class EngineerLekon extends Quest
  27. {
  28. private static final int LEKON = 32557;
  29. private static final int LICENSE = 13559;
  30. private static final int STARSTONE = 13277;
  31. private static final int LICENSE_COST = 10;
  32. private static final SystemMessage SM_NEED_CLANLVL5 = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NEED_CLANLVL_5_TO_SUMMON);
  33. private static final SystemMessage SM_NO_PRIVS = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NO_PRIVILEGES);
  34. private static final SystemMessage SM_LICENSE_ALREADY_ACQUIRED = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
  35. private EngineerLekon()
  36. {
  37. super(-1, EngineerLekon.class.getSimpleName(), "vehicles");
  38. addStartNpc(LEKON);
  39. addFirstTalkId(LEKON);
  40. addTalkId(LEKON);
  41. }
  42. @Override
  43. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  44. {
  45. if ("license".equalsIgnoreCase(event))
  46. {
  47. if ((player.getClan() == null) || (player.getClan().getLevel() < 5))
  48. {
  49. player.sendPacket(SM_NEED_CLANLVL5);
  50. return null;
  51. }
  52. if (!player.isClanLeader())
  53. {
  54. player.sendPacket(SM_NO_PRIVS);
  55. return null;
  56. }
  57. if (AirShipManager.getInstance().hasAirShipLicense(player.getClanId()))
  58. {
  59. player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
  60. return null;
  61. }
  62. if (player.getInventory().getItemByItemId(LICENSE) != null)
  63. {
  64. player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
  65. return null;
  66. }
  67. if (!player.destroyItemByItemId("AirShipLicense", STARSTONE, LICENSE_COST, npc, true))
  68. {
  69. return null;
  70. }
  71. player.addItem("AirShipLicense", LICENSE, 1, npc, true);
  72. return null;
  73. }
  74. return event;
  75. }
  76. @Override
  77. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  78. {
  79. return npc.getId() + ".htm";
  80. }
  81. public static void main(String[] args)
  82. {
  83. new EngineerLekon();
  84. }
  85. }