RequestStopPledgeWar.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 net.sf.l2j.gameserver.datatables.ClanTable;
  17. import net.sf.l2j.gameserver.model.L2Clan;
  18. import net.sf.l2j.gameserver.model.L2World;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.serverpackets.ActionFailed;
  22. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  23. public final class RequestStopPledgeWar extends L2GameClientPacket
  24. {
  25. private static final String _C__4F_REQUESTSTOPPLEDGEWAR = "[C] 4F RequestStopPledgeWar";
  26. //private static Logger _log = Logger.getLogger(RequestStopPledgeWar.class.getName());
  27. private String _pledgeName;
  28. @Override
  29. protected void readImpl()
  30. {
  31. _pledgeName = readS();
  32. }
  33. @Override
  34. protected void runImpl()
  35. {
  36. L2PcInstance player = getClient().getActiveChar();
  37. if (player == null) return;
  38. L2Clan playerClan = player.getClan();
  39. if (playerClan == null) return;
  40. L2Clan clan = ClanTable.getInstance().getClanByName(_pledgeName);
  41. if (clan == null)
  42. {
  43. player.sendMessage("No such clan.");
  44. player.sendPacket(ActionFailed.STATIC_PACKET);
  45. return;
  46. }
  47. if (!playerClan.isAtWarWith(clan.getClanId()))
  48. {
  49. player.sendMessage("You aren't at war with this clan.");
  50. player.sendPacket(ActionFailed.STATIC_PACKET);
  51. return;
  52. }
  53. // Check if player who does the request has the correct rights to do it
  54. if ((player.getClanPrivileges() & L2Clan.CP_CL_PLEDGE_WAR) != L2Clan.CP_CL_PLEDGE_WAR )
  55. {
  56. player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
  57. return;
  58. }
  59. //_log.info("RequestStopPledgeWar: By leader or authorized player: " + playerClan.getLeaderName() + " of clan: "
  60. // + playerClan.getName() + " to clan: " + _pledgeName);
  61. // L2PcInstance leader = L2World.getInstance().getPlayer(clan.getLeaderName());
  62. // if(leader != null && leader.isOnline() == 0)
  63. // {
  64. // player.sendMessage("Clan leader isn't online.");
  65. // player.sendPacket(ActionFailed.STATIC_PACKET);
  66. // return;
  67. // }
  68. // if (leader.isProcessingRequest())
  69. // {
  70. // SystemMessage sm = new SystemMessage(SystemMessage.S1_IS_BUSY_TRY_LATER);
  71. // sm.addString(leader.getName());
  72. // player.sendPacket(sm);
  73. // return;
  74. // }
  75. ClanTable.getInstance().deleteclanswars(playerClan.getClanId(), clan.getClanId());
  76. for (L2PcInstance cha : L2World.getInstance().getAllPlayers()) {
  77. if (cha.getClan() == player.getClan() || cha.getClan() == clan)
  78. cha.broadcastUserInfo();
  79. }
  80. }
  81. @Override
  82. public String getType()
  83. {
  84. return _C__4F_REQUESTSTOPPLEDGEWAR;
  85. }
  86. }