GMSkillTable.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 com.l2jserver.gameserver.model.L2Skill;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.util.Util;
  19. /**
  20. * @author Gnacik, Zoey76
  21. */
  22. public class GMSkillTable
  23. {
  24. private static final L2Skill[] _gmSkills = new L2Skill[46];
  25. private static final L2Skill[] _gmAuraSkills = new L2Skill[46];
  26. private static final int[] _gmSkillsId = { 7029, 7041, 7042, 7043, 7044, 7045, 7046, 7047, 7048, 7049, 7050, 7051, 7052, 7053, 7054, 7055, 7056, 7057, 7058, 7059, 7060, 7061, 7062, 7063, 7064, 7088, 7089, 7090, 7091, 7092, 7093, 7094, 7095, 7096, 23238, 23239, 23240, 23241, 23242, 23243, 23244, 23245, 23246, 23247, 23248, 23249 };
  27. private static final int[] _gmAuraSkillsId = { 7029, 23249, 23253, 23254, 23255, 23256, 23257, 23258, 23259, 23260, 23261, 23262, 23263, 23264, 23265, 23266, 23267, 23268, 23269, 23270, 23271, 23272, 23273, 23274, 23275, 23276, 23277, 23278, 23279, 23280, 23281, 23282, 23283, 23284, 23285, 23286, 23287, 23288, 23289, 23290, 23291, 23292, 23293, 23294, 23295, 23296 };
  28. private GMSkillTable()
  29. {
  30. for (int i = 0; i < _gmSkillsId.length; i++)
  31. {
  32. _gmSkills[i] = SkillTable.getInstance().getInfo(_gmSkillsId[i], 1);
  33. _gmAuraSkills[i] = SkillTable.getInstance().getInfo(_gmAuraSkillsId[i], 1);
  34. }
  35. }
  36. public static GMSkillTable getInstance()
  37. {
  38. return SingletonHolder._instance;
  39. }
  40. public static L2Skill[] getGMSkills()
  41. {
  42. return _gmSkills;
  43. }
  44. public static L2Skill[] getGMAuraSkills()
  45. {
  46. return _gmAuraSkills;
  47. }
  48. public static boolean isGMSkill(int skillid)
  49. {
  50. return Util.contains(_gmSkillsId, skillid) || Util.contains(_gmAuraSkillsId, skillid);
  51. }
  52. public void addSkills(L2PcInstance gmchar, boolean auraSkills)
  53. {
  54. final L2Skill[] skills = auraSkills ? getGMAuraSkills() : getGMSkills();
  55. for (L2Skill s : skills)
  56. {
  57. gmchar.addSkill(s, false); // Don't Save GM skills to database
  58. }
  59. }
  60. public void switchSkills(L2PcInstance gmchar, boolean toAuraSkills)
  61. {
  62. final L2Skill[] skills = toAuraSkills ? getGMSkills() : getGMAuraSkills();
  63. for (L2Skill s : skills)
  64. {
  65. gmchar.removeSkill(s, false); // Don't Save GM skills to database
  66. }
  67. addSkills(gmchar, toAuraSkills);
  68. }
  69. @SuppressWarnings("synthetic-access")
  70. private static class SingletonHolder
  71. {
  72. protected static final GMSkillTable _instance = new GMSkillTable();
  73. }
  74. }