RequestHennaRemove.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.clientpackets;
  16. import com.l2jserver.gameserver.model.L2HennaInstance;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.network.SystemMessageId;
  19. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  20. /**
  21. * This class ...
  22. *
  23. * @version $Revision$ $Date$
  24. */
  25. public final class RequestHennaRemove extends L2GameClientPacket
  26. {
  27. private static final String _C__BC_RequestHennaRemove = "[C] bc RequestHennaRemove";
  28. private int _symbolId;
  29. // format cd
  30. /**
  31. * packet type id 0xbb
  32. * format: cd
  33. * @param decrypt
  34. */
  35. @Override
  36. protected void readImpl()
  37. {
  38. _symbolId = readD();
  39. }
  40. @Override
  41. protected void runImpl()
  42. {
  43. L2PcInstance activeChar = getClient().getActiveChar();
  44. if (activeChar == null)
  45. return;
  46. if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("HennaRemove"))
  47. return;
  48. for (int i = 1; i <= 3; i++)
  49. {
  50. L2HennaInstance henna = activeChar.getHenna(i);
  51. if (henna != null && henna.getSymbolId() == _symbolId)
  52. {
  53. if (activeChar.getAdena() >= (henna.getPrice() / 5))
  54. activeChar.removeHenna(i);
  55. else
  56. activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
  57. }
  58. }
  59. }
  60. /* (non-Javadoc)
  61. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  62. */
  63. @Override
  64. public String getType()
  65. {
  66. return _C__BC_RequestHennaRemove;
  67. }
  68. }