SkillHandler.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.handler;
  16. import java.util.Map;
  17. import java.util.TreeMap;
  18. import com.l2jserver.gameserver.templates.skills.L2SkillType;
  19. /**
  20. * This class ...
  21. *
  22. * @version $Revision: 1.1.4.4 $ $Date: 2005/04/03 15:55:06 $
  23. */
  24. public class SkillHandler
  25. {
  26. private Map<L2SkillType, ISkillHandler> _datatable;
  27. public static SkillHandler getInstance()
  28. {
  29. return SingletonHolder._instance;
  30. }
  31. private SkillHandler()
  32. {
  33. _datatable = new TreeMap<L2SkillType, ISkillHandler>();
  34. }
  35. public void registerSkillHandler(ISkillHandler handler)
  36. {
  37. L2SkillType[] types = handler.getSkillIds();
  38. for (L2SkillType t : types)
  39. {
  40. _datatable.put(t, handler);
  41. }
  42. }
  43. public ISkillHandler getSkillHandler(L2SkillType skillType)
  44. {
  45. return _datatable.get(skillType);
  46. }
  47. /**
  48. * @return
  49. */
  50. public int size()
  51. {
  52. return _datatable.size();
  53. }
  54. @SuppressWarnings("synthetic-access")
  55. private static class SingletonHolder
  56. {
  57. protected static final SkillHandler _instance = new SkillHandler();
  58. }
  59. }