RequestExEnchantSkillInfo.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.network.clientpackets;
  16. import com.l2jserver.gameserver.datatables.EnchantGroupsTable;
  17. import com.l2jserver.gameserver.datatables.SkillTable;
  18. import com.l2jserver.gameserver.model.L2Skill;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.serverpackets.ExEnchantSkillInfo;
  21. /**
  22. * Format (ch) dd
  23. * c: (id) 0xD0
  24. * h: (subid) 0x06
  25. * d: skill id
  26. * d: skill lvl
  27. * @author -Wooden-
  28. *
  29. */
  30. public final class RequestExEnchantSkillInfo extends L2GameClientPacket
  31. {
  32. private static final String _C__D0_0E_REQUESTEXENCHANTSKILLINFO = "[C] D0:0E RequestExEnchantSkillInfo";
  33. private int _skillId;
  34. private int _skillLvl;
  35. @Override
  36. protected void readImpl()
  37. {
  38. _skillId = readD();
  39. _skillLvl = readD();
  40. }
  41. /* (non-Javadoc)
  42. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#runImpl()
  43. */
  44. @Override
  45. protected void runImpl()
  46. {
  47. if (_skillId <= 0 || _skillLvl <= 0) // minimal sanity check
  48. return;
  49. L2PcInstance activeChar = getClient().getActiveChar();
  50. if (activeChar == null)
  51. return;
  52. if (activeChar.getLevel() < 76)
  53. return;
  54. /* L2Npc trainer = activeChar.getLastFolkNPC();
  55. if (!(trainer instanceof L2NpcInstance))
  56. return;
  57. if (!trainer.canInteract(activeChar) && !activeChar.isGM())
  58. return;*/
  59. L2Skill skill = SkillTable.getInstance().getInfo(_skillId, _skillLvl);
  60. if (skill == null || skill.getId() != _skillId)
  61. {
  62. return;
  63. }
  64. if ( EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(_skillId) == null)
  65. return;
  66. int playerSkillLvl = activeChar.getSkillLevel(_skillId);
  67. if (playerSkillLvl == -1 || playerSkillLvl != _skillLvl)
  68. return;
  69. activeChar.sendPacket(new ExEnchantSkillInfo(_skillId, _skillLvl));
  70. }
  71. /* (non-Javadoc)
  72. * @see com.l2jserver.gameserver.BasePacket#getType()
  73. */
  74. @Override
  75. public String getType()
  76. {
  77. return _C__D0_0E_REQUESTEXENCHANTSKILLINFO;
  78. }
  79. }