SkillChannelized.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2004-2013 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.model.skills;
  20. import java.util.Map;
  21. import java.util.concurrent.ConcurrentHashMap;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. /**
  24. * @author UnAfraid
  25. */
  26. public final class SkillChannelized
  27. {
  28. private final Map<Integer, Map<Integer, L2Character>> _channelizers = new ConcurrentHashMap<>();
  29. public void addChannelizer(int skillId, L2Character channelizer)
  30. {
  31. if (!_channelizers.containsKey(skillId))
  32. {
  33. _channelizers.put(skillId, new ConcurrentHashMap<Integer, L2Character>());
  34. }
  35. _channelizers.get(skillId).put(channelizer.getObjectId(), channelizer);
  36. }
  37. public void removeChannelizer(int skillId, L2Character channelizer)
  38. {
  39. if (_channelizers.containsKey(skillId))
  40. {
  41. _channelizers.get(skillId).remove(channelizer.getObjectId());
  42. }
  43. }
  44. public int getChannerlizersSize(int skillId)
  45. {
  46. if (_channelizers.containsKey(skillId))
  47. {
  48. return _channelizers.get(skillId).size();
  49. }
  50. return 0;
  51. }
  52. public Map<Integer, L2Character> getChannelizers(int skillId)
  53. {
  54. return _channelizers.get(skillId);
  55. }
  56. public void abortChannelization()
  57. {
  58. for (Map<Integer, L2Character> map : _channelizers.values())
  59. {
  60. for (L2Character channelizer : map.values())
  61. {
  62. channelizer.abortCast();
  63. }
  64. }
  65. _channelizers.clear();
  66. }
  67. public boolean isChannelized()
  68. {
  69. for (Map<Integer, L2Character> map : _channelizers.values())
  70. {
  71. if (!map.isEmpty())
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. }