SendBypassBuildCmd.java 3.0 KB

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