RequestExEnchantSkillInfo.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. L2PcInstance activeChar = getClient().getActiveChar();
  48. if (activeChar == null)
  49. return;
  50. if (activeChar.getLevel() < 76)
  51. return;
  52. /* L2Npc trainer = activeChar.getLastFolkNPC();
  53. if (!(trainer instanceof L2NpcInstance))
  54. return;
  55. if (!trainer.canInteract(activeChar) && !activeChar.isGM())
  56. return;*/
  57. L2Skill skill = SkillTable.getInstance().getInfo(_skillId, _skillLvl);
  58. if (skill == null || skill.getId() != _skillId)
  59. {
  60. return;
  61. }
  62. if ( EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(_skillId) == null)
  63. return;
  64. int playerSkillLvl = activeChar.getSkillLevel(_skillId);
  65. if (playerSkillLvl == -1 || playerSkillLvl != _skillLvl)
  66. return;
  67. activeChar.sendPacket(new ExEnchantSkillInfo(_skillId, _skillLvl));
  68. }
  69. /* (non-Javadoc)
  70. * @see com.l2jserver.gameserver.BasePacket#getType()
  71. */
  72. @Override
  73. public String getType()
  74. {
  75. return _C__D0_0E_REQUESTEXENCHANTSKILLINFO;
  76. }
  77. }