RequestPetitionCancel.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.data.xml.impl.AdminData;
  22. import com.l2jserver.gameserver.instancemanager.PetitionManager;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. /**
  28. * <p>
  29. * Format: (c) d
  30. * <ul>
  31. * <li>d: Unknown</li>
  32. * </ul>
  33. * </p>
  34. * @author -Wooden-, TempyIncursion
  35. */
  36. public final class RequestPetitionCancel extends L2GameClientPacket
  37. {
  38. private static final String _C__8A_REQUEST_PETITIONCANCEL = "[C] 8A RequestPetitionCancel";
  39. // private int _unknown;
  40. @Override
  41. protected void readImpl()
  42. {
  43. // _unknown = readD(); This is pretty much a trigger packet.
  44. }
  45. @Override
  46. protected void runImpl()
  47. {
  48. L2PcInstance activeChar = getClient().getActiveChar();
  49. if (activeChar == null)
  50. {
  51. return;
  52. }
  53. if (PetitionManager.getInstance().isPlayerInConsultation(activeChar))
  54. {
  55. if (activeChar.isGM())
  56. {
  57. PetitionManager.getInstance().endActivePetition(activeChar);
  58. }
  59. else
  60. {
  61. activeChar.sendPacket(SystemMessageId.PETITION_UNDER_PROCESS);
  62. }
  63. }
  64. else
  65. {
  66. if (PetitionManager.getInstance().isPlayerPetitionPending(activeChar))
  67. {
  68. if (PetitionManager.getInstance().cancelActivePetition(activeChar))
  69. {
  70. int numRemaining = Config.MAX_PETITIONS_PER_PLAYER - PetitionManager.getInstance().getPlayerTotalPetitionCount(activeChar);
  71. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PETITION_CANCELED_SUBMIT_S1_MORE_TODAY);
  72. sm.addString(String.valueOf(numRemaining));
  73. activeChar.sendPacket(sm);
  74. // Notify all GMs that the player's pending petition has been cancelled.
  75. String msgContent = activeChar.getName() + " has canceled a pending petition.";
  76. AdminData.getInstance().broadcastToGMs(new CreatureSay(activeChar.getObjectId(), Say2.HERO_VOICE, "Petition System", msgContent));
  77. }
  78. else
  79. {
  80. activeChar.sendPacket(SystemMessageId.FAILED_CANCEL_PETITION_TRY_LATER);
  81. }
  82. }
  83. else
  84. {
  85. activeChar.sendPacket(SystemMessageId.PETITION_NOT_SUBMITTED);
  86. }
  87. }
  88. }
  89. @Override
  90. public String getType()
  91. {
  92. return _C__8A_REQUEST_PETITIONCANCEL;
  93. }
  94. }