SummonEffectsTable.java 2.7 KB

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