RequestPetitionCancel.java 3.1 KB

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