ShortCutInit.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.serverpackets;
  16. import net.sf.l2j.gameserver.model.L2ShortCut;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. /**
  19. *
  20. * ShortCutInit
  21. * format d *(1dddd)/(2ddddd)/(3dddd)
  22. *
  23. * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/03/27 15:29:39 $
  24. */
  25. public final class ShortCutInit extends L2GameServerPacket
  26. {
  27. private static final String _S__57_SHORTCUTINIT = "[S] 45 ShortCutInit";
  28. private L2ShortCut[] _shortCuts;
  29. private L2PcInstance _activeChar;
  30. public ShortCutInit(L2PcInstance activeChar)
  31. {
  32. _activeChar = activeChar;
  33. if (_activeChar == null)
  34. return;
  35. _shortCuts = _activeChar.getAllShortCuts();
  36. }
  37. @Override
  38. protected final void writeImpl()
  39. {
  40. writeC(0x45);
  41. writeD(_shortCuts.length);
  42. for (int i = 0; i < _shortCuts.length; i++)
  43. {
  44. L2ShortCut sc = _shortCuts[i];
  45. writeD(sc.getType());
  46. writeD(sc.getSlot() + sc.getPage() * 12);
  47. switch(sc.getType())
  48. {
  49. case L2ShortCut.TYPE_ITEM: //1
  50. writeD(sc.getId());
  51. writeD(0x01);
  52. writeD(-1);
  53. writeD(0x00);
  54. writeD(0x00);
  55. writeH(0x00);
  56. writeH(0x00);
  57. break;
  58. case L2ShortCut.TYPE_SKILL: //2
  59. writeD(sc.getId());
  60. writeD(sc.getLevel());
  61. writeC(0x00); // C5
  62. writeD(0x01); // C6
  63. break;
  64. case L2ShortCut.TYPE_ACTION: //3
  65. writeD(sc.getId());
  66. writeD(0x01); // C6
  67. break;
  68. case L2ShortCut.TYPE_MACRO: //4
  69. writeD(sc.getId());
  70. writeD(0x01); // C6
  71. break;
  72. case L2ShortCut.TYPE_RECIPE: //5
  73. writeD(sc.getId());
  74. writeD(0x01); // C6
  75. break;
  76. default:
  77. writeD(sc.getId());
  78. writeD(0x01); // C6
  79. }
  80. }
  81. }
  82. /* (non-Javadoc)
  83. * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
  84. */
  85. @Override
  86. public String getType()
  87. {
  88. return _S__57_SHORTCUTINIT;
  89. }
  90. }