RequestShortCutReg.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 net.sf.l2j.gameserver.clientpackets;
  16. import net.sf.l2j.gameserver.model.L2ShortCut;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. import net.sf.l2j.gameserver.serverpackets.ShortCutRegister;
  19. /**
  20. * This class ...
  21. *
  22. * @version $Revision: 1.3.4.3 $ $Date: 2005/03/27 15:29:30 $
  23. */
  24. public final class RequestShortCutReg extends L2GameClientPacket
  25. {
  26. private static final String _C__33_REQUESTSHORTCUTREG = "[C] 33 RequestShortCutReg";
  27. private int _type;
  28. private int _id;
  29. private int _slot;
  30. private int _page;
  31. private int _unk;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _type = readD();
  36. int slot = readD();
  37. _id = readD();
  38. _unk = readD();
  39. _slot = slot % 12;
  40. _page = slot / 12;
  41. }
  42. @Override
  43. protected void runImpl()
  44. {
  45. L2PcInstance activeChar = getClient().getActiveChar();
  46. if (activeChar == null)
  47. return;
  48. switch (_type)
  49. {
  50. case 0x01: // item
  51. case 0x03: // action
  52. case 0x04: // macro
  53. case 0x05: // recipe
  54. {
  55. L2ShortCut sc = new L2ShortCut(_slot, _page, _type, _id, -1, _unk);
  56. sendPacket(new ShortCutRegister(sc));
  57. activeChar.registerShortCut(sc);
  58. break;
  59. }
  60. case 0x02: // skill
  61. {
  62. int level = activeChar.getSkillLevel( _id );
  63. if (level > 0)
  64. {
  65. L2ShortCut sc = new L2ShortCut(_slot, _page, _type, _id, level, _unk);
  66. sendPacket(new ShortCutRegister(sc));
  67. activeChar.registerShortCut(sc);
  68. }
  69. break;
  70. }
  71. }
  72. }
  73. /* (non-Javadoc)
  74. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  75. */
  76. @Override
  77. public String getType()
  78. {
  79. return _C__33_REQUESTSHORTCUTREG;
  80. }
  81. }