NpcBuffers.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2004-2014 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 ai.npc.NpcBuffers;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.ThreadPoolManager;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. /**
  25. * @author UnAfraid
  26. */
  27. public final class NpcBuffers extends AbstractNpcAI
  28. {
  29. private final NpcBuffersData _npcBuffers = new NpcBuffersData();
  30. private NpcBuffers()
  31. {
  32. super(NpcBuffers.class.getSimpleName(), "npc");
  33. for (int npcId : _npcBuffers.getNpcBufferIds())
  34. {
  35. // TODO: Cleanup once npc rework is finished and default html is configurable.
  36. addFirstTalkId(npcId);
  37. addSpawnId(npcId);
  38. }
  39. }
  40. // TODO: Cleanup once npc rework is finished and default html is configurable.
  41. @Override
  42. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  43. {
  44. return null;
  45. }
  46. @Override
  47. public String onSpawn(L2Npc npc)
  48. {
  49. final NpcBufferData data = _npcBuffers.getNpcBuffer(npc.getId());
  50. for (NpcBufferSkillData skill : data.getSkills())
  51. {
  52. ThreadPoolManager.getInstance().scheduleAi(new NpcBufferAI(npc, skill), skill.getInitialDelay());
  53. }
  54. return super.onSpawn(npc);
  55. }
  56. public static void main(String[] args)
  57. {
  58. new NpcBuffers();
  59. }
  60. }