PlayerSkillHolder.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.holders;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.model.interfaces.ISkillsHolder;
  23. import com.l2jserver.gameserver.model.skills.L2Skill;
  24. /**
  25. * @author UnAfraid
  26. */
  27. public class PlayerSkillHolder implements ISkillsHolder
  28. {
  29. private final Map<Integer, L2Skill> _skills = new HashMap<>();
  30. /**
  31. * @return the map containing this character skills.
  32. */
  33. @Override
  34. public Map<Integer, L2Skill> getSkills()
  35. {
  36. return _skills;
  37. }
  38. /**
  39. * Add a skill to the skills map.<br>
  40. * @param skill
  41. */
  42. @Override
  43. public L2Skill addSkill(L2Skill skill)
  44. {
  45. return _skills.put(skill.getId(), skill);
  46. }
  47. /**
  48. * Return the level of a skill owned by the L2Character.
  49. * @param skillId The identifier of the L2Skill whose level must be returned
  50. * @return The level of the L2Skill identified by skillId
  51. */
  52. @Override
  53. public int getSkillLevel(int skillId)
  54. {
  55. final L2Skill skill = getKnownSkill(skillId);
  56. return (skill == null) ? -1 : skill.getLevel();
  57. }
  58. /**
  59. * @param skillId The identifier of the L2Skill to check the knowledge
  60. * @return the skill from the known skill.
  61. */
  62. @Override
  63. public L2Skill getKnownSkill(int skillId)
  64. {
  65. return _skills.get(skillId);
  66. }
  67. }