RequestSurrenderPersonally.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 java.util.logging.Logger;
  17. import com.l2jserver.gameserver.datatables.ClanTable;
  18. import com.l2jserver.gameserver.model.L2Clan;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  22. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  23. public final class RequestSurrenderPersonally extends L2GameClientPacket
  24. {
  25. private static final String _C__69_REQUESTSURRENDERPERSONALLY = "[C] 69 RequestSurrenderPersonally";
  26. private static Logger _log = Logger.getLogger(RequestSurrenderPledgeWar.class.getName());
  27. private String _pledgeName;
  28. private L2Clan _clan;
  29. private L2PcInstance _activeChar;
  30. @Override
  31. protected void readImpl()
  32. {
  33. _pledgeName = readS();
  34. }
  35. @Override
  36. protected void runImpl()
  37. {
  38. _activeChar = getClient().getActiveChar();
  39. if (_activeChar == null)
  40. return;
  41. _log.info("RequestSurrenderPersonally by "+getClient().getActiveChar().getName()+" with "+_pledgeName);
  42. _clan = getClient().getActiveChar().getClan();
  43. L2Clan clan = ClanTable.getInstance().getClanByName(_pledgeName);
  44. if(_clan == null)
  45. return;
  46. if(clan == null)
  47. {
  48. _activeChar.sendMessage("No such clan.");
  49. _activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  50. return;
  51. }
  52. if(!_clan.isAtWarWith(clan.getClanId()) || _activeChar.getWantsPeace() == 1)
  53. {
  54. _activeChar.sendMessage("You aren't at war with this clan.");
  55. _activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  56. return;
  57. }
  58. _activeChar.setWantsPeace(1);
  59. _activeChar.deathPenalty(false, false, false);
  60. SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_PERSONALLY_SURRENDERED_TO_THE_S1_CLAN);
  61. msg.addString(_pledgeName);
  62. _activeChar.sendPacket(msg);
  63. msg = null;
  64. ClanTable.getInstance().checkSurrender(_clan, clan);
  65. }
  66. @Override
  67. public String getType()
  68. {
  69. return _C__69_REQUESTSURRENDERPERSONALLY;
  70. }
  71. }