SummonEffectsTable.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 com.l2jserver.gameserver.datatables;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.skills.Skill;
  25. /**
  26. * @author Nyaran
  27. */
  28. public class SummonEffectsTable
  29. {
  30. /** Servitors **/
  31. // Map tree
  32. // -> key: charObjectId, value: classIndex Map
  33. // --> key: classIndex, value: servitors Map
  34. // ---> key: servitorSkillId, value: Effects list
  35. private final Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> _servitorEffects = new HashMap<>();
  36. public Map<Integer, Map<Integer, Map<Integer, List<SummonEffect>>>> getServitorEffectsOwner()
  37. {
  38. return _servitorEffects;
  39. }
  40. public Map<Integer, List<SummonEffect>> getServitorEffects(L2PcInstance owner)
  41. {
  42. final Map<Integer, Map<Integer, List<SummonEffect>>> servitorMap = _servitorEffects.get(owner.getObjectId());
  43. if (servitorMap == null)
  44. {
  45. return null;
  46. }
  47. return servitorMap.get(owner.getClassIndex());
  48. }
  49. /** Pets **/
  50. private final Map<Integer, List<SummonEffect>> _petEffects = new HashMap<>(); // key: petItemObjectId, value: Effects list
  51. public Map<Integer, List<SummonEffect>> getPetEffects()
  52. {
  53. return _petEffects;
  54. }
  55. public class SummonEffect
  56. {
  57. Skill _skill;
  58. int _effectCurTime;
  59. public SummonEffect(Skill skill, int effectCurTime)
  60. {
  61. _skill = skill;
  62. _effectCurTime = effectCurTime;
  63. }
  64. public Skill getSkill()
  65. {
  66. return _skill;
  67. }
  68. public int getEffectCurTime()
  69. {
  70. return _effectCurTime;
  71. }
  72. }
  73. public static SummonEffectsTable getInstance()
  74. {
  75. return SingletonHolder._instance;
  76. }
  77. private static class SingletonHolder
  78. {
  79. protected static final SummonEffectsTable _instance = new SummonEffectsTable();
  80. }
  81. }