2
0

RequestWithdrawalPledge.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.Config;
  17. import com.l2jserver.gameserver.model.L2Clan;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.SystemMessageId;
  20. import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListDelete;
  21. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  22. /**
  23. * This class ...
  24. *
  25. * @version $Revision: 1.3.2.1.2.3 $ $Date: 2005/03/27 15:29:30 $
  26. */
  27. public final class RequestWithdrawalPledge extends L2GameClientPacket
  28. {
  29. private static final String _C__26_REQUESTWITHDRAWALPLEDGE = "[C] 26 RequestWithdrawalPledge";
  30. //static Logger _log = Logger.getLogger(RequestWithdrawalPledge.class.getName());
  31. @Override
  32. protected void readImpl()
  33. {
  34. // trigger
  35. }
  36. @Override
  37. protected void runImpl()
  38. {
  39. L2PcInstance activeChar = getClient().getActiveChar();
  40. if (activeChar == null)
  41. {
  42. return;
  43. }
  44. if (activeChar.getClan() == null)
  45. {
  46. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
  47. return;
  48. }
  49. if (activeChar.isClanLeader())
  50. {
  51. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_CANNOT_WITHDRAW));
  52. return;
  53. }
  54. if (activeChar.isInCombat())
  55. {
  56. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_LEAVE_DURING_COMBAT));
  57. return;
  58. }
  59. L2Clan clan = activeChar.getClan();
  60. clan.removeClanMember(activeChar.getObjectId(), System.currentTimeMillis() + Config.ALT_CLAN_JOIN_DAYS * 86400000L); //24*60*60*1000 = 86400000
  61. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_WITHDRAWN_FROM_THE_CLAN);
  62. sm.addString(activeChar.getName());
  63. clan.broadcastToOnlineMembers(sm);
  64. sm = null;
  65. // Remove the Player From the Member list
  66. clan.broadcastToOnlineMembers(new PledgeShowMemberListDelete(activeChar.getName()));
  67. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_CLAN));
  68. activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_MUST_WAIT_BEFORE_JOINING_ANOTHER_CLAN));
  69. }
  70. /* (non-Javadoc)
  71. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  72. */
  73. @Override
  74. public String getType()
  75. {
  76. return _C__26_REQUESTWITHDRAWALPLEDGE;
  77. }
  78. }