DlgAnswer.java 3.4 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 java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
  19. import com.l2jserver.gameserver.handler.AdminCommandHandler;
  20. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.network.SystemMessageId;
  23. import com.l2jserver.gameserver.util.GMAudit;
  24. /**
  25. * @author Dezmond_snz
  26. * Format: cddd
  27. */
  28. public final class DlgAnswer extends L2GameClientPacket
  29. {
  30. private static final String _C__C5_DLGANSWER = "[C] C5 DlgAnswer";
  31. private static Logger _log = Logger.getLogger(DlgAnswer.class.getName());
  32. private int _messageId;
  33. private int _answer;
  34. private int _requesterId;
  35. @Override
  36. protected void readImpl()
  37. {
  38. _messageId = readD();
  39. _answer = readD();
  40. _requesterId = readD();
  41. }
  42. @Override
  43. public void runImpl()
  44. {
  45. final L2PcInstance activeChar = getClient().getActiveChar();
  46. if (activeChar == null)
  47. return;
  48. if (Config.DEBUG)
  49. _log.fine(getType()+": Answer accepted. Message ID "+_messageId+", answer "+_answer+", Requester ID "+_requesterId);
  50. if (_messageId == SystemMessageId.RESSURECTION_REQUEST_BY_C1_FOR_S2_XP.getId()
  51. || _messageId == SystemMessageId.RESURRECT_USING_CHARM_OF_COURAGE.getId())
  52. activeChar.reviveAnswer(_answer);
  53. else if (_messageId==SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId())
  54. activeChar.teleportAnswer(_answer, _requesterId);
  55. else if (_messageId == SystemMessageId.S1.getId())
  56. {
  57. String _command = activeChar.getAdminConfirmCmd();
  58. if (_command == null)
  59. {
  60. if (Config.L2JMOD_ALLOW_WEDDING)
  61. activeChar.engageAnswer(_answer);
  62. }
  63. else
  64. {
  65. activeChar.setAdminConfirmCmd(null);
  66. if (_answer == 0)
  67. return;
  68. String command = _command.split(" ")[0];
  69. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler(command);
  70. if (AdminCommandAccessRights.getInstance().hasAccess(command, activeChar.getAccessLevel()))
  71. {
  72. if (Config.GMAUDIT)
  73. GMAudit.auditGMAction(activeChar.getName()+" ["+activeChar.getObjectId()+"]", _command, (activeChar.getTarget() != null?activeChar.getTarget().getName():"no-target"));
  74. ach.useAdminCommand(_command, activeChar);
  75. }
  76. }
  77. }
  78. else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_OPEN_THE_GATE.getId())
  79. activeChar.gatesAnswer(_answer, 1);
  80. else if (_messageId == SystemMessageId.WOULD_YOU_LIKE_TO_CLOSE_THE_GATE.getId())
  81. activeChar.gatesAnswer(_answer, 0);
  82. }
  83. @Override
  84. public String getType()
  85. {
  86. return _C__C5_DLGANSWER;
  87. }
  88. }