RequestWithdrawalPledge.java 2.7 KB

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