CharacterDelete.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 java.util.logging.Level;
  17. import java.util.logging.Logger;
  18. import net.sf.l2j.Config;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.serverpackets.CharDeleteFail;
  21. import net.sf.l2j.gameserver.serverpackets.CharDeleteSuccess;
  22. import net.sf.l2j.gameserver.serverpackets.CharSelectionInfo;
  23. /**
  24. * This class ...
  25. *
  26. * @version $Revision: 1.8.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
  27. */
  28. public final class CharacterDelete extends L2GameClientPacket
  29. {
  30. private static final String _C__0C_CHARACTERDELETE = "[C] 0C CharacterDelete";
  31. private static Logger _log = Logger.getLogger(CharacterDelete.class.getName());
  32. // cd
  33. private int _charSlot;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _charSlot = readD();
  38. }
  39. @Override
  40. protected void runImpl()
  41. {
  42. if (Config.DEBUG) _log.fine("deleting slot:" + _charSlot);
  43. L2PcInstance character = null;
  44. try
  45. {
  46. if (Config.DELETE_DAYS == 0)
  47. character = getClient().deleteChar(_charSlot);
  48. else
  49. character = getClient().markToDeleteChar(_charSlot);
  50. }
  51. catch (Exception e)
  52. {
  53. _log.log(Level.SEVERE, "Error:", e);
  54. }
  55. if (character == null)
  56. {
  57. sendPacket(new CharDeleteSuccess());
  58. }
  59. else
  60. {
  61. if (character.isClanLeader())
  62. {
  63. sendPacket(new CharDeleteFail(CharDeleteFail.REASON_CLAN_LEADERS_MAY_NOT_BE_DELETED));
  64. }
  65. else
  66. {
  67. sendPacket(new CharDeleteFail(CharDeleteFail.REASON_YOU_MAY_NOT_DELETE_CLAN_MEMBER));
  68. }
  69. }
  70. CharSelectionInfo cl = new CharSelectionInfo(getClient().getAccountName(), getClient().getSessionId().playOkID1, 0);
  71. sendPacket(cl);
  72. getClient().setCharSelection(cl.getCharInfo());
  73. }
  74. /* (non-Javadoc)
  75. * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
  76. */
  77. @Override
  78. public String getType()
  79. {
  80. return _C__0C_CHARACTERDELETE;
  81. }
  82. }