SendBypassBuildCmd.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.handler.AdminCommandHandler;
  23. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.util.GMAudit;
  26. /**
  27. * This class handles all GM commands triggered by //command
  28. * @version $Revision: 1.3.4.2 $ $Date: 2005/03/27 15:29:29 $
  29. */
  30. public final class SendBypassBuildCmd extends L2GameClientPacket
  31. {
  32. private static final String _C__74_SENDBYPASSBUILDCMD = "[C] 74 SendBypassBuildCmd";
  33. public static final int GM_MESSAGE = 9;
  34. public static final int ANNOUNCEMENT = 10;
  35. private String _command;
  36. @Override
  37. protected void readImpl()
  38. {
  39. _command = readS();
  40. if (_command != null)
  41. {
  42. _command = _command.trim();
  43. }
  44. }
  45. @Override
  46. protected void runImpl()
  47. {
  48. L2PcInstance activeChar = getClient().getActiveChar();
  49. if (activeChar == null)
  50. {
  51. return;
  52. }
  53. String command = "admin_" + _command.split(" ")[0];
  54. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
  55. if (ach == null)
  56. {
  57. if (activeChar.isGM())
  58. {
  59. activeChar.sendMessage("The command " + command.substring(6) + " does not exists!");
  60. }
  61. _log.warning("No handler registered for admin command '" + command + "'");
  62. return;
  63. }
  64. if (!AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel()))
  65. {
  66. activeChar.sendMessage("You don't have the access right to use this command!");
  67. _log.warning("Character " + activeChar.getName() + " tryed to use admin command " + command + ", but have no access to it!");
  68. return;
  69. }
  70. if (Config.GMAUDIT)
  71. {
  72. GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", _command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
  73. }
  74. ach.useAdminCommand("admin_" + _command, activeChar);
  75. }
  76. @Override
  77. public String getType()
  78. {
  79. return _C__74_SENDBYPASSBUILDCMD;
  80. }
  81. }