GMViewSkillInfo.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. writeC(SkillTable.getInstance().isEnchantable(skill.getId()) ? 1 : 0);
  47. }
  48. }
  49. /* (non-Javadoc)
  50. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  51. */
  52. @Override
  53. public String getType()
  54. {
  55. return _S__91_GMViewSkillInfo;
  56. }
  57. }