RequestSaveKeyMapping.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. import com.l2jserver.Config;
  24. import com.l2jserver.gameserver.data.xml.impl.UIData;
  25. import com.l2jserver.gameserver.model.ActionKey;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
  28. /**
  29. * Request Save Key Mapping client packet.
  30. * @author mrTJO, Zoey76
  31. */
  32. public class RequestSaveKeyMapping extends L2GameClientPacket
  33. {
  34. private static final String _C__D0_22_REQUESTSAVEKEYMAPPING = "[C] D0:22 RequestSaveKeyMapping";
  35. private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
  36. private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
  37. @Override
  38. protected void readImpl()
  39. {
  40. int category = 0;
  41. readD(); // Unknown
  42. readD(); // Unknown
  43. final int _tabNum = readD();
  44. for (int i = 0; i < _tabNum; i++)
  45. {
  46. int cmd1Size = readC();
  47. for (int j = 0; j < cmd1Size; j++)
  48. {
  49. UIData.addCategory(_catMap, category, readC());
  50. }
  51. category++;
  52. int cmd2Size = readC();
  53. for (int j = 0; j < cmd2Size; j++)
  54. {
  55. UIData.addCategory(_catMap, category, readC());
  56. }
  57. category++;
  58. int cmdSize = readD();
  59. for (int j = 0; j < cmdSize; j++)
  60. {
  61. int cmd = readD();
  62. int key = readD();
  63. int tgKey1 = readD();
  64. int tgKey2 = readD();
  65. int show = readD();
  66. UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
  67. }
  68. }
  69. readD();
  70. readD();
  71. }
  72. @Override
  73. protected void runImpl()
  74. {
  75. final L2PcInstance player = getActiveChar();
  76. if (!Config.STORE_UI_SETTINGS || (player == null) || (getClient().getState() != GameClientState.IN_GAME))
  77. {
  78. return;
  79. }
  80. player.getUISettings().storeAll(_catMap, _keyMap);
  81. }
  82. @Override
  83. public String getType()
  84. {
  85. return _C__D0_22_REQUESTSAVEKEYMAPPING;
  86. }
  87. }