GMViewSkillInfo.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.serverpackets;
  16. import com.l2jserver.gameserver.datatables.SkillTable;
  17. import com.l2jserver.gameserver.model.L2Skill;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. public class GMViewSkillInfo extends L2GameServerPacket
  20. {
  21. private static final String _S__91_GMViewSkillInfo = "[S] 97 GMViewSkillInfo";
  22. private L2PcInstance _activeChar;
  23. private L2Skill[] _skills;
  24. public GMViewSkillInfo (L2PcInstance cha)
  25. {
  26. _activeChar = cha;
  27. _skills = _activeChar.getAllSkills();
  28. if (_skills.length == 0)
  29. _skills = new L2Skill[0];
  30. }
  31. @Override
  32. protected final void writeImpl()
  33. {
  34. writeC(0x97);
  35. writeS(_activeChar.getName());
  36. writeD(_skills.length);
  37. boolean isDisabled = false;
  38. if (_activeChar.getClan() != null)
  39. isDisabled = _activeChar.getClan().getReputationScore() < 0;
  40. for (L2Skill skill: _skills)
  41. {
  42. writeD(skill.isPassive() ? 1 : 0);
  43. writeD(skill.getLevel());
  44. writeD(skill.getId());
  45. writeC(isDisabled && skill.isClanSkill() ? 1 : 0);
  46. int skillMaxLevel = SkillTable.getInstance().getMaxLevel(skill.getId());
  47. boolean isEnchanted = skillMaxLevel > 100;
  48. writeC(isEnchanted ? 1 : 0);
  49. }
  50. }
  51. /* (non-Javadoc)
  52. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  53. */
  54. @Override
  55. public String getType()
  56. {
  57. return _S__91_GMViewSkillInfo;
  58. }
  59. }