SummonEffectsTable.java 2.6 KB

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